강좌 / 팁

기 타 [팁] 유튜브 광고 차단

2023.12.03 20:59

천경지위 조회:7982 추천:28

 

Youtube 광고가 미쳤는지 좀 긴 영상보다보면 10분마다 한번씩 뜨는 경우가 있더군요.. 

30분에 한번씩 뜰때까지만 해도 그냥 광고 보이면 5초뒤에 건너띄기 눌러서 보고 그랬었는데 ... 

10분만다 뜨니 짜증이 나더군요...   어쩔수 없이 광고 건너띄는 방법을 찾아 봅니다. 

 

 

아래 소스를 즐겨찾기에 넣어두시고 유튜브 들어가서 한번씩 눌러주면 됩니다.   주소창에 복사해서 붙여넣고 맨앞에 javascript:를 넣은후 즐겨찾기로 끌어 오시면 즐겨찾기 추가한후 알아보기 쉽게 이름 바꿔주면 유튜브 접속후 해당 즐겨찾기를 한번 눌러주면 됩니다.      

혹은 유튜브 접속후 F12 눌러 콘솔탭에서 해당 소스를 붙여놓고 실행시키는 방법도 있습니다.

 

 

(function()

 {

    const adblocker = true;

    const removePopup = true;

    const debug = true;

 

    const domainsToRemove = [

        '*.youtube-nocookie.com/*'

    ];

    const jsonPathsToRemove = [

        'playerResponse.adPlacements',

        'playerResponse.playerAds',

        'adPlacements',

        'playerAds',

        'playerConfig',

        'auxiliaryUi.messageRenderers.enforcementMessageViewModel'

    ];

 

    const observerConfig = {

        childList: true,

        subtree: true

    };

 

    const keyEvent = new KeyboardEvent("keydown", {

      key: "k",

      code: "KeyK",

      keyCode: 75,

      which: 75,

      bubbles: true,

      cancelable: true,

      view: window

    });

 

    let mouseEvent = new MouseEvent("click", {

      bubbles: true,

      cancelable: true,

      view: window,

    });

 

    let unpausedAfterSkip = 0;

 

    if (debug) console.log("Remove Adblock Thing: Remove Adblock Thing: Script started");

    window.__ytplayer_adblockDetected = false;

 

    if(adblocker) addblocker();

    if(removePopup) popupRemover();

    if(removePopup) observer.observe(document.body, observerConfig);

 

    function popupRemover() {

        removeJsonPaths(domainsToRemove, jsonPathsToRemove);

        setInterval(() => {

 

            const fullScreenButton = document.querySelector(".ytp-fullscreen-button");

            const modalOverlay = document.querySelector("tp-yt-iron-overlay-backdrop");

            const popup = document.querySelector(".style-scope ytd-enforcement-message-view-model");

            const popupButton = document.getElementById("dismiss-button");

 

            const video1 = document.querySelector("#movie_player > video.html5-main-video");

            const video2 = document.querySelector("#movie_player > .html5-video-container > video");

 

            const bodyStyle = document.body.style;

 

            bodyStyle.setProperty('overflow-y', 'auto', 'important');

 

            if (modalOverlay) {

                modalOverlay.removeAttribute("opened");

                modalOverlay.remove();

            }

 

            if (popup) {

                if (debug) console.log("Remove Adblock Thing: Popup detected, removing...");

 

                if(popupButton) popupButton.click();

                popup.remove();

                unpausedAfterSkip = 2;

 

                fullScreenButton.dispatchEvent(mouseEvent);

              

                setTimeout(() => {

                  fullScreenButton.dispatchEvent(mouseEvent);

                }, 500);

 

                if (debug) console.log("Remove Adblock Thing: Popup removed");

            }

 

            if (!unpausedAfterSkip > 0) return;

 

            unPauseVideo(video1);

            unPauseVideo(video2);

 

        }, 1000);

    }

 

    function addblocker()

    {

        setInterval(() =>

                    {

            const skipBtn = document.querySelector('.videoAdUiSkipButton,.ytp-ad-skip-button');

            const ad = [...document.querySelectorAll('.ad-showing')][0];

            const sidAd = document.querySelector('ytd-action-companion-ad-renderer');

            const displayAd = document.querySelector('div#root.style-scope.ytd-display-ad-renderer.yt-simple-endpoint');

            const sparklesContainer = document.querySelector('div#sparkles-container.style-scope.ytd-promoted-sparkles-web-renderer');

            const mainContainer = document.querySelector('div#main-container.style-scope.ytd-promoted-video-renderer');

            const feedAd = document.querySelector('ytd-in-feed-ad-layout-renderer');

            const mastheadAd = document.querySelector('.ytd-video-masthead-ad-v3-renderer');

            const sponsor = document.querySelectorAll("div#player-ads.style-scope.ytd-watch-flexy, div#panels.style-scope.ytd-watch-flexy");

            const nonVid = document.querySelector(".ytp-ad-skip-button-modern");

 

            if (ad)

            {

                const video = document.querySelector('video');

                video.playbackRate = 10;

                video.volume = 0;

                video.currentTime = video.duration;

                skipBtn?.click();

            }

 

            sidAd?.remove();

            displayAd?.remove();

            sparklesContainer?.remove();

            mainContainer?.remove();

            feedAd?.remove();

            mastheadAd?.remove();

            sponsor?.forEach((element) => {

                 if (element.getAttribute("id") === "panels") {

                    element.childNodes?.forEach((childElement) => {

                      if (childElement.data.targetId && childElement.data.targetId !=="engagement-panel-macro-markers-description-chapters")

                            childElement.remove();

                          });

                       } else {

                           element.remove();

                       }

             });

            nonVid?.click();

        }, 50)

    }

 

    function unPauseVideo(video)

    {

        if (!video) return;

        if (video.paused) {

 

            document.dispatchEvent(keyEvent);

            unpausedAfterSkip = 0;

            if (debug) console.log("Remove Adblock Thing: Unpaused video using 'k' key");

        } else if (unpausedAfterSkip > 0) unpausedAfterSkip--;

    }

    function removeJsonPaths(domains, jsonPaths)

    {

        const currentDomain = window.location.hostname;

        if (!domains.includes(currentDomain)) return;

 

        jsonPaths.forEach(jsonPath => {

            const pathParts = jsonPath.split('.');

            let obj = window;

            let previousObj = null;

            let partToSetUndefined = null;

        

            for (const part of pathParts) {

                if (obj.hasOwnProperty(part)) {

                    previousObj = obj;

                    partToSetUndefined = part;

                    obj = obj[part];

                } else {

                    break;

                }

            }

        

            if (previousObj && partToSetUndefined !== null) {

                previousObj[partToSetUndefined] = undefined;

            }

        });

    }

 

    const observer = new MutationObserver(() =>

    {

        removeJsonPaths(domainsToRemove, jsonPathsToRemove);

    });

})();

 

 

위 소스는 해외유저가 github에 공개된 소스 입니다.

https://github.com/TheRealJoelmatic/RemoveAdblockThing/releases

 

매번 유튜브 들어가서 한번씩 눌러주는게 귀찮다면

Run Javascript 같은 별도의 확장 프로그램 이나 Tampermonkey 같은 확장프로그램을 이용하시는 방법도 있습니다.

 

번호 제목 글쓴이 조회 추천 등록일
[공지] 강좌 작성간 참고해주세요 gooddew - - -
4440 기 타| 컴퓨터 구매의 질문이 종종 보여서 나름의 팁을 얘기 합니다. [8] Boss 1941 6 02-19
4439 윈 도 우| 이 번 업데이트로 엣지에 추가된 사이드바 버튼 제거 [7] 고고추 2172 9 02-16
4438 윈 도 우| cmd 관리자 권한 실행과 특수문자 경로 문제 [9] 메리아 1100 12 02-14
4437 윈 도 우| 측면 버튼에 등록된 돋보기 기능... 기본값으로 복원 [2] 사가르마타 1058 0 02-10
4436 윈 도 우| 윈11 탐색기 메뉴삭제 [5] 진실 2430 19 02-06
4435 윈 도 우| 윈도우 탐색기 갤러리 안보이게 하는 방법 [1] 사가르마타 1586 2 02-05
4434 기 타| 한 드라이브에 윈도우(Atlas OS)까지 2개 설치하는 법(?) (... 누군가 1152 0 02-04
4433 기 타| 2024 새로운 시작, Rainmeter, 위젯, 바탕화면, 퍼포먼스 [16] 모네곰 2587 38 02-01
4432 윈 도 우| 윈도우10~11 알고리즘에 영향을 끼치는 이미지 파일 삭제 ... [2] risystem 2312 4 01-23
4431 윈 도 우| Windows11 트레이 아이콘 내맘대로... [9] 메인보드 3859 15 01-07
4430 기 타| 파워쉘로 WOL 수행 [3] JR.오펜하이 1467 9 01-06
4429 윈 도 우| 무인응답파일(autounattend.xml) 쉽게 만들기 [30] 네오이즘 3851 60 12-31
4428 기 타| 크롬, 파이어폭스 사용자를 위한 웹 자막은 이런것 모네곰 1392 1 12-31
4427 윈 도 우| Windows 11 설치 할 때 MS계정 로그인 스킵 [13] Corns7 3794 10 12-30
4426 기 타| 모든 영상을 순간으로 MP4 확장자로 변환. [18] 모네곰 2427 28 12-30
4425 소프트웨어| PE 환경에서 AOMEI Backupper 구동을 위한 파일, 레지스트... [11] 무월 1300 22 12-27
4424 소프트웨어| pureBasic - WIM 정보 v0993 - 내부 파일 추가 삭제 내보내... [40] 입니다 8656 160 12-22
4423 소프트웨어| pureBasic - IXMLDOMDocument [6] 입니다 1307 27 12-16
4422 기 타| WSA + ReVanced Extended 조합 체리마키아 1956 13 12-09
4421 기 타| 희안한 유튭광고 제거 경험 공유 [3] 트레져sn 3971 6 12-09
XE1.11.6 Layout1.4.8