├── .gitignore ├── .jpmignore ├── icon.png ├── data ├── courtain_16.png ├── courtain_32.png └── overlay_remover.js ├── release.cmd ├── lib └── main.js ├── package.json ├── README.md ├── update.xml └── WORKS_ON.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.xpi 2 | *.exe 3 | bootstrap.js 4 | install.rdf 5 | -------------------------------------------------------------------------------- /.jpmignore: -------------------------------------------------------------------------------- 1 | .* 2 | *.xpi 3 | *.md 4 | *.exe 5 | release.cmd 6 | update.xml 7 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustOff/dismiss-the-overlay/HEAD/icon.png -------------------------------------------------------------------------------- /data/courtain_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustOff/dismiss-the-overlay/HEAD/data/courtain_16.png -------------------------------------------------------------------------------- /data/courtain_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JustOff/dismiss-the-overlay/HEAD/data/courtain_32.png -------------------------------------------------------------------------------- /release.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | set VER=1.0.7 3 | 4 | sed -i -E "s/\"version\": \".+?\"/\"version\": \"%VER%\"/; s/\"name\": \".+?\"/\"name\": \"dismiss-the-overlay-%VER%\"/" package.json 5 | sed -i -E "s/version>.+?%VER%=38.0a1 <=56.*", 10 | "{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}": ">=27.1.0b1 <=29.*" 11 | }, 12 | "permissions": { 13 | "private-browsing": true 14 | }, 15 | "author": "Off JustOff ", 16 | "contributors": [ 17 | "Nicolae Namolovan" 18 | ], 19 | "homepage": "https://github.com/JustOff/dismiss-the-overlay", 20 | "updateURL": "https://raw.githubusercontent.com/JustOff/dismiss-the-overlay/master/update.xml", 21 | "license": "MIT" 22 | } 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### [ Dismiss The Overlay](https://github.com/JustOff/dismiss-the-overlay/releases) 2 | 3 | **What's it all about?** 4 | 5 | Some websites will use an overlay to mask its content with a transparent background to force you to read a message before you can see the actual content. 6 | 7 | This is very annoying as every site will have a different way to close that overlay popup. 8 | 9 | This extension solves this problem by offering **one button to close any overlay** on any website you may ever encounter. 10 | 11 | **Does it work everywhere ?** 12 | 13 | The extension should work on most sites that have overlays. Here is a list of some of the websites that the extension is know to work: [WORKS_ON.md](WORKS_ON.md). 14 | 15 | **Features** 16 | 17 | * Requires no special permissions. 18 | * Extremely lightweight, relies on little known ``document.elementFromPoint`` browser's function to find elements that are in front with the highest z-index. 19 | * Non-intrusive. The extension activates only when you click its button, thereby it has no impact on navigation performance when you don't use the extension. Doesn't inject tons of CSS rules as AdBlock extension is doing for example. 20 | * Supports hiding of multiple DOM overlay elements. 21 | * Enables overflow auto of the body when overlay script hides it to disable the scroll of the page. 22 | 23 | **Licence** 24 | Licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php). 25 | -------------------------------------------------------------------------------- /update.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1.0.7 9 | 10 | 11 | {8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4} 12 | 27.1.0b1 13 | 29.* 14 | https://github.com/JustOff/dismiss-the-overlay/releases/download/1.0.7/dismiss-the-overlay-1.0.7.xpi 15 | 16 | 17 | 18 | 19 | {ec8030f7-c20a-464f-9b0e-13a3a9e97384} 20 | 38.0a1 21 | 56.* 22 | https://github.com/JustOff/dismiss-the-overlay/releases/download/1.0.7/dismiss-the-overlay-1.0.7.xpi 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /WORKS_ON.md: -------------------------------------------------------------------------------- 1 | These are some of the sites where the extension was tested to be working 2 | 3 | * http://www.quora.com/Product-Launches/What-is-the-best-day-of-the-week-to-launch-a-new-product-or-company 4 | * https://www.youtube.com/user/SCStarNet?annotation_id=annotation_1748547763&feature=iv&src_vid=BOl7H0jGiOw&sub_confirmation=1 5 | * http://www.pbs.org/wgbh/pages/frontline/shows/teenbrain/work/adolescent.html 6 | * http://www.pcmag.com/ 7 | * http://www.billhowe.com/2012/08/take-our-survey-and-get-5-to-starbucks-and-be-entered-in-our-big-giveaway/ 8 | * http://www.parallels.com/products/desktop/ 9 | * http://slashdot.org/story/14/05/27/1326219/the-flaw-lurking-in-every-deep-neural-net 10 | * http://sfglobe.com/?id=846 11 | * http://www.thebetterindia.com/10904/jadav-molai-payeng-forest-man-india/ 12 | * http://www.maddyness.com/accompagnement/formation-accompagnement/2014/05/05/subvention-startup-horizon-2020/ 13 | * http://www.siteslike.com/similar/google.com 14 | * http://privesc.eu 15 | * http://www.facenews.ua/articles/2014/198055/ 16 | * http://www.sitepoint.com/using-beacon-image-github-website-email-analytics/ 17 | * http://www.ft.com/cms/s/1bef71b8-e433-11e3-a73a-00144feabdc0,Authorised=false.html?_i_location=http%3A%2F%2Fwww.ft.com%2Fcms%2Fs%2F0%2F1bef71b8-e433-11e3-a73a-00144feabdc0.html%3Fsiteedition%3Duk&siteedition=uk&_i_referer=#axzz32pxnHeyS 18 | * http://www.searchenginejournal.com/5-important-link-removal-facts-post-penguin-2-0/65027/ 19 | * http://www.lemonde.fr/sante/article/2014/05/30/paquets-neutres-interdiction-du-vapotage-en-public-les-mesures-chocs-anti-tabac_4428991_1651302.html 20 | * http://evroua.com/poroshenko-obyasnil-kak-ukraina-budet-zhit-bez-rossijskogo-gaza/ 21 | * http://www.motherjones.com/media/2014/05/internet-archive-wayback-machine-brewster-kahle 22 | * http://www.linearpublishing.com/Articles-s-15047.412112-203190.114123-p17698.114123-sub_Overlay_Ads.html 23 | * https://sowefund.com/projet/1/Brands-On-Air 24 | * http://www.scoop.it/t/sigfox/p/3633647007/2012/12/07/sigfox-recrute 25 | * http://www.devfright.com/ibeacons-tutorial-ios-7-clbeaconregion-clbeacon/ -------------------------------------------------------------------------------- /data/overlay_remover.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This is a script that will remove overlay popups in the 99% of the cases. 3 | * It's doing that by detecting DOM elements. 4 | * 5 | */ 6 | 7 | var debug = false; 8 | 9 | var utils = (function() { 10 | function hideElement(element) { 11 | styleImportant(element, 'display', 'none'); 12 | } 13 | 14 | function styleImportant(element, cssProperty, cssValue) { 15 | element.style[cssProperty] = ''; 16 | var cssText = element.style.cssText || ''; 17 | if (cssText.length > 0 && cssText.slice(-1) != ';') 18 | cssText += ';'; 19 | // Some pages are using !important on elements, so we must use it too 20 | element.style.cssText = cssText + cssProperty + ': ' + cssValue + ' !important;'; 21 | } 22 | 23 | function isVisible(element) { 24 | return element.offsetWidth > 0 && element.offsetHeight > 0; 25 | } 26 | 27 | function getZIndex(element) { 28 | return parseInt(window.getComputedStyle(element).zIndex); 29 | } 30 | 31 | function isAnElement(node) { 32 | return node.nodeType == 1; // nodeType 1 mean element 33 | } 34 | 35 | function nodeListToArray(nodeList) { 36 | return Array.prototype.slice.call(nodeList); 37 | } 38 | 39 | function forEachElement(nodeList, functionToApply) { 40 | nodeListToArray(nodeList).filter(isAnElement).forEach(function(element) { 41 | functionToApply.call(this, element); 42 | }); 43 | } 44 | 45 | function collectParrents(element, predicate) { 46 | var matchedElement = element && predicate(element) ? [element] : []; 47 | var parent = element.parentNode; 48 | 49 | if (parent && parent != document && parent != document.body) { 50 | return matchedElement.concat(collectParrents(parent, predicate)); 51 | } else { 52 | return matchedElement; 53 | } 54 | } 55 | 56 | // Calculate the number of DOM elements inside an element 57 | function elementWeight(element, maxThreshold) { 58 | var grandTotal = 0; 59 | var nextElement = element; 60 | var nextGrandChildNodes = []; 61 | 62 | function calculateBreathFirst(element) { 63 | var total = 0; 64 | var nextChildElements = []; 65 | 66 | var childNodes = element.childNodes; 67 | total = childNodes.length; 68 | 69 | forEachElement(childNodes, function(childNode) { 70 | var grandChildNodes = nodeListToArray(childNode.childNodes); 71 | total += grandChildNodes.length; 72 | nextChildElements = nextChildElements.concat(grandChildNodes.filter(isAnElement)); 73 | }); 74 | return [total, nextChildElements]; 75 | } 76 | 77 | while (nextElement) { 78 | var tuple_total_nextChildElements = calculateBreathFirst(nextElement); 79 | var total = tuple_total_nextChildElements[0]; 80 | 81 | grandTotal += total; 82 | nextGrandChildNodes = nextGrandChildNodes.concat(tuple_total_nextChildElements[1]); 83 | 84 | if (grandTotal >= maxThreshold) { 85 | break; 86 | } else { 87 | nextElement = nextGrandChildNodes.pop(); 88 | } 89 | } 90 | 91 | return grandTotal; 92 | } 93 | 94 | return { 95 | hideElement: hideElement, 96 | isVisible: isVisible, 97 | getZIndex: getZIndex, 98 | forEachElement: forEachElement, 99 | collectParrents: collectParrents, 100 | elementWeight: elementWeight, 101 | styleImportant: styleImportant 102 | } 103 | })(); 104 | 105 | var overlayRemover = function(debug, utils) { 106 | function hideElementsAtZIndexNear(nearElement, thresholdZIndex) { 107 | var parent = nearElement.parentNode; 108 | // The case when nearElement is a document 109 | if (parent === null) { 110 | return; 111 | } 112 | var children = parent.childNodes; 113 | 114 | utils.forEachElement(children, function(child) { 115 | if (utils.getZIndex(child) >= thresholdZIndex) { 116 | utils.hideElement(child); 117 | } 118 | }) 119 | } 120 | 121 | // Check the element in the middle of the screen 122 | // Search fo elements that has zIndex attribute 123 | function methodTwoHideElementMiddle() { 124 | var overlayPopup = document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2); 125 | 126 | var overlayFound = utils.collectParrents( overlayPopup, function(el) { 127 | return utils.getZIndex(el) > 0; 128 | }); 129 | 130 | if (debug) 131 | console.debug('Overlay found: ', overlayFound); 132 | 133 | if (overlayFound.length == 0) 134 | return false; 135 | 136 | var olderParent = overlayFound.pop(); 137 | 138 | if (debug) 139 | console.debug('Hide parrent: ', olderParent); 140 | 141 | return olderParent; 142 | } 143 | 144 | function containersOverflowAuto() { 145 | var containers = [document.documentElement, document.body]; 146 | 147 | containers.forEach(function(element) { 148 | if (window.getComputedStyle(element).overflow == 'hidden') { 149 | utils.styleImportant(element, 'overflow', 'auto'); 150 | } 151 | }) 152 | } 153 | 154 | function run() { 155 | for (var i = 0; i < 10; i++) { 156 | var candidate = methodTwoHideElementMiddle(); 157 | var first = i == 0; 158 | if (candidate === false) { 159 | if (first) 160 | alert('No overlay has been found on this website.'); 161 | break; 162 | } else { 163 | if (!first) { 164 | // Prevent to hide the actual content 165 | var weightThreshold = 100; 166 | var candidateWeight = utils.elementWeight(candidate, weightThreshold) 167 | if (candidateWeight < weightThreshold) { 168 | if (debug) 169 | console.log('Element is too lightweigh, hide it', candidate); 170 | utils.hideElement(candidate); 171 | } else { 172 | if (debug) 173 | console.log("Element is too heavy, don't hide it", candidate); 174 | } 175 | } else { 176 | utils.hideElement(candidate); 177 | containersOverflowAuto(); 178 | } 179 | } 180 | } 181 | } 182 | 183 | return { 184 | run: run 185 | }; 186 | 187 | }; 188 | 189 | overlayRemoverInstance = overlayRemover(debug, utils); 190 | 191 | function overlayRemoverRun() { 192 | overlayRemoverInstance.run(); 193 | } --------------------------------------------------------------------------------