YouTube - Mute Ads

Automatically mutes VideoAds

当前为 2015-11-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube - Mute Ads
  3. // @name:de YouTube - Mute Ads
  4. // @version 1.0.4
  5. // @description Automatically mutes VideoAds
  6. // @description:de Schaltet Werbung auf YouTube automatisch stumm
  7. // @autor VVind0wM4ker
  8. // @namespace https://github.com/VVind0wM4ker/Userscripts
  9. // @homepageURL https://github.com/VVind0wM4ker/Userscripts/tree/master/YouTube_Mute_Ads
  10. // @license MIT License
  11. // @grant none
  12. // @include http*://*.youtube.com/watch*
  13. // ==/UserScript==
  14.  
  15.  
  16. var adPlaying = 0;
  17. var interval = 500
  18. var vid = document.getElementsByClassName("video-stream html5-main-video")[0];
  19.  
  20. var timer;
  21.  
  22.  
  23. vid.onplay = function() {startTimer();};
  24. vid.onpause = function() {pauseTimer();};
  25. var muteAds = function () {
  26. //console.log("check for Ads") //for testing
  27. if (document.getElementsByClassName("ad-interrupting").length > 0) {
  28. adPlaying = 1;
  29. vid.mute();
  30. }
  31. else {
  32. if (adPlaying == 1) {
  33. adPlaying = 0;
  34. vid.unMute();
  35. }
  36. }
  37. };
  38.  
  39.  
  40.  
  41. function pauseTimer () {
  42. clearInterval(timer);
  43. }
  44.  
  45. function startTimer () {
  46. clearInterval(timer);
  47. timer = setInterval(muteAds, interval);
  48. }