Remove Youtube Ads(Works)

Removes all ads including video ads

目前为 2017-03-08 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Remove Youtube Ads(Works)
  3. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.6
  6. // @description Removes all ads including video ads
  7. // @author Wrekt/Ethan
  8. // @match https://www.youtube.com/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. var advideo = "false";
  13.  
  14. function clickOrigin(e){
  15. var target = e.target;
  16. var tag = [];
  17. tag.tagType = target.tagName.toLowerCase();
  18. tag.tagClass = target.className.split(' ');
  19. tag.id = target.id;
  20. tag.parent = target.parentNode;
  21.  
  22. return tag;
  23. }
  24.  
  25. var tagsToIdentify = ['img','a'];
  26.  
  27. document.body.onclick = function(e){
  28. elem = clickOrigin(e);
  29.  
  30. for (i=0;i<tagsToIdentify.length;i++){
  31. if (elem.tagType == tagsToIdentify[i]){
  32. console.log('You\'ve clicked a monitored tag (' + elem.tagType + ', in this case).');
  33. location.reload();
  34. console.log("Reloaded");
  35. }
  36. }
  37. };
  38.  
  39. if ($(".ad-showing")[0]){
  40. advideo = "true";
  41. } else {
  42. advideo = "false";
  43. }
  44.  
  45. (function() {
  46. $("#header").remove();
  47. })();
  48.  
  49.  
  50. (function(){
  51. if ($(".ad-showing")[0]){
  52. advideo = "true";
  53. } else {
  54. advideo = "false";
  55. }
  56. $("#watch7-sidebar-ads").remove();
  57. $(".pyv-afc-ads-container").remove();
  58. $(".video-ads").remove();
  59. $("#pyv-watch-related-dest-url").remove();
  60. if (advideo == "true") {
  61. $(".video-stream").attr("src", "");
  62. }
  63. setTimeout(arguments.callee, 1000);
  64. })();