Fix the "Ad blockers violate YouTube's Terms of Service" Error
< Feedback on Youtube AdBlock ban bypass
Oh, one more thing! Since this uses the embedded version of the YT player, I thought everyone here should know that it's not able to display age-restricted content. However, this other script helps to bypass that restriction, so it's best to use that script alongside this script :)
https://greasyfork.org/en/scripts/423851-simple-youtube-age-restriction-bypass
Another fix, haha. I fixed the issue where the video player would continue to play if the user navigates away from the "watch" page (without pausing first), by deleting the iframe anytime they navigate away from them. I added a new yt-page-type-changed
listener that specifically works for this, and made sure that the iframe is recreated on the next video if it's been removed, which naturally meant some changes had to be made to the existing yt-navigate-finish
listener.
document.addEventListener('yt-page-type-changed', function() {
const newUrl = window.location.href;
// remove the player iframe when the user navigates away from a "watch" page
if (!newUrl.includes("watch")) {
const player = document.getElementById("youtube-iframe");
player.parentNode.removeChild(player);
}
});
document.addEventListener('yt-navigate-finish', function() {
const newUrl = window.location.href;
if (newUrl !== currentPageUrl) {
const url = "https://www.youtube-nocookie.com/embed/" + splitUrl(newUrl) + "?autoplay=1" + getTimestampFromUrl(newUrl);
let player = document.getElementById("youtube-iframe");
// recreate the player iframe if it was removed
if(!player) {
// get the mount point for the iframe
const oldplayer = document.getElementById("error-screen");
// create the iframe
player = document.createElement('iframe');
player.style = "height:100%;width:100%;border-radius:12px;";
player.id = "youtube-iframe";
// append the elements to the DOM
oldplayer.appendChild(player);
}
setYtPlayerAttributes(player, url);
}
});
Could you add your changes to the github at https://github.com/0belous/Youtube-AdBlock-ban-Bypass this just makes it easier to put everyones changes into the next update.
Incase you havent used github before you need to clone the project to download it, make your changes and create a pull request to add your changes, there are many tutorials on google if you need help.
Thank you for contributing by the way I can see you have added a lot.
Whoops, I just noticed this. Funny story actually, I do have a Github account, but didn't notice/realise you have this on there as well, so I sorta already created a new repo instead...? I'll get all the changes I have so far and add it to yours, then maybe delete my repo once you've merged everything on your end.
Okay, I went ahead and made a pull request on your dev branch. I hope you don't mind! I just liked your attempt to fix the playlist issue, so I wanted to incorporate those. :p
Hi, it's me again. I went ahead and added support for timestamp tags. :)
I also took the time to clean up the code and moved the
player.setAttribute()
stuff into its own function, so it can be easily reused, in case such a need arises later.Again, many thanks to you OP, and everyone else who have contributed so far!