// ==UserScript== // @name 아프리카TV - 사이드바 UI 변경 // @name:ko 아프리카TV - 사이드바 UI 변경 // @namespace https://www.afreecatv.com/ // @version 20240318 // @description 아프리카TV의 사이드바 UI를 변경합니다. // @description:ko 아프리카TV의 사이드바 UI를 변경합니다. // @author You // @match https://www.afreecatv.com/ // @match https://www.afreecatv.com/?hash=* // @match https://www.afreecatv.com/?NaPm=* // @match https://play.afreecatv.com/*/* // @icon https://www.google.com/s2/favicons?sz=64&domain=afreecatv.com // @grant GM_addStyle // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // @run-at document-end // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; const currentUrl = window.location.href; let display_follow = GM_getValue("display_follow", 6); let display_myplus = GM_getValue("display_myplus", 6); let display_myplusvod = GM_getValue("display_myplusvod", 4); let display_top = GM_getValue("display_top", 6); let myplus_position = GM_getValue("myplus_position", 1); let myplus_order = GM_getValue("myplus_order", 1); let clickDisplayCount = GM_getValue("clickDisplayCount", 10); let blockedUsers = GM_getValue('blockedUsers', []); let blockedCategories = GM_getValue('blockedCategories', []); let open_newtab = GM_getValue("open_newtab", 0); let playerSmode = GM_getValue("playerSmode", 0); let preplayerSmode = playerSmode; let sidebarMinimized = GM_getValue("sidebarMinimized", 0); let smodeSidebar = GM_getValue("smodeSidebar", 1); let menuIds = {}; let categoryMenuIds = {}; const isDarkMode = document.body.classList.contains('thema_dark'); let savedCategory = GM_getValue("szBroadCategory",0); let delayCheckEnabled = true; let sharpModeCheckEnabled = true; let autoChangeQuality = GM_getValue("autoChangeQuality", 0); let autoChangeMute = GM_getValue("autoChangeMute", 0); let removeDupSwitch = GM_getValue("removeDupSwitch", 1); let showUptime = GM_getValue("showUptime", 1); let showRemainingBuffer = GM_getValue("showRemainingBuffer", 1); let pinSwitch_push = GM_getValue("pinSwitch_push", 0); let pinSwitch_pin = GM_getValue("pinSwitch_pin", 0); let bottomChatSwitch = GM_getValue("bottomChatSwitch", 1); let webplayer_scroll_left = 240; if(sidebarMinimized){ webplayer_scroll_left = 52; } // 데이터를 로드하고 처리하는 함수 function loadData() { // 현재 시간 기록 var currentTime = new Date().getTime(); // 이전 실행 시간 불러오기 var lastExecutionTime = GM_getValue("lastExecutionTime", 0); // 마지막 실행 시간으로부터 1시간 이상 경과했는지 확인 if (currentTime - lastExecutionTime >= 3600000) { // 1시간은 3600000 밀리초 GM_xmlhttpRequest({ method: "GET", url: "https://live.afreecatv.com/script/locale/ko_KR/broad_category.js", onload: function(response) { if (response.status === 200) { // 성공적으로 데이터를 받았을 때 처리할 코드 작성 var szBroadCategory = response.responseText; // 이후 처리할 작업 추가 szBroadCategory = JSON.parse(szBroadCategory.split('var szBroadCategory = ')[1].slice(0, -1)); if (szBroadCategory.CHANNEL.RESULT === "1") { // 데이터 저장 GM_setValue("szBroadCategory", szBroadCategory); // 현재 시간을 마지막 실행 시간으로 업데이트 GM_setValue("lastExecutionTime", currentTime); } } else { console.error("Failed to load data:", response.statusText); } }, onerror: function(error) { console.error("Error occurred while loading data:", error); } }); } else { console.log("1 hour not elapsed since last execution. Skipping data load."); } } // 페이지가 로드되면 데이터를 로드하고 처리 window.addEventListener('load', function() { //console.log(GM_getValue("lastExecutionTime")); loadData(); }); const commonCss = ` .modal { display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4); color: black; } .modal-content { background-color: #fefefe; margin: 15% auto; padding: 20px; border: 1px solid #888; border-radius: 10px; width: 80%; max-width: 500px; } .myModalClose { color: #aaa; float: right; font-size: 36px; font-weight: bold; margin-top: -12px; } .myModalClose:hover, .myModalClose:focus { color: black; text-decoration: none; cursor: pointer; } .option { margin-bottom: 20px; display: flex; align-items: center; } .option label { margin-right: 10px; font-size: 16px; } .switch { position: relative; display: inline-block; width: 60px; height: 34px; } .switch input { display: none; } .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; } .slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; } input:checked + .slider { background-color: #2196F3; } input:focus + .slider { box-shadow: 0 0 1px #2196F3; } input:checked + .slider:before { transform: translateX(26px); } .slider.round { border-radius: 34px; min-width: 60px; } .slider.round:before { border-radius: 50%; } #range { width: 100%; } #rangeValue { display: inline-block; margin-left: 10px; } .divider { width: 100%; /* 가로 폭 설정 */ height: 1px; /* 세로 높이 설정 */ background-color: #000; /* 배경색 설정 */ margin: 20px 0; /* 위아래 여백 설정 */ } #openModalBtn { box-sizing: border-box; font-size: 12px; line-height: 1.2 !important; font-family: "NG"; list-style: none; position: relative; margin-left: 12px; width: 40px; height: 40px; } #topInnerHeader #openModalBtn { margin-right: 12px; } #openModalBtn > button { background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3e%3cpath d='M11 2.5c1.07 0 1.938.867 1.938 1.938l-.001.245.12.036c.318.104.628.232.927.382l.112.06.174-.173a1.937 1.937 0 0 1 2.594-.126l.128.117a1.923 1.923 0 0 1 .015 2.748l-.17.171.062.117c.151.299.279.608.382.927l.036.12h.245c1.02 0 1.855.787 1.932 1.787L19.5 11c0 1.07-.867 1.938-1.938 1.938l-.246-.001-.035.12a6.578 6.578 0 0 1-.382.926l-.062.116.155.157c.333.322.537.752.578 1.21l.008.172c0 .521-.212 1.02-.576 1.372a1.938 1.938 0 0 1-2.733 0l-.173-.174-.112.06a6.58 6.58 0 0 1-.927.383l-.12.035v.247a1.936 1.936 0 0 1-1.786 1.931l-.151.006a1.938 1.938 0 0 1-1.938-1.937v-.245l-.119-.035a6.58 6.58 0 0 1-.927-.382l-.114-.062-.168.171a1.94 1.94 0 0 1-2.62.119l-.123-.113a1.94 1.94 0 0 1-.003-2.746l.172-.171-.06-.112a6.578 6.578 0 0 1-.381-.927l-.036-.119h-.245a1.938 1.938 0 0 1-1.932-1.786l-.006-.151c0-1.07.867-1.938 1.938-1.938h.245l.036-.119a6.33 6.33 0 0 1 .382-.926l.059-.113-.175-.174a1.94 1.94 0 0 1-.108-2.619l.114-.123a1.94 1.94 0 0 1 2.745.008l.166.168.114-.06c.3-.152.609-.28.927-.383l.119-.036v-.25c0-1.019.787-1.854 1.787-1.931zm0 1a.937.937 0 0 0-.938.938v.937a.322.322 0 0 0 .02.098 5.578 5.578 0 0 0-2.345.966.347.347 0 0 0-.056-.075l-.656-.663a.94.94 0 1 0-1.331 1.326l.665.663c.023.02.048.036.075.05a5.576 5.576 0 0 0-.965 2.343l-.094-.019h-.938a.937.937 0 1 0 0 1.875h.938l.094-.018c.137.845.468 1.647.965 2.343a.375.375 0 0 0-.075.05l-.665.663a.94.94 0 1 0 1.331 1.325l.656-.662a.347.347 0 0 0 .056-.075 5.58 5.58 0 0 0 2.344.966.322.322 0 0 0-.018.094v.936a.937.937 0 1 0 1.874 0v-.938l-.018-.094a5.58 5.58 0 0 0 2.343-.966l.047.075.666.663a.937.937 0 0 0 1.322 0 .922.922 0 0 0 0-1.326l-.656-.663-.075-.05a5.578 5.578 0 0 0 .965-2.343.57.57 0 0 0 .094.018h.938a.937.937 0 1 0 0-1.874h-.938a.57.57 0 0 0-.094.016 5.576 5.576 0 0 0-.965-2.343l.075-.05.656-.663a.922.922 0 0 0 0-1.325.938.938 0 0 0-1.322 0l-.666.662-.046.075a5.578 5.578 0 0 0-2.344-.966l.018-.094v-.938A.937.937 0 0 0 11 3.5zm0 4.188a3.313 3.313 0 1 1 0 6.625 3.313 3.313 0 0 1 0-6.626zm0 1a2.313 2.313 0 1 0 0 4.625 2.313 2.313 0 0 0 0-4.626z' fill='%23707173'/%3e%3c/svg%3e") 50% 50% no-repeat !important; background-size: 18px 22px; !important; } `; const css_Darkmode = ` @media screen and (max-width: 1136px) { .left_navbar a:first-child { display: none; } } #sidebar.min { width: 52px; } #sidebar.min .users-section a.user span { display: none; } #sidebar.min .users-section button { font-size:11px; padding: 1px; } #sidebar.max .button-fold-sidebar { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none slice' viewBox='0 0 7 11'%3e%3cpath fill='%23f9f9f9' d='M5.87 11.01L.01 5.51 5.87.01l1.08 1.01-4.74 4.45L7 9.96 5.87 11z'/%3e%3c/svg%3e"); background-size: 7px 11px; background-repeat: no-repeat; width: 26px; height: 26px; background-position: center; position: absolute; top: 13px; left: 200px; } #sidebar.max .button-unfold-sidebar { display:none; } #sidebar.min .button-fold-sidebar { display:none; } #sidebar.min .button-unfold-sidebar { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none slice' viewBox='0 0 7 11'%3e%3cpath fill='%23f9f9f9' d='M1.13 11.01l5.86-5.5L1.13.01.05 1.02l4.74 4.45L0 9.96 1.13 11z'/%3e%3c/svg%3e"); background-size: 7px 11px; background-repeat: no-repeat; width: 26px; height: 26px; background-position: center; position: relative; top: 8px; left: 12px; padding-bottom:10px; } #sidebar.min .top-section span.max{ display:none; } #sidebar.max .top-section span.min{ display:none; } .game_post_area { width: 94%; left: 30px; } .game_post_area .scroll_area ul li{ background-color:#0E0E10; } #list-container { overflow-x: hidden; background-color:#0E0E10; } #listMain #wrap { min-width: 960px; } #listMain #wrap #serviceHeader { min-width: 960px; } #listMain #wrap #list-container #list-section { padding: 12px 22px 0 38px; } button.block-icon-svg-white { width: 40px; height: 50px; } button.block-icon-svg-white span { background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="100" height="100" viewBox="0 0 64 64" style="fill:%23B2B2B2;"%3E%3Cpath d="M32 6C17.641 6 6 17.641 6 32C6 46.359 17.641 58 32 58C46.359 58 58 46.359 58 32C58 17.641 46.359 6 32 6zM32 10C37.331151 10 42.225311 11.905908 46.037109 15.072266L14.505859 45.318359C11.682276 41.618415 10 37.00303 10 32C10 19.869 19.869 10 32 10zM48.927734 17.962891C52.094092 21.774689 54 26.668849 54 32C54 44.131 44.131 54 32 54C26.99697 54 22.381585 52.317724 18.681641 49.494141L48.927734 17.962891z"%3E%3C/path%3E%3C/svg%3E'); background-size: 100% 100%; width: 20px; height: 20px; } button.block-icon-svg-white:hover span { background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="100" height="100" viewBox="0 0 64 64" style="fill:%235285FF;"%3E%3Cpath d="M32 6C17.641 6 6 17.641 6 32C6 46.359 17.641 58 32 58C46.359 58 58 46.359 58 32C58 17.641 46.359 6 32 6zM32 10C37.331151 10 42.225311 11.905908 46.037109 15.072266L14.505859 45.318359C11.682276 41.618415 10 37.00303 10 32C10 19.869 19.869 10 32 10zM48.927734 17.962891C52.094092 21.774689 54 26.668849 54 32C54 44.131 44.131 54 32 54C26.99697 54 22.381585 52.317724 18.681641 49.494141L48.927734 17.962891z"%3E%3C/path%3E%3C/svg%3E'); } html { overflow: hidden; } .users-section.myplus > .user.show-more, .users-section.follow > .user.show-more, .users-section.top > .user.show-more, .users-section.myplusvod > .user.show-more { display: none; } #toggleButton, #toggleButton2, #toggleButton3, #toggleButton4 { padding:12px; color:#A1A1A1; width: 100%; text-align: center; } .left_navbar { display: flex; align-items: center; justify-content: flex-end; position: absolute; flex-direction: row-reverse; top: 0px; left: 160px; } .left_nav_button { position: relative; width: 70px; height: 70px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; z-index: 3001; transition: all .2s; color: #e5e5e5; font-size: 15px; font-weight: 600; } .left_nav_button.active { color: #019BFE; } #sidebar { width: 240px; grid-area: sidebar; background-color: #1F1F23; color:white; margin-right:10px; padding-bottom:360px; } #sidebar .top-section { display: flex; align-items: center; justify-content: space-around; margin: 12px 0px 6px 0px; } #sidebar .top-section>span { text-transform: uppercase; font-weight: 550; font-size: 14px; margin-top: 6px; margin-bottom: 2px; color:#DEDEE3; } #sidebar .top-section>span>a { color:#DEDEE3; } #sidebar .twitch-message-section { margin: 0px 10px; margin-top: 10px; padding: 0 25px; background-color: #1F1F23; } #sidebar .twitch-message-section .title { margin: 0px; font-size: 1.5rem; font-weight: 500; } #sidebar .twitch-message-section .title>span { color: var(--primary-color); } #sidebar .twitch-message-section .description { margin: 8px 0px; line-height: 1.3rem; font-size: 0.9rem; color: #A1A1A1; } #sidebar .twitch-message-section .description>span { display: block; text-align: center; } .users-section .user { display: grid; grid-template-areas: "profile-picture username watchers" "profile-picture description blank"; grid-template-columns: 40px auto auto; padding: 6px 10px; } .users-section .user:hover { background-color: #26262c; cursor: pointer; } .users-section .user .profile-picture { grid-area: profile-picture; width: 32px; height: 32px; border-radius: 50%; } .users-section .user .username { grid-area: username; font-size: 14px; font-weight: 600; color:#DEDEE3; letter-spacing: 0.6px; margin-left:1px; } .users-section .user .description { grid-area: description; font-size: 13px; color: #a1a1a1; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left:1px; } .users-section .user .watchers { grid-area: watchers; display: flex; align-items: center; justify-content: flex-end; font-weight: 400; font-size: 14px; color: #c0c0c0; margin-right: 2px; } .users-section .user .watchers .dot { font-size: 7px; margin-right: 5px; } #listMain #wrap #serviceHeader #afLogo { left: 30px; height: 72px; } .btn_flexible { display: none; } #innerLnb { display: none; } #list-container { height: 100vh; overflow-y: auto; } #sidebar { height: 100vh; overflow-y: auto; position: fixed; scrollbar-width: none; /* 파이어폭스 */ } #sidebar::-webkit-scrollbar { display: none; /* Chrome, Safari, Edge */ } .tooltip-container { z-index: 999; width: 480px; height: auto; position: fixed; background-color: #26262C; display: flex; border-radius: 10px; box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.5); } .tooltip-container img { position: relative; z-index: 999; width: auto; height: auto; max-width:480px; max-height:270px flex: 0; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; } .tooltiptext { flex: 0; position: relative; z-index: 999; width: 480px; max-width: 100%; /* 넘치는 경우 최대 너비 */ height: auto; background-color: #26262C; color: #fff; text-align: center; align-items: center; /* 세로 가운데 정렬 */ justify-content: center; /* 가로 가운데 정렬 */ box-sizing: border-box; /* 패딩을 포함한 전체 너비 유지 */ padding: 8px 20px 14px 20px; font-size: 15px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; } #serviceHeader .a_d_banner { display: none !important; } .profile-grayscale { filter: grayscale(100%) contrast(85%); opacity: .8; } `; const css_Whitemode = ` @media screen and (max-width: 1136px) { .left_navbar a:first-child { display: none; } } #sidebar.max { width: 240px; } #sidebar.min { width: 52px; } #sidebar.min .users-section a.user span { display: none; } #sidebar.min .users-section button { font-size:11px; padding: 1px; } #sidebar.max .button-fold-sidebar { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none slice' viewBox='0 0 7 11'%3e%3cpath fill='%23888' d='M5.87 11.01L.01 5.51 5.87.01l1.08 1.01-4.74 4.45L7 9.96 5.87 11z'/%3e%3c/svg%3e"); background-size: 7px 11px; background-repeat: no-repeat; width: 26px; height: 26px; background-position: center; position: absolute; top: 13px; left: 200px; } #sidebar.max .button-unfold-sidebar { display:none; } #sidebar.min .button-fold-sidebar { display:none; } #sidebar.min .button-unfold-sidebar { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none slice' viewBox='0 0 7 11'%3e%3cpath fill='%23888' d='M1.13 11.01l5.86-5.5L1.13.01.05 1.02l4.74 4.45L0 9.96 1.13 11z'/%3e%3c/svg%3e"); background-size: 7px 11px; background-repeat: no-repeat; width: 26px; height: 26px; background-position: center; position: relative; top: 8px; left: 12px; padding-bottom:10px; } #sidebar.min .top-section span.max{ display:none; } #sidebar.max .top-section span.min{ display:none; } .game_post_area { width: 94%; left: 30px; } .game_post_area .scroll_area ul li{ background-color:#F7F7F8; } #list-container { overflow-x: hidden; background-color:#F7F7F8; } #listMain #wrap { min-width: 960px; } #listMain #wrap #serviceHeader { min-width: 960px; } #listMain #wrap #list-container #list-section { padding: 12px 22px 0 38px; } button.block-icon-svg { width: 40px; height: 50px; } button.block-icon-svg span { background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="100" height="100" viewBox="0 0 64 64" style="fill:%237C7D7D;"%3E%3Cpath d="M32 6C17.641 6 6 17.641 6 32C6 46.359 17.641 58 32 58C46.359 58 58 46.359 58 32C58 17.641 46.359 6 32 6zM32 10C37.331151 10 42.225311 11.905908 46.037109 15.072266L14.505859 45.318359C11.682276 41.618415 10 37.00303 10 32C10 19.869 19.869 10 32 10zM48.927734 17.962891C52.094092 21.774689 54 26.668849 54 32C54 44.131 44.131 54 32 54C26.99697 54 22.381585 52.317724 18.681641 49.494141L48.927734 17.962891z"%3E%3C/path%3E%3C/svg%3E'); background-size: 100% 100%; width: 20px; height: 20px; } button.block-icon-svg:hover span { background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="100" height="100" viewBox="0 0 64 64" style="fill:%235285FF;"%3E%3Cpath d="M32 6C17.641 6 6 17.641 6 32C6 46.359 17.641 58 32 58C46.359 58 58 46.359 58 32C58 17.641 46.359 6 32 6zM32 10C37.331151 10 42.225311 11.905908 46.037109 15.072266L14.505859 45.318359C11.682276 41.618415 10 37.00303 10 32C10 19.869 19.869 10 32 10zM48.927734 17.962891C52.094092 21.774689 54 26.668849 54 32C54 44.131 44.131 54 32 54C26.99697 54 22.381585 52.317724 18.681641 49.494141L48.927734 17.962891z"%3E%3C/path%3E%3C/svg%3E'); } html { overflow: hidden; } .users-section.myplus > .user.show-more, .users-section.follow > .user.show-more, .users-section.top > .user.show-more, .users-section.myplusvod > .user.show-more { display: none; } #toggleButton, #toggleButton2, #toggleButton3, #toggleButton4 { padding:12px; color:#53535F; width: 100%; text-align: center; } .left_navbar { display: flex; align-items: center; justify-content: flex-end; position: absolute; flex-direction: row-reverse; top: 0px; left: 160px; } .left_nav_button { position: relative; width: 70px; height: 70px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; z-index: 3001; transition: all .2s; color: 1F1F23; font-size: 15px; font-weight: 600; } .left_nav_button.active { color: #0545B1; } #sidebar { width: 240px; grid-area: sidebar; background-color: #EFEFF1; color:black; padding-bottom:360px; } #sidebar .top-section { display: flex; align-items: center; justify-content: space-around; margin: 12px 0px 6px 0px; } #sidebar .top-section>span { text-transform: uppercase; font-weight: 600; font-size: 14px; margin-top: 6px; margin-bottom: 2px; color:#0E0E10; } #sidebar .top-section>span>a { color:#0E0E10; } #sidebar .twitch-message-section { margin: 0px 10px; margin-top: 10px; padding: 0 25px; background-color: #EFEFF1; } #sidebar .twitch-message-section .title { margin: 0px; font-size: 1.5rem; font-weight: 500; } #sidebar .twitch-message-section .title>span { color: var(--primary-color); } #sidebar .twitch-message-section .description { margin: 8px 0px; line-height: 1.3rem; font-size: 0.9rem; color: #53535F; } #sidebar .twitch-message-section .description>span { display: block; text-align: center; } .users-section .user { display: grid; grid-template-areas: "profile-picture username watchers" "profile-picture description blank"; grid-template-columns: 40px auto auto; padding: 6px 10px; } .users-section .user:hover { background-color: #E6E6EA; cursor: pointer; } .users-section .user .profile-picture { grid-area: profile-picture; width: 32px; height: 32px; border-radius: 50%; } .users-section .user .username { grid-area: username; font-size: 14px; font-weight: 600; color:#1F1F23; letter-spacing: 0.6px; margin-left:1px; } .users-section .user .description { grid-area: description; font-size: 13px; font-weight: 400; color: #53535F; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left:1px; } .users-section .user .watchers { grid-area: watchers; display: flex; align-items: center; justify-content: flex-end; font-size: 14px; font-weight: 400; color: black; margin-right: 2px; } .users-section .user .watchers .dot { font-size: 7px; margin-right: 5px; } #listMain #wrap #serviceHeader #afLogo { left: 30px; height: 72px; } .btn_flexible { display: none; } #innerLnb { display: none; } #list-container { height: 100vh; overflow-y: auto; } #sidebar { height: 100vh; overflow-y: auto; position: fixed; scrollbar-width: none; /* 파이어폭스 */ } #sidebar::-webkit-scrollbar { display: none; /* Chrome, Safari, Edge */ } .tooltip-container { z-index: 999; width: 480px; height: auto; position: fixed; background-color: #E6E6EA; display: flex; border-radius: 10px; box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.5); } .tooltip-container img { position: relative; z-index: 999; width: auto; height: auto; max-width:480px; max-height:270px flex: 0; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; } .tooltiptext { flex: 0; position: relative; z-index: 999; width: 480px; max-width: 100%; /* 넘치는 경우 최대 너비 */ height: auto; background-color: #E6E6EA; color: black; text-align: center; align-items: center; /* 세로 가운데 정렬 */ justify-content: center; /* 가로 가운데 정렬 */ box-sizing: border-box; /* 패딩을 포함한 전체 너비 유지 */ padding: 8px 20px 14px 20px; font-size: 15px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; } #serviceHeader .a_d_banner { display: none !important; } .profile-grayscale { filter: grayscale(100%) contrast(85%); opacity: .8; } `; const css_Darkmode_player = ` .remainingBuffer { overflow: visible; display: inline-block; position: relative; z-index: 1; margin-left: 15px; vertical-align: middle; } .remainingBuffer p{ font-size: 12px; color: #888888; vertical-align: middle; text-align: center; } .elapsed-time { overflow: visible; display: inline-block; position: relative; z-index: 1; margin-left: 15px; vertical-align: middle; } .elapsed-time p{ font-size: 13px; vertical-align: middle; text-align: center; } @media (max-width: 1320px) { .layout_v2#webplayer.chat_open #webplayer_contents, .layout_v2#webplayer.chat_open.list_open #webplayer_contents, .layout_v2#webplayer.chat_open.list_bookmark_open #webplayer_contents { min-width: 600px; } } @media screen and (max-width: 1120px) { .left_nav_button { display: none; } } #sidebar.max { width: 240px; } #sidebar.min { width: 52px; } #sidebar.min .users-section a.user span { display: none; } #sidebar.min .users-section button { font-size:11px; padding: 1px; } #sidebar.max .button-fold-sidebar { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none slice' viewBox='0 0 7 11'%3e%3cpath fill='%23f9f9f9' d='M5.87 11.01L.01 5.51 5.87.01l1.08 1.01-4.74 4.45L7 9.96 5.87 11z'/%3e%3c/svg%3e"); background-size: 7px 11px; background-repeat: no-repeat; width: 26px; height: 26px; background-position: center; position: absolute; top: 13px; left: 200px; } #sidebar.max .button-unfold-sidebar { display:none; } #sidebar.min .button-fold-sidebar { display:none; } #sidebar.min .button-unfold-sidebar { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none slice' viewBox='0 0 7 11'%3e%3cpath fill='%23f9f9f9' d='M1.13 11.01l5.86-5.5L1.13.01.05 1.02l4.74 4.45L0 9.96 1.13 11z'/%3e%3c/svg%3e"); background-size: 7px 11px; background-repeat: no-repeat; width: 26px; height: 26px; background-position: center; position: relative; top: 10px; left: 12px; padding-bottom:10px; } #sidebar.min .top-section span.max{ display:none; } #sidebar.max .top-section span.min{ display:none; } #afreecatv_player { width: 100%; } .smode #webplayer_scroll { top: 0; left:0; } #webplayer_scroll{ left: ${webplayer_scroll_left}px; } #sidebar { height:100vh; grid-area: sidebar; background-color: #1F1F23; color:white; overflow-y: auto; position: fixed; top: 56px; scrollbar-width: none; /* 파이어폭스 */ } #sidebar > :last-child { padding-bottom: 360px; /* 마지막 자식에만 padding 추가 */ } #sidebar::-webkit-scrollbar { display: none; /* Chrome, Safari, Edge */ } #sidebar .top-section { display: flex; align-items: center; justify-content: space-around; margin: 12px 0px 6px 0px; } #sidebar .top-section>span { text-transform: uppercase; font-weight: 550; font-size: 14px; margin-top: 6px; margin-bottom: 2px; color:#DEDEE3; } #sidebar .top-section>span>a { color:#DEDEE3; } #sidebar .twitch-message-section { margin: 0px 10px; margin-top: 10px; padding: 0 25px; background-color: #1F1F23; } #sidebar .twitch-message-section .title { margin: 0px; font-size: 1.5rem; font-weight: 500; } #sidebar .twitch-message-section .title>span { color: var(--primary-color); } #sidebar .twitch-message-section .description { margin: 8px 0px; line-height: 1.3rem; font-size: 0.9rem; color: #A1A1A1; } #sidebar .twitch-message-section .description>span { display: block; text-align: center; } .users-section .user { display: grid; grid-template-areas: "profile-picture username watchers" "profile-picture description blank"; grid-template-columns: 40px auto auto; padding: 6px 10px; } .users-section .user:hover { background-color: #26262c; cursor: pointer; } .users-section .user .profile-picture { grid-area: profile-picture; width: 32px; height: 32px; border-radius: 50%; } .users-section .user .username { grid-area: username; font-size: 14px; font-weight: 600; color:#DEDEE3; letter-spacing: 0.6px; margin-left:1px; } .users-section .user .description { grid-area: description; font-size: 13px; color: #a1a1a1; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left:1px; } .users-section .user .watchers { grid-area: watchers; display: flex; align-items: center; justify-content: flex-end; font-weight: 400; font-size: 14px; color: #c0c0c0; margin-right: 2px; } .users-section .user .watchers .dot { font-size: 7px; margin-right: 5px; } #webplayer_top .logo { top: 18px; left: 18px; } .left_navbar { display: flex; align-items: center; justify-content: flex-end; position: absolute; flex-direction: row-reverse; top: 0px; left: 140px; } .left_nav_button { position: relative; width: 70px; height: 56px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; z-index: 3001; transition: all .2s; color: #e5e5e5; font-size: 15px; font-weight: 600; } .tooltip-container { z-index: 999; width: 480px; height: auto; position: fixed; background-color: #26262C; display: flex; border-radius: 10px; box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.5); } .tooltip-container img { position: relative; z-index: 999; width: auto; height: auto; max-width:480px; max-height:270px flex: 0; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; } .tooltiptext { flex: 0; position: relative; z-index: 999; width: 480px; max-width: 100%; /* 넘치는 경우 최대 너비 */ height: auto; background-color: #26262C; color: #fff; text-align: center; align-items: center; /* 세로 가운데 정렬 */ justify-content: center; /* 가로 가운데 정렬 */ box-sizing: border-box; /* 패딩을 포함한 전체 너비 유지 */ padding: 8px 20px 14px 20px; font-size: 15px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; } .users-section.myplus > .user.show-more, .users-section.follow > .user.show-more, .users-section.top > .user.show-more, .users-section.myplusvod > .user.show-more { display: none; } #toggleButton, #toggleButton2, #toggleButton3, #toggleButton4 { padding:12px; color:#A1A1A1; width: 100%; text-align: center; } .profile-grayscale { filter: grayscale(100%) contrast(85%); opacity: .8; } `; const css_Whitemode_player = ` .remainingBuffer { overflow: visible; display: inline-block; position: relative; z-index: 1; margin-left: 15px; vertical-align: middle; } .remainingBuffer p{ font-size: 12px; color: #888888; vertical-align: middle; text-align: center; } .elapsed-time { overflow: visible; display: inline-block; position: relative; z-index: 1; margin-left: 15px; vertical-align: middle; } .elapsed-time p{ font-size: 13px; vertical-align: middle; text-align: center; } @media (max-width: 1320px) { .layout_v2#webplayer.chat_open #webplayer_contents, .layout_v2#webplayer.chat_open.list_open #webplayer_contents, .layout_v2#webplayer.chat_open.list_bookmark_open #webplayer_contents { min-width: 600px; } } @media screen and (max-width: 1120px) { .left_nav_button { display: none; } } #afSearcharea .search_window .searchInputWrap { border: 1px solid #E5E5E5 !important; } #webplayer_top { border-bottom: 1px solid #E5E5E5 !important; } #sidebar.max { width: 240px; } #sidebar.min { width: 52px; } #sidebar.min .users-section a.user span { display: none; } #sidebar.min .users-section button { font-size:11px; padding: 1px; } #sidebar.max .button-fold-sidebar { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none slice' viewBox='0 0 7 11'%3e%3cpath fill='%23888' d='M5.87 11.01L.01 5.51 5.87.01l1.08 1.01-4.74 4.45L7 9.96 5.87 11z'/%3e%3c/svg%3e"); background-size: 7px 11px; background-repeat: no-repeat; width: 26px; height: 26px; background-position: center; position: absolute; top: 13px; left: 200px; } #sidebar.max .button-unfold-sidebar { display:none; } #sidebar.min .button-fold-sidebar { display:none; } #sidebar.min .button-unfold-sidebar { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none slice' viewBox='0 0 7 11'%3e%3cpath fill='%23888' d='M1.13 11.01l5.86-5.5L1.13.01.05 1.02l4.74 4.45L0 9.96 1.13 11z'/%3e%3c/svg%3e"); background-size: 7px 11px; background-repeat: no-repeat; width: 26px; height: 26px; background-position: center; position: relative; top: 8px; left: 12px; padding-bottom:10px; } #sidebar.min .top-section span.max{ display:none; } #sidebar.max .top-section span.min{ display:none; } #afreecatv_player { width: 100%; } .smode #webplayer_scroll { top: 0; left:0; } #webplayer_scroll{ left: ${webplayer_scroll_left}px; } #sidebar { width: 240px; height:100vh; grid-area: sidebar; background-color: #EFEFF1; color:white; overflow-y: auto; position: fixed; top: 56px; scrollbar-width: none; /* 파이어폭스 */ } #sidebar > :last-child { padding-bottom: 360px; /* 마지막 자식에만 padding 추가 */ } #sidebar::-webkit-scrollbar { display: none; /* Chrome, Safari, Edge */ } #sidebar .top-section { display: flex; align-items: center; justify-content: space-around; margin: 12px 0px 6px 0px; } #sidebar .top-section>span { text-transform: uppercase; font-weight: 600; font-size: 14px; margin-top: 6px; margin-bottom: 2px; color:#0E0E10; } #sidebar .top-section>span>a { color:#0E0E10; } #sidebar .twitch-message-section { margin: 0px 10px; margin-top: 10px; padding: 0 25px; background-color: #EFEFF1; } #sidebar .twitch-message-section .title { margin: 0px; font-size: 1.5rem; font-weight: 500; } #sidebar .twitch-message-section .title>span { color: var(--primary-color); } #sidebar .twitch-message-section .description { margin: 8px 0px; line-height: 1.3rem; font-size: 0.9rem; color: #53535F; } #sidebar .twitch-message-section .description>span { display: block; text-align: center; } .users-section .user { display: grid; grid-template-areas: "profile-picture username watchers" "profile-picture description blank"; grid-template-columns: 40px auto auto; padding: 6px 10px; } .users-section .user:hover { background-color: #E6E6EA; cursor: pointer; } .users-section .user .profile-picture { grid-area: profile-picture; width: 32px; height: 32px; border-radius: 50%; } .users-section .user .username { grid-area: username; font-size: 14px; font-weight: 600; color:#1F1F23; letter-spacing: 0.6px; margin-left:1px; } .users-section .user .description { grid-area: description; font-size: 13px; font-weight: 400; color: #53535F; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left:1px; } .users-section .user .watchers { grid-area: watchers; display: flex; align-items: center; justify-content: flex-end; font-size: 14px; font-weight: 400; color: black; margin-right: 2px; } .users-section .user .watchers .dot { font-size: 7px; margin-right: 5px; } .tooltip-container { z-index: 999; width: 480px; height: auto; position: fixed; background-color: #E6E6EA; display: flex; border-radius: 10px; box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.5); } .tooltip-container img { position: relative; z-index: 999; width: auto; height: auto; max-width:480px; max-height:270px flex: 0; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; } .tooltiptext { flex: 0; position: relative; z-index: 999; width: 480px; max-width: 100%; /* 넘치는 경우 최대 너비 */ height: auto; background-color: #E6E6EA; color: black; text-align: center; align-items: center; /* 세로 가운데 정렬 */ justify-content: center; /* 가로 가운데 정렬 */ box-sizing: border-box; /* 패딩을 포함한 전체 너비 유지 */ padding: 8px 20px 14px 20px; font-size: 15px; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; } #webplayer_top .logo { top: 18px; left: 18px; } .left_navbar { display: flex; align-items: center; justify-content: flex-end; position: absolute; flex-direction: row-reverse; top: 0px; left: 140px; } .left_nav_button { position: relative; width: 70px; height: 56px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; z-index: 3001; transition: all .2s; color: #1F1F23; font-size: 15px; font-weight: 600; } .users-section.myplus > .user.show-more, .users-section.follow > .user.show-more, .users-section.top > .user.show-more, .users-section.myplusvod > .user.show-more { display: none; } #toggleButton, #toggleButton2, #toggleButton3, #toggleButton4 { padding:12px; color:#53535F; width: 100%; text-align: center; } .profile-grayscale { filter: grayscale(100%) contrast(85%); opacity: .8; } `; //======================================공용 함수======================================// function refreshPageOnDarkModeToggle() { var modecheck1 = document.getElementById("modecheck"); var modecheck2 = document.getElementById("modecheck2"); if (modecheck1 !== null) { modecheck1.addEventListener("change", function () { location.reload(); }); } if (modecheck2 !== null) { modecheck2.addEventListener("change", function () { location.reload(); }); } } function addNumberSeparator(number) { // toLocaleString 메서드를 사용하여 숫자에 구분자 추가 number = Number(number); return number.toLocaleString(); } function getCategoryName(targetCateNo) { function searchCategory(categories, targetCateNo) { // 카테고리 배열을 순회합니다. for (let category of categories) { // 현재 카테고리의 cate_no가 목표 cate_no와 일치하는지 확인합니다. if (category.cate_no === targetCateNo) { // 일치하는 경우 cate_name을 반환합니다. return category.cate_name; } else { // 현재 카테고리에 child가 있는지 확인합니다. if (category.child && category.child.length > 0) { // 재귀적으로 child 카테고리를 검색합니다. let result = searchCategory(category.child, targetCateNo); // 재귀 호출 결과가 null이 아니라면 해당 cate_name을 반환합니다. if (result !== null) { return result; } } } } // cate_no에 해당하는 카테고리가 없는 경우 null을 반환합니다. return null; } // 함수 호출 시 CHANNEL.BROAD_CATEGORY에서 시작합니다. return searchCategory(savedCategory.CHANNEL.BROAD_CATEGORY, targetCateNo); } // 차단 목록을 저장합니다. function saveBlockedUsers() { GM_setValue('blockedUsers', blockedUsers); } // 사용자를 차단 목록에 추가합니다. function blockUser(userName, userId) { // 이미 차단된 사용자인지 확인 if (!isUserBlocked(userId)) { blockedUsers.push({ userName, userId }); saveBlockedUsers(); alert(`사용자 ${userName}(${userId})를 차단했습니다.`); registerUnblockMenu({ userName, userId }); } else { alert(`사용자 ${userName}(${userId})는 이미 차단되어 있습니다.`); } } // 함수: 사용자 차단 해제 function unblockUser(userId) { // 차단된 사용자 목록에서 해당 사용자 찾기 let unblockedUser = blockedUsers.find(user => user.userId === userId); // 사용자를 찾았을 때만 차단 해제 및 메뉴 삭제 수행 if (unblockedUser) { // 차단된 사용자 목록에서 해당 사용자 제거 blockedUsers = blockedUsers.filter(user => user.userId !== userId); // 변경된 목록을 저장 GM_setValue('blockedUsers', blockedUsers); alert(`사용자 ${userId}의 차단이 해제되었습니다.`); unregisterUnblockMenu(unblockedUser.userName); } } // 사용자가 이미 차단되어 있는지 확인합니다. function isUserBlocked(userId) { return blockedUsers.some(user => user.userId === userId); } // 함수: 동적으로 메뉴 등록 function registerUnblockMenu(user) { // GM_registerMenuCommand로 메뉴를 등록하고 메뉴 ID를 기록 let menuId = GM_registerMenuCommand(`💔 차단 해제 - ${user.userName}`, function() { unblockUser(user.userId); }); // 메뉴 ID를 기록 menuIds[user.userName] = menuId; } // 함수: 동적으로 메뉴 삭제 function unregisterUnblockMenu(userName) { // userName을 기반으로 저장된 메뉴 ID를 가져와서 삭제 let menuId = menuIds[userName]; if (menuId) { GM_unregisterMenuCommand(menuId); delete menuIds[userName]; // 삭제된 메뉴 ID를 객체에서도 제거 } } // 카테고리 목록을 저장합니다. function saveBlockedCategories() { GM_setValue('blockedCategories', blockedCategories); } // 카테고리를 차단 목록에 추가합니다. function blockCategory(categoryName, categoryId) { // 이미 차단된 카테고리인지 확인 if (!isCategoryBlocked(categoryId)) { blockedCategories.push({ categoryName, categoryId }); saveBlockedCategories(); alert(`카테고리 ${categoryName}(${categoryId})를 차단했습니다.`); registerCategoryUnblockMenu({ categoryName, categoryId }); } else { alert(`카테고리 ${categoryName}(${categoryId})는 이미 차단되어 있습니다.`); } } // 함수: 카테고리 차단 해제 function unblockCategory(categoryId) { // 차단된 카테고리 목록에서 해당 카테고리 찾기 let unblockedCategory = blockedCategories.find(category => category.categoryId === categoryId); // 카테고리를 찾았을 때만 차단 해제 및 메뉴 삭제 수행 if (unblockedCategory) { // 차단된 카테고리 목록에서 해당 카테고리 제거 blockedCategories = blockedCategories.filter(category => category.categoryId !== categoryId); // 변경된 목록을 저장 GM_setValue('blockedCategories', blockedCategories); alert(`카테고리 ${categoryId}의 차단이 해제되었습니다.`); unregisterCategoryUnblockMenu(unblockedCategory.categoryName); } } // 카테고리가 이미 차단되어 있는지 확인합니다. function isCategoryBlocked(categoryId) { return blockedCategories.some(category => category.categoryId === categoryId); } // 함수: 동적으로 카테고리 메뉴 등록 function registerCategoryUnblockMenu(category) { // GM_registerMenuCommand로 카테고리 메뉴를 등록하고 메뉴 ID를 기록 let menuId = GM_registerMenuCommand(`💔 카테고리 차단 해제 - ${category.categoryName}`, function() { unblockCategory(category.categoryId); }); // 메뉴 ID를 기록 categoryMenuIds[category.categoryName] = menuId; } // 함수: 동적으로 카테고리 메뉴 삭제 function unregisterCategoryUnblockMenu(categoryName) { // categoryName을 기반으로 저장된 메뉴 ID를 가져와서 삭제 let menuId = categoryMenuIds[categoryName]; if (menuId) { GM_unregisterMenuCommand(menuId); delete categoryMenuIds[categoryName]; // 삭제된 메뉴 ID를 객체에서도 제거 } } function waitForElement(elementSelector, callBack, attempts = 0, maxAttempts = 100) { const element = document.querySelector(elementSelector); if (element) { callBack(elementSelector, element); } else { if (attempts < maxAttempts) { setTimeout(function () { waitForElement(elementSelector, callBack, attempts + 1, maxAttempts); }, 200); } else { console.error('Reached maximum attempts. Element not found.'); } } } function desc_order(selector) { // Get the container element const container = document.querySelector(selector); // Get all user elements const userElements = document.querySelectorAll(`${selector} > .user`); // Create arrays for each category let category1 = []; let category2 = []; let category3 = []; let category4 = []; let category5 = []; // Categorize users userElements.forEach(user => { const isPin = user.getAttribute('is_pin') === 'Y'; const hasBroadThumbnail = user.hasAttribute('broad_thumbnail'); const isMobilePush = user.getAttribute('is_mobile_push') === 'Y'; if (isPin && hasBroadThumbnail) { category1.push(user); } else if (isPin && !hasBroadThumbnail) { category2.push(user); } else if (!isPin && isMobilePush) { category3.push(user); } else if (!isPin && !isMobilePush) { category4.push(user); } else { category5.push(user); } }); // Sort each category by watchers category1.sort(compareWatchers); category2.sort(compareWatchers); category3.sort(compareWatchers); category4.sort(compareWatchers); category5.sort(compareWatchers); // Clear container and append sorted elements container.innerHTML = ''; [...category1, ...category2, ...category3, ...category4, ...category5].forEach(user => { container.appendChild(user); }); } function compareWatchers(a, b) { const watchersA = parseInt(a.getAttribute('data-watchers') || '0'); const watchersB = parseInt(b.getAttribute('data-watchers') || '0'); return watchersB - watchersA; // Sort by watchers } function makeTopNavbarAndSidebar(page){ // .left_navbar를 찾거나 생성 var leftNavbar = document.querySelector('.left_navbar'); if (!leftNavbar) { leftNavbar = document.createElement('div'); leftNavbar.className = 'left_navbar'; // 페이지의 적절한 위치에 추가 var targetElement = document.body; // 원하는 위치에 따라 수정 targetElement.insertBefore(leftNavbar, targetElement.firstChild); } var buttonData = [ { href: 'https://www.afreecatv.com/?hash=all', text: '전체' }, { href: 'https://www.afreecatv.com/?hash=game', text: '게임' }, { href: 'https://www.afreecatv.com/?hash=bora', text: '보.라' }, { href: 'https://www.afreecatv.com/?hash=sports', text: '스포츠' } ]; buttonData.reverse().forEach(function (data) { var newButton = document.createElement('a'); newButton.href = data.href; newButton.innerHTML = ``; leftNavbar.appendChild(newButton); }); var tooltipContainer = document.createElement('div'); tooltipContainer.classList.add('tooltip-container'); const sidebarClass = sidebarMinimized ? "min" : "max"; if(page==="main"){ const newHtml = `
`; const serviceLnbElement = document.getElementById('serviceLnb'); if (serviceLnbElement) { serviceLnbElement.insertAdjacentHTML('beforeend', newHtml); } var listsection = document.querySelector('#list-section'); listsection.appendChild(tooltipContainer); } if(page==="player"){ const sidebarHtml = ` `; const webplayerElement = document.getElementById('webplayer'); if (webplayerElement) { webplayerElement.insertAdjacentHTML('beforeend', sidebarHtml); } webplayerElement.appendChild(tooltipContainer); } } function updateElementWithContent(targetElement, newContent) { // DocumentFragment 생성 function createFragment(content) { var fragment = document.createDocumentFragment(); var tempDiv = document.createElement('div'); tempDiv.innerHTML = content; while (tempDiv.firstChild) { fragment.appendChild(tempDiv.firstChild); } return fragment; } // 기존 내용을 지우고 DocumentFragment를 적용 function applyFragment(fragment) { targetElement.innerHTML = ''; // 기존 내용을 모두 지움 targetElement.appendChild(fragment); // 새로운 내용 추가 } // 호출 시점에 전달된 newContent를 사용하여 DocumentFragment 생성 후 적용 applyFragment(createFragment(newContent)); } // 사용자 요소를 생성하는 함수 function createUserElement(channel, is_mobile_push, is_pin) { const userId = channel.user_id; const broadNo = channel.broad_no; const totalViewCnt = channel.total_view_cnt; const broadTitle = channel.broad_title; const userNick = channel.user_nick; const playerLink = "https://play.afreecatv.com/"+userId+"/"+broadNo; const broad_thumbnail = `https://liveimg.afreecatv.com/m/${broadNo}`; const userElement = document.createElement('a'); userElement.classList.add('user'); if(!open_newtab){ userElement.setAttribute('href',`${playerLink}`); } else { userElement.setAttribute('href',`${playerLink}`); userElement.setAttribute('target','_blank'); } userElement.setAttribute('data-watchers',`${totalViewCnt}`); userElement.setAttribute('broad_thumbnail',`${broad_thumbnail}`); userElement.setAttribute('tooltip',`${broadTitle}`); userElement.setAttribute('user_id',`${userId}`); if (is_mobile_push) { userElement.setAttribute('is_mobile_push', is_mobile_push); if (is_pin) { userElement.setAttribute('is_pin', 'Y'); } else { userElement.setAttribute('is_pin', 'N'); } } const profilePicture = document.createElement('img'); const pp_webp="https://stimg.afreecatv.com/LOGO/"+userId.slice(0, 2)+"/"+userId+"/m/"+userId+".webp"; const pp_jpg="https://profile.img.afreecatv.com/LOGO/"+userId.slice(0, 2)+"/"+userId+"/m/"+userId+".jpg"; profilePicture.src = pp_webp; profilePicture.setAttribute('onerror', `this.onerror=null; this.src='${pp_jpg}'`); profilePicture.setAttribute('alt', `${userId}'`); if (open_newtab === 1) { profilePicture.setAttribute('onclick', `event.preventDefault(); event.stopPropagation(); document.getElementById('sidebar').offsetWidth === 52 ? window.open('${playerLink}', '_blank') : window.open('https://bj.afreecatv.com/${userId}', '_blank');`); } else { profilePicture.setAttribute('onclick', `event.preventDefault(); event.stopPropagation(); document.getElementById('sidebar').offsetWidth === 52 ? location.href = '${playerLink}' : window.open('https://bj.afreecatv.com/${userId}', '_blank');`); } profilePicture.classList.add('profile-picture'); const username = document.createElement('span'); username.classList.add('username'); if(is_pin){ username.textContent = `🖈${userNick}`; username.setAttribute('title','고정됨(상단 고정 켜짐)'); } else if (is_mobile_push==="Y") { username.textContent = `🖈${userNick}`; username.setAttribute('title','고정됨(알림 받기 켜짐)'); } else { username.textContent = userNick; } const cat_no = channel.broad_cate_no; const description = document.createElement('span'); description.classList.add('description'); description.textContent = getCategoryName(cat_no); userElement.setAttribute('broad_cate_no',`${cat_no}`); const watchers = document.createElement('span'); watchers.classList.add('watchers'); watchers.innerHTML = `🔴${addNumberSeparator(totalViewCnt)}`; userElement.appendChild(profilePicture); userElement.appendChild(username); userElement.appendChild(description); userElement.appendChild(watchers); return userElement; } function createUserElement_vod(channel) { const userId = channel.user_id; const broadNo = channel.title_no; const totalViewCnt = channel.view_cnt; const broadTitle = channel.title; const userNick = channel.user_nick; const playerLink = "https://vod.afreecatv.com/player/"+broadNo; const broad_thumbnail = `${channel.thumbnail}`; const userElement = document.createElement('a'); userElement.classList.add('user'); if(!open_newtab){ userElement.setAttribute('href',`${playerLink}`); } else { userElement.setAttribute('href',`${playerLink}`); userElement.setAttribute('target','_blank'); } userElement.setAttribute('data-watchers',`${totalViewCnt}`); userElement.setAttribute('broad_thumbnail',`${broad_thumbnail}`); userElement.setAttribute('tooltip',`${broadTitle}`); userElement.setAttribute('user_id',`${userId}`); const profilePicture = document.createElement('img'); const pp_webp="https://stimg.afreecatv.com/LOGO/"+userId.slice(0, 2)+"/"+userId+"/m/"+userId+".webp"; const pp_jpg="https://profile.img.afreecatv.com/LOGO/"+userId.slice(0, 2)+"/"+userId+"/m/"+userId+".jpg"; profilePicture.src = pp_webp; profilePicture.setAttribute('onerror', `this.onerror=null; this.src='${pp_jpg}'`); profilePicture.setAttribute('alt', `${userId}'`); if (open_newtab === 1) { profilePicture.setAttribute('onclick', `event.preventDefault(); event.stopPropagation(); document.getElementById('sidebar').offsetWidth === 52 ? window.open('${playerLink}', '_blank') : window.open('https://bj.afreecatv.com/${userId}', '_blank');`); } else { profilePicture.setAttribute('onclick', `event.preventDefault(); event.stopPropagation(); document.getElementById('sidebar').offsetWidth === 52 ? location.href = '${playerLink}' : window.open('https://bj.afreecatv.com/${userId}', '_blank');`); } profilePicture.classList.add('profile-picture'); profilePicture.classList.add('profile-grayscale'); const username = document.createElement('span'); username.classList.add('username'); username.textContent = userNick; const reg_date = channel.reg_date; const description = document.createElement('span'); description.classList.add('description'); description.textContent = channel.vod_duration; const watchers = document.createElement('span'); watchers.classList.add('watchers'); watchers.innerHTML = timeSince(reg_date); userElement.appendChild(profilePicture); userElement.appendChild(username); userElement.appendChild(description); userElement.appendChild(watchers); return userElement; } function createUserElement_offline(channel) { const userId = channel.user_id; const totalViewCnt = channel.total_view_cnt; const userNick = channel.user_nick; const playerLink = "https://bj.afreecatv.com/"+userId; const is_mobile_push = channel.is_mobile_push; const is_pin = channel.is_pin; const userElement = document.createElement('a'); userElement.classList.add('user'); if(!open_newtab){ userElement.setAttribute('href',`${playerLink}`); } else { userElement.setAttribute('href',`${playerLink}`); userElement.setAttribute('target','_blank'); } userElement.setAttribute('data-tooltip-listener', 'false'); userElement.setAttribute('data-watchers',`${totalViewCnt}`); userElement.setAttribute('user_id',`${userId}`); if (is_mobile_push) { userElement.setAttribute('is_mobile_push', is_mobile_push); if (is_pin) { userElement.setAttribute('is_pin', 'Y'); } else { userElement.setAttribute('is_pin', 'N'); } } const profilePicture = document.createElement('img'); const pp_webp="https://stimg.afreecatv.com/LOGO/"+userId.slice(0, 2)+"/"+userId+"/m/"+userId+".webp"; const pp_jpg="https://profile.img.afreecatv.com/LOGO/"+userId.slice(0, 2)+"/"+userId+"/m/"+userId+".jpg"; profilePicture.src = pp_webp; profilePicture.setAttribute('onerror', `this.onerror=null; this.src='${pp_jpg}'`); profilePicture.setAttribute('alt', `${userId}'`); if (open_newtab === 1) { profilePicture.setAttribute('onclick', `event.preventDefault(); event.stopPropagation(); document.getElementById('sidebar').offsetWidth === 52 ? window.open('${playerLink}', '_blank') : window.open('https://bj.afreecatv.com/${userId}', '_blank');`); } else { profilePicture.setAttribute('onclick', `event.preventDefault(); event.stopPropagation(); document.getElementById('sidebar').offsetWidth === 52 ? location.href = '${playerLink}' : window.open('https://bj.afreecatv.com/${userId}', '_blank');`); } profilePicture.classList.add('profile-picture'); profilePicture.classList.add('profile-grayscale'); const username = document.createElement('span'); username.classList.add('username'); username.textContent = `🖈${userNick}`; username.setAttribute('title','고정됨(상단 고정 켜짐)'); const description = document.createElement('span'); description.classList.add('description'); description.textContent = ''; const watchers = document.createElement('span'); watchers.classList.add('watchers'); watchers.innerHTML = `🔴오프라인`; userElement.appendChild(profilePicture); userElement.appendChild(username); userElement.appendChild(description); userElement.appendChild(watchers); return userElement; } function timeSince(timestamp) { const currentTime = new Date(); const pastTime = new Date(timestamp.replace(/-/g, '/')); const seconds = Math.floor((currentTime - pastTime) / 1000); const minutes = Math.floor(seconds / 60); const hours = Math.floor(minutes / 60); const days = Math.floor(hours / 24); if (days > 365) { const years = Math.floor(days / 365); return years + "년 전"; } else if (days > 30) { const months = Math.floor(days / 30); return months + "개월 전"; } else if (days > 0) { return days + "일 전"; } else if (hours > 0) { return hours + "시간 전"; } else if (minutes > 0) { return minutes + "분 전"; } else { return seconds + "초 전"; } } function isUserInFollowSection(userid) { const followUsers = document.querySelectorAll('.users-section.follow .user'); // 유저가 포함되어 있는지 확인 for (const user of followUsers) { if (user.getAttribute('user_id') === userid) { return true; // 유저가 포함되어 있으면 true를 리턴 } } return false; // 유저가 포함되어 있지 않으면 false를 리턴 } function insertFoldButton() { const foldButton = ` `; const newHtml = `${foldButton}`; const webplayer_scroll = document.getElementById('webplayer_scroll') || document.getElementById('list-container'); const serviceLnbElement = document.getElementById('sidebar'); if (serviceLnbElement) { serviceLnbElement.insertAdjacentHTML('beforeend', newHtml); // 버튼 요소 가져오기 const buttons = serviceLnbElement.querySelectorAll('.button-fold-sidebar, .button-unfold-sidebar'); buttons.forEach(function(button) { // 버튼에 클릭 이벤트 리스너 추가 button.addEventListener('click', function () { // sidebar 상태 변경 sidebarMinimized = !sidebarMinimized; // max 클래스가 있으면 제거하고 min 클래스 추가 if (serviceLnbElement.classList.contains('max')) { serviceLnbElement.classList.remove('max'); serviceLnbElement.classList.add('min'); webplayer_scroll.style.left = '52px'; } // min 클래스가 있으면 제거하고 min 클래스 추가 else if (serviceLnbElement.classList.contains('min')) { serviceLnbElement.classList.remove('min'); serviceLnbElement.classList.add('max'); webplayer_scroll.style.left = '240px'; } // sidebarMinimized 값을 저장 GM_setValue("sidebarMinimized", sidebarMinimized ? 1 : 0); }); }); } } function insertTopChannels(update){ let topIcon = `${formattedTime}
`; } setInterval(updateElapsedTime, 1000); } function insertRemainingBuffer(element){ const video = element; function getRemainingBufferTime(){ const buffered = video.buffered; if (buffered.length > 0) { let remainingBufferTime = buffered.end(buffered.length - 1) - video.currentTime; remainingBufferTime = remainingBufferTime.toFixed(1); remainingBufferTime = parseFloat(remainingBufferTime); remainingBufferTime = remainingBufferTime % 1 === 0 ? remainingBufferTime.toFixed(1) : remainingBufferTime; return remainingBufferTime; } } // video의 onprogress 이벤트 핸들러 video.onprogress = function() { // 남은 버퍼 시간 가져오기 let remainingBufferTime = getRemainingBufferTime(); // 요소 찾기 const existingRemainingBuffer = document.querySelector('.remainingBuffer'); // 형제 요소로 삽입할 HTML 생성 const remainingBufferHTML = `${remainingBufferTime}s
${remainingBufferTime}s
`; } else { // 요소 찾기 const elapsedTimeDiv = document.querySelector('#player_area > div.broadcast_information > div.text_information > div.elapsed-time'); const viewerCntDiv = document.querySelector('#player_area > div.broadcast_information > div.text_information > div.broadcast_viewer_cnt'); // elapsedTimeDiv가 존재하는 경우 if (elapsedTimeDiv) { // 형제 요소로 삽입 elapsedTimeDiv.insertAdjacentHTML('afterend', remainingBufferHTML); } else if (viewerCntDiv) { // viewerCntDiv가 존재하는 경우 // 형제 요소로 삽입 viewerCntDiv.insertAdjacentHTML('afterend', remainingBufferHTML); } } }; } // 타이머 식별자를 함수 외부에서 선언합니다. var timerId_m; function handleMuteByVisibility() { const button = document.querySelector("#btn_sound"); if (document.hidden) { // 탭이 비활성화됨 timerId_m = setTimeout(function(){ if (!button.classList.contains("mute")) { button.click(); console.log("탭이 비활성화됨, 음소거"); } },1000); } else { // 탭이 활성화됨 if (typeof timerId_m !== 'undefined') { clearTimeout(timerId_m); } if (button.classList.contains("mute")) { button.click(); console.log("탭이 활성화됨, 음소거 해제"); } } } // 타이머 식별자를 함수 외부에서 선언합니다. var timerId_q; function handleChangeQualityByVisibility() { const qualityButtons = document.querySelectorAll("#afreecatv_player > div.player_ctrlBox > div.right_ctrl > div.quality_box > ul > li:not([style='display: none;']) > button"); if (document.hidden) { // 탭이 비활성화됨 // setTimeout 함수를 호출하고 타이머 식별자를 변수에 저장합니다. timerId_q = setTimeout(function(){ const lastButtonIndex = qualityButtons.length - 1; const lastButton = qualityButtons[lastButtonIndex]; lastButton.click(); console.log(`탭이 비활성화됨, ${lastButton.textContent}`); }, 1000); } else { // 탭이 활성화됨 if (typeof timerId_q !== 'undefined') { clearTimeout(timerId_q); } qualityButtons[1].click(); console.log(`탭이 활성화됨, ${qualityButtons[1].textContent}`); } } function isVideoInPiPMode() { // 현재 비디오 요소 가져오기 var videoElement = document.querySelector('video'); // 비디오 요소가 존재하고, PiP 모드인지 확인 if (videoElement !== null && document.pictureInPictureElement === videoElement) { return true; } else { return false; } } function registerVisibilityChangeHandler() { document.addEventListener('visibilitychange', () => { if(!isVideoInPiPMode()){ if(autoChangeMute) handleMuteByVisibility(); if(autoChangeQuality) handleChangeQualityByVisibility(); } }, true); } function useBottomChat(){ // 미디어 쿼리를 추가할 때 사용할 스타일 시트입니다. var customStyleSheet = document.createElement('style'); customStyleSheet.setAttribute('id', 'custom-style-sheet'); // 미디어 쿼리에 대한 CSS를 설정합니다. var customCSS = ` .smode #player_area.bottomChat{ left: 0px !important; right: 0px !important; width: 100vw; height: calc((100vw / 16 * 9) + 64px) !important; } .smode #chatting_area.bottomChat { top: calc((100vw / 16 * 9) + 70px) !important; left: 0px !important; width: 100vw !important; height: auto; display: block !important; } .smode #webplayer[chat-move=true].chat_open #webplayer_contents #chatting_area.bottomChat{ top: calc((100vw / 16 * 9) + 70px) !important; left: 0px !important; width: 100vw !important; height: auto; display: block !important; } `; // 스타일 시트에 CSS를 추가합니다. customStyleSheet.innerHTML = customCSS; // 스타일 시트를 문서 헤드에 추가합니다. document.head.appendChild(customStyleSheet); // 해상도에 따라 bottomChat 클래스를 추가하거나 제거하는 함수 function toggleBottomChat() { var screenHeight = window.innerHeight; var screenWidth = window.innerWidth; // screenHeight가 1024 이상이고 screenWidth가 1320 이상일 때 bottomChat 클래스를 추가합니다. // 그렇지 않으면 bottomChat 클래스를 제거합니다. var playerArea = document.getElementById('player_area'); var chattingArea = document.getElementById('chatting_area'); if (screenHeight >= 1080 && screenWidth <= 1320) { playerArea.classList.add('bottomChat'); chattingArea.classList.add('bottomChat'); } else { playerArea.classList.remove('bottomChat'); chattingArea.classList.remove('bottomChat'); } } // 윈도우 리사이즈 이벤트를 감지하여 toggleBottomChat 함수를 호출합니다. window.addEventListener('resize', toggleBottomChat); // 페이지 로드 시 한 번 실행하여 초기 설정을 수행합니다. toggleBottomChat(); } //=================================플레이어 페이지 함수 끝 ===================================// //============================ 메인 페이지 실행 ============================// if (currentUrl.startsWith("https://www.afreecatv.com")) { if(isDarkMode){ GM_addStyle(css_Darkmode); } else { GM_addStyle(css_Whitemode); } makeTopNavbarAndSidebar("main"); waitForElement('.left_nav_button', function (elementSelector, element) { // Get the current page URL const currentPage = window.location.href; // Get all navigation links const navLinks = document.querySelectorAll('.left_nav_button'); // Loop through each link and check if it matches the current page navLinks.forEach(link => { var parentLink = link.parentElement; if (parentLink.href === currentPage) { link.classList.add('active'); // Add the 'active' class if it matches } }); }); blockButtonOnMutation(); setCategoryOnAjaxResponse(); document.getElementById('serviceLnb').classList.remove('mini'); if (currentUrl === "https://www.afreecatv.com/?hash=bora" || currentUrl === "https://www.afreecatv.com/?hash=game" || currentUrl === "https://www.afreecatv.com/?hash=sports") { waitForElement('button.refresh.loaded', function (elementSelector, element) { setTimeout(function () { var refreshButton = document.getElementById('btnRefresh'); refreshButton.click(); }, 1000); }); } } //============================ 플레이어 페이지 실행 ============================// if (currentUrl.includes("play.afreecatv.com")) { //embed 페이지에서는 실행하지 않음 var pattern = /^https:\/\/play.afreecatv.com\/.*\/.*\/embed(\?.*)?$/; if (pattern.test(currentUrl) || currentUrl.includes("vtype=chat")) { return; } detectSmode(); detectFullscreenmode(); appendPauseButton(); if(isDarkMode){ GM_addStyle(css_Darkmode_player); } else { GM_addStyle(css_Whitemode_player); } if(bottomChatSwitch) useBottomChat(); makeTopNavbarAndSidebar("player"); insertFoldButton(); toggleSharpModeShortcut(); toggleLowLatencyShortcut(); if(smodeSidebar) showSidebarOnMouseOver(); checkPlayerPageHeaderAd(); if(showUptime){ broadcastTimeElapsed(); } if(showRemainingBuffer){ waitForElement('#livePlayer', function (elementSelector, element) { insertRemainingBuffer(element); }); } registerVisibilityChangeHandler(); // #webplayer_top > h1 > a 요소 가져오기 var linkElement = document.querySelector("#webplayer_top > h1 > a"); // 만약 요소가 존재하고 target 속성이 있다면 제거 if (linkElement && linkElement.hasAttribute("target")) { linkElement.removeAttribute("target"); } } //============================ 공용 실행 ============================// blockedUsers.forEach(function(user) { registerUnblockMenu(user); }); blockedCategories.forEach(function(category) { registerCategoryUnblockMenu(category); }); refreshPageOnDarkModeToggle(); removeStudioButton(); generateBroadcastElements(0); setInterval(function() { generateBroadcastElements(1); }, 60*1000); GM_addStyle(commonCss); addModalSettings(); })();