Youtube AdBlock ban bypass

Bypass youtubes new ad block restrictions

As of 2023-10-15. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Youtube AdBlock ban bypass
// @namespace    http://tampermonkey.net/
// @version      0.31
// @description  Bypass youtubes new ad block restrictions
// @author       Obelous
// @match        https://www.youtube.com/*
// @match        https://www.youtube-nocookie.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      MIT
// ==/UserScript==

let currentPageUrl = window.location.href;

window.addEventListener('beforeunload', function () {
    currentPageUrl = window.location.href;
});

document.addEventListener('yt-navigate-finish', function () {
    const newUrl = window.location.href;
    if (newUrl !== currentPageUrl) {
        location.reload();
    }
});

function splitUrl(str) {
    return str.split('=')[1];
}

function run() {
    console.log("Loaded");
    const block = document.querySelector('.yt-playability-error-supported-renderers');
    block.parentNode.removeChild(block);
    const url = "https://youtube.com/embed/" + splitUrl(window.location.href);
    const oldplayer = document.getElementById("error-screen");
    const player = document.createElement('iframe');
    player.setAttribute('src', url);
    player.style = "height:100%;width:100%;border-radius:12px;";
    player.id = "youtube-iframe";
    oldplayer.appendChild(player);
    console.log('Finished');
}

(function() {
    'use strict';
    //|             |||
    // RUN DELAY    VVV
    setTimeout(run, 500);
})();