SC2Casts.com Adblock Nag Screen Remover

Removes the 'disable Adblock' nag screen.

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

  1. // ==UserScript==
  2. // @name SC2Casts.com Adblock Nag Screen Remover
  3. // @namespace http://lazy.artifact
  4. // @version 0.32
  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. noop = function() {
  17. /* try to get some relaxation time in there. you don't *need* to update every day, do you? :) */
  18. },
  19. regexBodyAction = function(i, obj) {
  20. if (popupFuncBodyRegex.test(obj[i].toString())) {
  21. obj[i] = noop;
  22. }
  23. },
  24. walk = function(obj, action, maxDepth) {
  25. var i,
  26. nodes = [
  27. {
  28. value: obj,
  29. parent: null
  30. }
  31. ],
  32. nodeType,
  33. parent,
  34. currentDepth;
  35.  
  36. while(nodes.length > 0) {
  37. obj = nodes.shift();
  38. parent = obj.parent;
  39. currentDepth = 0;
  40.  
  41. while(parent !== null && parent !== undefined) {
  42. parent = parent.parent;
  43.  
  44. currentDepth++;
  45. }
  46. if(maxDepth !== undefined && maxDepth !== null && currentDepth >= maxDepth) {
  47. break;
  48. }
  49.  
  50. for(i in obj.value) {
  51. if(obj.value[i] === null || obj.value[i] === undefined) {
  52. continue;
  53. }
  54.  
  55. if(!Object.prototype.hasOwnProperty.call(obj.value, i)) {
  56. continue;
  57. }
  58.  
  59. nodeType = typeof obj.value[i];
  60. if(nodeType === 'object' && !(obj.value[i] instanceof window.constructor)) {
  61. if(nodes.findIndex(function(e) { return obj.value[i] === e; }) < 0) {
  62. continue;
  63. }
  64.  
  65. nodes.push({
  66. value: obj.value[i],
  67. parent: obj
  68. });
  69.  
  70. continue;
  71. }
  72.  
  73. if(nodeType !== 'function') {
  74. continue;
  75. }
  76.  
  77. action(i, obj.value);
  78. }
  79.  
  80. }
  81. };
  82. walk(window, regexBodyAction, null);
  83.  
  84. })();