강좌 / 팁

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

2023.12.03 20:59

천경지위 조회:7989 추천: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 기 타| 구글 드라이브 다운로드 초과했을 때 다운로드 방법 [41] suk 26731 49 11-19
381 기 타| WindowsXPE147 수정버전 사용법 입니다... [27] 노랑개굴 1900 49 03-11
380 기 타| 그 동안 본인이 업로드한 강좌를 보내드립니다. [181] 고양이2 12717 45 11-06
379 기 타| 2024 새로운 시작, Rainmeter, 위젯, 바탕화면, 퍼포먼스 [16] 모네곰 2591 38 02-01
378 기 타| RSImageX 기본 파일 구성 [19] suk 2641 33 02-14
377 기 타| BCD편집으로 USB에 PE 2개 넣기 [41] lakeside 7155 32 05-22
» 기 타| [팁] 유튜브 광고 차단 [14] 천경지위 7989 28 12-03
375 기 타| 모든 영상을 순간으로 MP4 확장자로 변환. [18] 모네곰 2428 28 12-30
374 기 타| [팁] PE에서 wim 부팅하는데 필요한 boot.sdi [12] suk 3763 27 04-24
373 기 타| 바로 가기 만들기 [7] bangul 2270 23 04-22
372 기 타| USB 디스크 인식 오류시 복구 방법 [18] gooddew 4172 22 08-17
371 기 타| CMD BAT 를 UTF8 모드로 사용 [13] 입니다 1661 22 01-16
370 기 타| 단위를 올바로 씁시다 [18] asklee 9202 21 10-20
369 기 타| 애드가드(Adguard) 다음카카오TV 재생불가 필터 추가하세요. [24] 절제자 4709 20 01-04
368 기 타| 우리집 와이파이 비밀번호 초간단 확인하기 [7] gooddew 5693 20 08-22
367 기 타| Dubox Cloud 스토리지에서 1TB를 무료로 제공합니다. [30] VenusGirl 3876 20 07-01
366 기 타| bat로 포터블 만들기 간단 팁 [9] 슈머슈마 2714 20 11-12
365 기 타| [정보] 윈도우10 쓰는 사람 필독 [10] ♣OSISO™ 8833 19 01-25
364 기 타| GRUB 부팅 USB 만들기. 쉽게 써보려고 노력...; [35] 서기다 8364 18 03-08
363 기 타| 자신의 음악성향에 맞게 EQ(이퀼라이저) 설정하기 [10] UCLA 5668 18 12-02
XE1.11.6 Layout1.4.8