강좌 / 팁

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

2023.12.03 20:59

천경지위 조회:7991 추천: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 - - -
382 기 타| WindowsXPE147 수정버전 사용법 입니다... [27] 노랑개굴 1902 49 03-11
381 기 타| [오토핫키 v1] 경로, 이름 ,드라이브명 등등 추출 함수 [2] 청락은복 869 8 03-06
380 기 타| 컴퓨터 구매의 질문이 종종 보여서 나름의 팁을 얘기 합니다. [8] Boss 1941 6 02-19
379 기 타| 한 드라이브에 윈도우(Atlas OS)까지 2개 설치하는 법(?) (... 누군가 1153 0 02-04
378 기 타| 2024 새로운 시작, Rainmeter, 위젯, 바탕화면, 퍼포먼스 [16] 모네곰 2601 38 02-01
377 기 타| 파워쉘로 WOL 수행 [3] JR.오펜하이 1467 9 01-06
376 기 타| 크롬, 파이어폭스 사용자를 위한 웹 자막은 이런것 모네곰 1392 1 12-31
375 기 타| 모든 영상을 순간으로 MP4 확장자로 변환. [18] 모네곰 2433 28 12-30
374 기 타| WSA + ReVanced Extended 조합 체리마키아 1958 13 12-09
373 기 타| 희안한 유튭광고 제거 경험 공유 [3] 트레져sn 3976 6 12-09
» 기 타| [팁] 유튜브 광고 차단 [14] 천경지위 7991 28 12-03
371 기 타| 짜증나는 유튭 광고 개인설정과 구글설정 [10] 트레져sn 4061 15 11-27
370 기 타| macOS 소노마 14.1.1 다운로드 및 부팅 ISO 제작 후 VMWare... [8] 무월 1818 16 11-22
369 기 타| VMWare Workstation@Hybrid CPU 성능 문제 해결책 [3] DarknessAn 997 6 11-20
368 기 타| 포토샵 많이 좋아졌네요!! [3] 집에서뒹굴 2750 5 08-02
367 기 타| 배치 파일 %~1 [13] bangul 1614 14 07-02
366 기 타| 레마클로님 wifi on/off 스크립트 (수정) pnputil 추가 [10] 슈머슈마 889 7 06-20
365 기 타| Windows 10 pe 디스플레이 레지스트리 [4] bangul 1529 16 06-13
364 기 타| 특정 폴더 파일 확장자 폴더 별로 정리 [4] 슈머슈마 1363 9 05-29
363 기 타| pe의 Registry.cmd 파일 수정 [1] bangul 596 8 05-28
XE1.11.6 Layout1.4.8