SC2Casts.com Adblock Nag Screen Remover

Removes the 'disable Adblock' nag screen.

当前为 2016-06-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name SC2Casts.com Adblock Nag Screen Remover
  3. // @namespace http://lazy.artifact
  4. // @version 0.35
  5. // @description Removes the 'disable Adblock' nag screen.
  6. // @author Lazy Artifact
  7. // @match http://sc2casts.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var popupFuncBodyRegex = /display\s*=\s*["']/im,
  15. i,
  16. regexBodyAction = function(i, obj) {
  17. if (popupFuncBodyRegex.test(obj[i].toString())) {
  18. var oldFunc = obj[i],
  19. funcToString = Function.prototype.toString,
  20. noop = function() {};
  21. obj[i] = noop;
  22. noop.toString = function() {
  23. return funcToString.call(oldFunc);
  24. };
  25. }
  26. },
  27. walk = function(obj, action, maxDepth) {
  28. var i,
  29. nodes = [
  30. {
  31. value: obj,
  32. parent: null
  33. }
  34. ],
  35. nodeType,
  36. parent,
  37. currentDepth;
  38.  
  39. while(nodes.length > 0) {
  40. obj = nodes.shift();
  41. parent = obj.parent;
  42. currentDepth = 0;
  43.  
  44. while(parent !== null && parent !== undefined) {
  45. parent = parent.parent;
  46.  
  47. currentDepth++;
  48. }
  49. if(maxDepth !== undefined && maxDepth !== null && currentDepth >= maxDepth) {
  50. break;
  51. }
  52.  
  53. for(i in obj.value) {
  54. if(obj.value[i] === null || obj.value[i] === undefined) {
  55. continue;
  56. }
  57.  
  58. if(!Object.prototype.hasOwnProperty.call(obj.value, i)) {
  59. continue;
  60. }
  61.  
  62. nodeType = typeof obj.value[i];
  63. if(nodeType === 'object' && !(obj.value[i] instanceof window.constructor)) {
  64. if(nodes.findIndex(function(e) { return obj.value[i] === e; }) < 0) {
  65. continue;
  66. }
  67.  
  68. nodes.push({
  69. value: obj.value[i],
  70. parent: obj
  71. });
  72.  
  73. continue;
  74. }
  75.  
  76. if(nodeType !== 'function') {
  77. continue;
  78. }
  79.  
  80. action(i, obj.value);
  81. }
  82.  
  83. }
  84. };
  85. walk(window, regexBodyAction, null);
  86. })();