강좌 / 팁

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

2023.12.03 20:59

천경지위 조회:8020 추천: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 - - -
4430 기 타| 파워쉘로 WOL 수행 [3] JR.오펜하이 1473 9 01-06
4429 윈 도 우| 무인응답파일(autounattend.xml) 쉽게 만들기 [30] 네오이즘 3902 62 12-31
4428 기 타| 크롬, 파이어폭스 사용자를 위한 웹 자막은 이런것 모네곰 1393 1 12-31
4427 윈 도 우| Windows 11 설치 할 때 MS계정 로그인 스킵 [13] Corns7 3842 10 12-30
4426 기 타| 모든 영상을 순간으로 MP4 확장자로 변환. [18] 모네곰 2467 28 12-30
4425 소프트웨어| PE 환경에서 AOMEI Backupper 구동을 위한 파일, 레지스트... [11] 무월 1302 22 12-27
4424 소프트웨어| pureBasic - WIM 정보 v0993 - 내부 파일 추가 삭제 내보내... [40] 입니다 8716 160 12-22
4423 소프트웨어| pureBasic - IXMLDOMDocument [6] 입니다 1311 27 12-16
4422 기 타| WSA + ReVanced Extended 조합 체리마키아 1961 13 12-09
4421 기 타| 희안한 유튭광고 제거 경험 공유 [3] 트레져sn 3989 6 12-09
4420 소프트웨어| pureBasic - FMIFS FormatEX 0.1.2 [6] 입니다 991 24 12-08
» 기 타| [팁] 유튜브 광고 차단 [14] 천경지위 8020 28 12-03
4418 윈 도 우| sources 폴더 교체시 드라이버 로드 오류 참고 [14] 무월 1375 31 12-02
4417 소프트웨어| pureBasic 소스 - 실행 목록 및 화면 캡처 v0.2 [7] 입니다 977 29 12-01
4416 기 타| 짜증나는 유튭 광고 개인설정과 구글설정 [10] 트레져sn 4068 15 11-27
4415 소프트웨어| 한글2024 로고 교체 / 자동 설치 옵션 [54] 무월 13257 107 11-25
4414 소프트웨어| pureBasic 소스 - 전원 단추. PB 6.10 지원 [12] 입니다 1247 34 11-24
4413 소프트웨어| PCem Win98 인터넷 개통하기. [6] 메인보드 1361 6 11-23
4412 기 타| macOS 소노마 14.1.1 다운로드 및 부팅 ISO 제작 후 VMWare... [8] 무월 1830 16 11-22
4411 소프트웨어| 오토잇 시스템 종료&재부팅 소스 [15] 무월 1599 27 11-21
XE1.11.6 Layout1.4.8