SC2Casts.com Adblock Nag Screen Remover

Removes the 'disable Adblock' nag screen.

当前为 2016-05-28 提交的版本,查看 最新版本

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