Youtube Ad Cleaner(Include Non-Skippable Ads- works)

(Be Tested Daily) Bypass all youtube ads (skippable and non-skippable Ads) plus download youtube video on the fly

  1. // ==UserScript==
  2. // @name Youtube Ad Cleaner(Include Non-Skippable Ads- works)
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.50.9
  5. // @description (Be Tested Daily) Bypass all youtube ads (skippable and non-skippable Ads) plus download youtube video on the fly
  6. // @ Please add youtube.com to the whitelist if you are using any adblocker to avoid reload loops
  7. // @author BjDanny
  8. // @run-at document-start
  9. // @match *://*.youtube.com/*
  10. // ==/UserScript==
  11. 'use strict';
  12. var currentTime, duration, yt;
  13.  
  14.  
  15. function myWindow()
  16. {
  17. let y = window.location.href.replace("youtube", "youtube5s");
  18. let myWin = window.open(y,"Download Youtube Video","directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=800, height=900");
  19. myWin.onload = setInterval(clearPage,1000);
  20. }
  21.  
  22. function clearPage()
  23. {
  24. try{
  25. document.querySelectorAll(".col-xs-12")[8].remove();
  26. document.querySelector("footer").remove();
  27. document.querySelector("ul").remove();
  28. document.querySelector(".navbar-header").remove();
  29. document.querySelector("#logo-icon").remove();
  30. }
  31. catch(e)
  32. {
  33. return;
  34. }
  35. }
  36.  
  37.  
  38. function createButton()
  39. {
  40. try{
  41. let css = document.createElement('style');
  42. //Thanks GreenSheep3 for the css style
  43. css.innerHTML = `
  44. .myButton {
  45. font-size: 14px;
  46. font-weight: 300;
  47. color: #eee;
  48. text-align: center;
  49. vertical-align: middle;
  50. border: 1px solid #555;
  51. border-radius: 50px;
  52. background-color: rgba(0, 0, 0, 0);
  53. height: 36px;
  54. width: 135px;
  55. padding: 0;
  56. margin: 8px
  57. }
  58. `;
  59. document.head.appendChild(css);
  60. let btn = document.createElement("BUTTON");
  61. btn.className = "myButton";
  62. btn.id = "mybutton";
  63. btn.innerHTML = "DOWNLOAD";
  64. btn.addEventListener("click", myWindow);
  65. document.querySelector("#owner").appendChild(btn);
  66. }
  67. catch(e)
  68. {
  69. }
  70. }
  71.  
  72. function adOverlay(){
  73. const ad = document.querySelector(".ytp-ad-text");
  74. const video = document.querySelector("video");
  75. if (ad){
  76. video.currentTime = video.duration;
  77. }
  78. let btn = document.querySelector(".ytp-ad-skip-button-icon-modern");
  79. if(btn){document.querySelector(".ytp-ad-skip-button-icon-modern").click();console.log("Skipped Video Ad");}
  80. }
  81.  
  82.  
  83. function removeSp()
  84. {
  85. try
  86. {
  87. if (document.getElementById("support").innerText.includes("Ad") == true)
  88. {
  89. document.getElementsByClassName("ytd-rich-item-renderer")[0].innerHTML = ""
  90. console.log('Sponsor Ad removed!');
  91. }
  92. }
  93. catch(e)
  94. {
  95. return;
  96. }
  97. }
  98.  
  99. var Ads = {
  100. "aId":["masthead-ad","player-ads","top-container","offer-module","pyv-watch-related-dest-url","ytd-promoted-video-renderer","sparkles-container","fulfilled-layout"],
  101. "aClass":["style-scope ytd-search-pyv-renderer","ytd-compact-promoted-video-renderer","style-scope ytd-carousel-ad-renderer","ytp-ad-overlay-container","ytp-ad-message-container","style-scope ytd-engagement-panel-section-list-renderer"],
  102. "aTag":["ytd-promoted-sparkles-text-search-renderer"],
  103. "vdoAd":["ytp-ad-text ytp-ad-preview-text","ytp-ad-skip-button ytp-button","ytp-ad-text ytp-ad-skip-button-text-centered ytp-ad-skip-button-text"],
  104. "removeByID":function(){this.aId.forEach(i=>{ let AdId = document.getElementById(i);if(AdId) AdId.remove();})},
  105. "removeByClassName":function(){this.aClass.forEach(c=>{ let AdClass = document.getElementsByClassName(c);if(AdClass[0]) AdClass[0].remove();})},
  106. "removeByTagName":function(){this.aTag.forEach(t=>{ let AdTag = document.getElementsByTagName(t);if(AdTag[0]) AdTag[0].remove();})},
  107. "removeVdoAd":function(){this.vdoAd.forEach(v=>{let AdVdo = document.getElementsByClassName(v)[0];if(AdVdo) {AdVdo.click(); console.log("Skipped a clickable Ad")}})} //handles skippable video Ad
  108. }
  109.  
  110. function killAd()
  111. {
  112. Ads.removeByID();
  113. Ads.removeByClassName();
  114. Ads.removeByTagName();
  115. Ads.removeVdoAd();
  116. removeSp();
  117. adOverlay();
  118. }
  119.  
  120. document.addEventListener('DOMContentLoaded', ()=>{setInterval(killAd, 100); setTimeout(createButton, 5000);});

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址