유튜브 광고가 심해졌더군요... 긴 영상 하나 보려고 했더니 무슨 광고가 10분에 몇개씩 뜨면서 영상에 집중을 못하게 만들더군요.. 예전엔 30분정도에 한번씩 떴던것 같은데.. ㅡ.ㅡ;; 짧은 영상볼때도 광고를 몇개씩 띄우며 귀찮게 해서 무슨 광고가 방송보는만큼 뜨는 느낌입니다.
이 방법 저 방법 찾다가 github 에 어떤분이 광고를 제거할수 있는 Javascript 를 공개 해주셨네요...
Releases · TheRealJoelmatic/RemoveAdblockThing (github.com)
위링크를 방문하셔서 Youtube-Ad-blocker-Reminder-Remover.user.js 파일을 다운받아서 이용하시면 됩니다.
(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);
});
})();(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);
});
})();
유튜브 접속후 F12 눌러서 콘솔탭에 위 소스를 복사해서 붙여넣고 실행하면 유튜브 광고가 안뜨는걸 확인할수 있었습니다.
혹은 맨앞에 javascript: 를 넣어 주소창에 붙여넣고 즐겨찾기로 끌어와 유튜브 접속후 해당 버튼을 누르는 방법도 있습니다.
이를 Chrome 확장 프로그램에서 Run Javascript 같은 확장 프로그램을 설치후 해당 javascript 내용을 지정된 사이트를 방문하실때만다 자동으로 해당 스크립트를 실행해주는 확장프로그램을 사용하시면 됩니다. 마찬가지로 tampermonkey 확장프로그램 등을 설치하셔서 적용시키는 방법등이 있습니다.
github에 공개된 팁이 얼마나 오래 갈수 있을지는 모르겠으나 그전까지는 이용하실수 있을듯 합니다.
일반적인 광고 차단방식하고는 전혀 다른 방식으로 광고사이트 접속을 차단하는 방식이 아닌 광고를 불러오는 Script 실행을 방해하는 방식입니다.
그냥 광고 보면서 유튜브 보던 스타일이었는데 10분마나 뜨는건 선을 넘었다고 봐야죠... 유튜브 영상 제작자 한테 별도로 제작비를 지원해주는것도 아니고, 광고료도 여러번 뜬다고 여러번 다 지불하는것도 아니고 처음 1회만 지불하고 이후는 영상 제작자하고는 상관도 없고... 너무하다 싶은 느낌입니다.
추가 - Youtube 광고 시스템이 업데이트 되면서 스크립트 소스도 업데이트 되었는데 일반적으로 나오는 배너광고는 제거하지 않고 동영상 광고 부분만 제거하는것으로 패치된것 같습니다. 기존 소스와 새로운 소스 장/단점이 있는듯 하므로 취향에 따라 선택 하시면 될듯 합니다.
(function()
{
const adblocker = true;
const removePopup = false;
const updateCheck = true;
const debugMessages = 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;
let currentUrl = window.location.href;
let hasIgnoredUpdate = false;
if (debugMessages) console.log("Remove Adblock Thing: Script started ");
if (adblocker) removeAds();
if (removePopup) popupRemover();
if (updateCheck) checkForUpdate();
function popupRemover() {
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 (debugMessages) 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 (debugMessages) console.log("Remove Adblock Thing: Popup removed");
}
if (!unpausedAfterSkip > 0) return;
unPauseVideo(video1);
unPauseVideo(video2);
}, 1000);
}
function removeAds()
{
if (debugMessages) console.log("Remove Adblock Thing: removeAds()");
setInterval(() =>{
const ad = [...document.querySelectorAll('.ad-showing')][0];
if (window.location.href !== currentUrl) {
currentUrl = window.location.href;
removePageAds();
}
var video = document.querySelector('video');
var videoPlayback = video.playbackRate
if (ad)
{
if (debugMessages) console.log("Remove Adblock Thing: Found Ad");
const skipBtn = document.querySelector('.videoAdUiSkipButton,.ytp-ad-skip-button');
const nonVid = document.querySelector(".ytp-ad-skip-button-modern");
const openAdCenterButton = document.querySelector('.ytp-ad-button-icon');
const blockAdButton = document.querySelector('[label="Block ad"]');
const blockAdButtonConfirm = document.querySelector('.Eddif [label="CONTINUE"] button');
const closeAdCenterButton = document.querySelector('.zBmRhe-Bz112c');
const hidebackdrop = document.querySelector("body > tp-yt-iron-overlay-backdrop");
if (video) video.playbackRate = 10;
if (video) video.volume = 0;
if (video) video.currentTime = video.duration || 0;
if (video) skipBtn?.click();
if (video) nonVid?.click();
openAdCenterButton?.click();
var popupContainer = document.querySelector('body > ytd-app > ytd-popup-container > tp-yt-paper-dialog');
if (popupContainer) {
popupContainer.style.display = 'none';
hidebackdrop.style.display = 'none';
}
blockAdButton?.click();
blockAdButtonConfirm?.click();
closeAdCenterButton?.click();
if (popupContainer) popupContainer.style.display = "block";
if (debugMessages) console.log("Remove Adblock Thing: skipped Ad (✔️)");
} else {
if(video.playbackRate == 10){
video.playbackRate = videoPlayback
}
}
}, 50)
removePageAds();
}
function removePageAds(){
const sponsor = document.querySelectorAll("div#player-ads.style-scope.ytd-watch-flexy, div#panels.style-scope.ytd-watch-flexy");
const style = document.createElement('style');
style.textContent = `
ytd-action-companion-ad-renderer,
div#root.style-scope.ytd-display-ad-renderer.yt-simple-endpoint,
div#sparkles-container.style-scope.ytd-promoted-sparkles-web-renderer,
div#main-container.style-scope.ytd-promoted-video-renderer,
ytd-in-feed-ad-layout-renderer,
.ytd-video-masthead-ad-v3-renderer,
div#player-ads.style-scope.ytd-watch-flexy,
yt-about-this-ad-renderer,
yt-mealbar-promo-renderer,
#masthead-ad {
display: none !important;
}`;
document.head.appendChild(style);
sponsor?.forEach((element) => {
if (element.getAttribute("id") === "rendering-content") {
element.childNodes?.forEach((childElement) => {
if (childElement?.data.targetId && childElement?.data.targetId !=="engagement-panel-macro-markers-description-chapters"){
element.style.display = 'none';
}
});
}
});
if (debugMessages) console.log("Remove Adblock Thing: Removed page ads (✔️)");
}
function unPauseVideo(video)
{
if (!video) return;
if (video.paused) {
document.dispatchEvent(keyEvent);
unpausedAfterSkip = 0;
if (debugMessages) console.log("Remove Adblock Thing: Unpaused video using 'k' key");
} else if (unpausedAfterSkip > 0) unpausedAfterSkip--;
}
function checkForUpdate(){
if (!(window.location.href.includes("youtube.com"))){
return;
}
if (hasIgnoredUpdate){
return;
}
const scriptUrl = 'https://raw.githubusercontent.com/TheRealJoelmatic/RemoveAdblockThing/main/Youtube-Ad-blocker-Reminder-Remover.user.js';
fetch(scriptUrl)
.then(response => response.text())
.then(data => {
const match = data.match(/@version\s+(\d+\.\d+)/);
if (match) {
const githubVersion = parseFloat(match[1]);
const currentVersion = parseFloat(GM_info.script.version);
if (githubVersion > currentVersion) {
console.log('Remove Adblock Thing: A new version is available. Please update your script.');
var result = window.confirm("Remove Adblock Thing: A new version is available. Please update your script.");
if (result) {
window.location.replace(scriptUrl);
}
} else {
console.log('Remove Adblock Thing: You have the latest version of the script.');
}
} else {
console.error('Remove Adblock Thing: Unable to extract version from the GitHub script.');
}
})
.catch(error => {
hasIgnoredUpdate = true;
console.error('Remove Adblock Thing: Error checking for updates:', error);
});
hasIgnoredUpdate = true;
}
})();
'Web' 카테고리의 다른 글
통관 일정 예상하는 사이트 (0) | 2023.06.08 |
---|---|
무료 홈페이지 제작 (0) | 2023.03.31 |
[게임] 무료 온라인 웹 AI 게임 (장기, 체스) 스톡피쉬 (0) | 2023.03.23 |
무료 도메인, 무료 호스팅 (https://www.infinityfree.net) (0) | 2023.03.03 |
모바일(휴대폰)에서 쉽게 Tidal Master 음원 듣기 .... (유료) (0) | 2022.02.26 |
[소식] VS Code 개발 환경을 웹에서 .... (0) | 2021.10.21 |
댓글