🏠 Home 

Anti-Adblock Killer on spiegel.de

Removes the Anti-Adblock Overlay


Install this script?
  1. // ==UserScript==
  2. // @name Anti-Adblock Killer on spiegel.de
  3. // @description Removes the Anti-Adblock Overlay
  4. // @run-at document-start
  5. // @include http://www.spiegel.de/*
  6. // @version 0.0.1.20171121
  7. // @namespace https://greasyfork.org/users/67252
  8. // ==/UserScript==
  9. // This script is based on https://gist.github.com/raw/2620135/checkForBadJavascripts.js
  10. checkForBadJavascripts([
  11. [false, /showAdBlockDetectionLayer/, null]
  12. ]);
  13. function checkForBadJavascripts (controlArray) {
  14. /*--- Note that this is a self-initializing function. The controlArray
  15. parameter is only active for the FIRST call. After that, it is an
  16. event listener.
  17. The control array row is defines like so:
  18. [bSearchSrcAttr, identifyingRegex, callbackFunction]
  19. Where:
  20. bSearchSrcAttr True to search the SRC attribute of a script tag
  21. false to search the TEXT content of a script tag.
  22. identifyingRegex A valid regular expression that should be unique
  23. to that particular script tag.
  24. callbackFunction An optional function to execute when the script is
  25. found. Use null if not needed.
  26. Usage example:
  27. checkForBadJavascripts ( [
  28. [false, /old, evil init()/, function () {addJS_Node (init);} ],
  29. [true, /evilExternalJS/i, null ]
  30. ] );
  31. */
  32. if ( ! controlArray.length) return null;
  33. checkForBadJavascripts = function (zEvent) {
  34. for (var J = controlArray.length - 1; J >= 0; --J) {
  35. var bSearchSrcAttr = controlArray[J][0];
  36. var identifyingRegex = controlArray[J][1];
  37. if (bSearchSrcAttr) {
  38. if (identifyingRegex.test (zEvent.target.src) ) {
  39. stopBadJavascript (J);
  40. return false;
  41. }
  42. }
  43. else {
  44. if (identifyingRegex.test (zEvent.target.textContent) ) {
  45. stopBadJavascript (J);
  46. return false;
  47. }
  48. }
  49. }
  50. function stopBadJavascript (controlIndex) {
  51. zEvent.stopPropagation ();
  52. zEvent.preventDefault ();
  53. var callbackFunction = controlArray[J][2];
  54. if (typeof callbackFunction == "function")
  55. callbackFunction (zEvent.target);
  56. //--- Remove the node just to clear clutter from Firebug inspection.
  57. zEvent.target.parentNode.removeChild (zEvent.target);
  58. //--- Script is intercepted, remove it from the list.
  59. controlArray.splice (J, 1);
  60. if ( ! controlArray.length) {
  61. //--- All done, remove the listener.
  62. window.removeEventListener (
  63. 'beforescriptexecute', checkForBadJavascripts, true
  64. );
  65. }
  66. }
  67. }
  68. /*--- Use the "beforescriptexecute" event to monitor scipts as they are loaded.
  69. See https://developer.mozilla.org/en/DOM/element.onbeforescriptexecute
  70. Note seems to work on acripts that are dynamically created, despite what
  71. the spec says.
  72. */
  73. window.addEventListener ('beforescriptexecute', checkForBadJavascripts, true);
  74. return checkForBadJavascripts;
  75. }
  76. function addJS_Node (text, s_URL, funcToRun) {
  77. var D = document;
  78. var scriptNode = D.createElement ('script');
  79. scriptNode.type = "text/javascript";
  80. if (text) scriptNode.textContent = text;
  81. if (s_URL) scriptNode.src = s_URL;
  82. if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()';
  83. var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
  84. //--- Don't error check here. if DOM not available, should throw error.
  85. targ.appendChild (scriptNode);
  86. }