Skip to content

Commit

Permalink
Kill overlays: kill known overlays (of *any* size)
Browse files Browse the repository at this point in the history
  • Loading branch information
janmoesen committed Feb 1, 2016
1 parent 9196f54 commit fc4e183
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bookmarks.html
Expand Up @@ -43,15 +43,15 @@ <H1>Bookmarks Menu</H1>

See COPYING for licence details. Or &quot;license details&quot;, if you are so inclined.

These bookmarks were exported on Thu, 2016/01/21 09:12:32 +0100.</P>
These bookmarks were exported on Mon, 2016/02/01 23:39:26 +0100.</P>
<DL><P>
<DT><H3>Content</H3>
<DD><P>Tweak the page's content.</P>
<DL><P>
<DT><A HREF="javascript:%28function%20loadFullSizeImages%28%29%20%7B%20%20var%20selectors%20%3D%20%5B%20%27img%5Bsrc%2A%3D%22%3F%22%5D%5Bsrc%2A%3D%22maxWidth%3D%22%5D%5Bsrc%2A%3D%22maxHeight%3D%22%5D%27%2C%20%27img%5Bsrc%2A%3D%22%3F%22%5D%5Bsrc%2A%3D%22maxwidth%3D%22%5D%5Bsrc%2A%3D%22maxheight%3D%22%5D%27%2C%20%27img%5Bsrc%2A%3D%22%3F%22%5D%5Bsrc%2A%3D%22width%3D%22%5D%5Bsrc%2A%3D%22height%3D%22%5D%27%2C%20%27img%5Bsrc%2A%3D%22%3F%22%5D%5Bsrc%2A%3D%22w%3D%22%5D%5Bsrc%2A%3D%22h%3D%22%5D%27%20%5D%3B%20%5B%5D.forEach.call%28%20document.querySelectorAll%28selectors.join%28%27%2C%20%27%29%29%2C%20function%20%28img%29%20%7B%20var%20queryParts%20%3D%20img.src.replace%28%2F.%2A%5C%3F%2F%2C%20%27%27%29.split%28%27%26%27%29%3B%20var%20newParts%20%3D%20queryParts.filter%28function%20%28s%29%20%7B%20return%20s.length%20%26%26%20%21s.match%28%2F%5E%28w%7Cwidth%7Cmaxwidth%7CmaxWidth%7Ch%7Cheight%7Cmaxheight%7CmaxHeight%29%3D%2F%29%3B%20%7D%29%3B%20var%20newSrc%20%3D%20img.src.replace%28%2F%5C%3F.%2A%2F%2C%20%27%27%29%3B%20if%20%28newParts.length%29%20%7B%20newSrc%20%2B%3D%20%27%3F%27%20%2B%20newParts.join%28%27%26%27%29%3B%20%7D%20if%20%28img.src%20%3D%3D%3D%20newSrc%29%20%7B%20return%3B%20%7D%20if%20%28window.console%20%26%26%20console.log%29%20%7B%20console.log%28%27Load%20full%20images%3A%20found%20matching%20query%20string%3B%20old%20img.src%3A%20%27%2C%20img.src%29%3B%20console.log%28%27Load%20full%20images%3A%20found%20matching%20query%20string%3B%20new%20img.src%3A%20%27%2C%20newSrc%29%3B%20%7D%20img.src%20%3D%20newSrc%3B%20%7D%29%3B%20%20%5B%5D.forEach.call%28%20document.querySelectorAll%28%27a%20img%27%29%2C%20function%20%28img%29%20%7B%20var%20a%20%3D%20img.parentNode%3B%20while%20%28a%20%26%26%20a.tagName%20%26%26%20a.tagName.toLowerCase%28%29%20%21%3D%3D%20%27a%27%29%20%7B%20a%20%3D%20a.parentNode%3B%20%7D%20if%20%28%21a%29%20%7B%20return%3B%20%7D%20if%20%28a.href%20%3D%3D%3D%20img.src%29%20%7B%20return%3B%20%7D%20var%20similarity%20%3D%20getSimilarity%28%27%27%20%2B%20img.src%2C%20%27%27%20%2B%20a.href%29%3B%20if%20%28similarity%20%3E%200.66%29%20%7B%20if%20%28window.console%20%26%26%20console.log%29%20%7B%20console.log%28%27Load%20full%20images%3A%20found%20linked%20image%20with%20%27%2C%20Math.round%28similarity%20%2A%20100%29%2C%20%27%25%20similarity%3B%20old%20img.src%3A%20%27%2C%20img.src%29%3B%20console.log%28%27Load%20full%20images%3A%20found%20linked%20image%20with%20%27%2C%20Math.round%28similarity%20%2A%20100%29%2C%20%27%25%20similarity%3B%20new%20img.src%3A%20%27%2C%20a.href%29%3B%20%7D%20img.src%20%3D%20a.href%3B%20%7D%20%7D%20%29%3B%20%20function%20getSimilarity%28strA%2C%20strB%29%20%7B%20var%20result%20%3D%200%2C%20i%20%3D%20Math.min%28strA.length%2C%20strB.length%29%3B%20while%20%28--i%29%20%7B%20if%20%28strA%5Bi%5D%20%3D%3D%3D%20strB%5Bi%5D%29%20%7B%20continue%3B%20%7D%20if%20%28strA%5Bi%5D.toLowerCase%28%29%20%3D%3D%3D%20strB%5Bi%5D.toLowerCase%28%29%29%20%7B%20result%2B%2B%3B%20%7D%20else%20%7B%20result%20%2B%3D%204%3B%20%7D%20%7D%20return%201%20-%20%28result%20%2B%204%20%2A%20Math.abs%28strA.length%20-%20strB.length%29%29%20%2F%20%282%20%2A%20%28strA.length%20%2B%20strB.length%29%29%3B%20%7D%20%7D%29%28%29%3B" ADD_DATE="1452292983" LAST_MODIFIED="1452520238" SHORTCUTURL="full-img">Load full images</A>
<DD><P>Load the full-size versions of resized images based on their &quot;src&quot;
attribute, or their containing link's &quot;href&quot; attribute.</P></DD>
<DT><A HREF="javascript:%28function%20killOverlays%28%29%20%7B%20%20var%20selectors%20%3D%20%5B%20%27body%20%5Bclass%2A%3D%22modal%22%5D%27%2C%20%27body%20%5Bclass%2A%3D%22overlay%22%5D%27%2C%20%27body%20%5Bclass%2A%3D%22popup%22%5D%27%2C%20%27body%20%5Bstyle%2A%3D%22width%22%5D%5Bstyle%2A%3D%22height%22%5D%5Bstyle%2A%3D%22100%25%22%5D%27%2C%20%27body%20%5Bclass%5E%3D%22nyroModal%22%5D%27%2C%20%27.frame-container%27%2C%20%27.optimonk-holder%27%2C%20%27iframe%5Bstyle%5D%27%2C%20%27%23spout-friendly-iframe%27%2C%20%5D%3B%20%5B%5D.forEach.call%28%20document.querySelectorAll%28selectors.join%28%27%2C%20%27%29%29%2C%20function%20%28elem%29%20%7B%20if%20%28elem.offsetWidth%20%2F%20window.innerWidth%20%3E%200.75%20%7C%7C%20elem.offsetHeight%20%2F%20window.innerHeight%20%3E%200.75%29%20%7B%20elem.parentNode.removeChild%28elem%29%3B%20%7D%20%7D%20%29%3B%20%20document.body.classList.remove%28%27login_no_scroll%27%29%3B%20%20%5B%5D.forEach.call%28%20document.querySelectorAll%28%27%5Bstyle%2A%3D%22overflow%22%5D%5Bstyle%2A%3D%22hidden%22%5D%27%29%2C%20function%20%28elem%29%20%7B%20elem.setAttribute%28%27style%27%2C%20elem.getAttribute%28%27style%27%29.replace%28%2Foverflow%5Cs%2A%3A%5Cs%2Ahidden%5Cs%2A%3B%3F%2F%2C%20%27%27%29%29%3B%20%7D%20%29%3B%20%7D%29%28%29%3B" ADD_DATE="1452295742" LAST_MODIFIED="1453132724" SHORTCUTURL="kill-overlays">Kill overlays</A>
<DT><A HREF="javascript:%28function%20killOverlays%28%29%20%7B%20%20var%20selectors%20%3D%20%5B%20%27body%20%5Bclass%5E%3D%22nyroModal%22%5D%27%2C%20%27.optimonk-holder%27%2C%20%27%23spout-friendly-iframe%27%2C%20%5D%3B%20%5B%5D.forEach.call%28%20document.querySelectorAll%28selectors.join%28%27%2C%20%27%29%29%2C%20function%20%28elem%29%20%7B%20elem.parentNode.removeChild%28elem%29%3B%20%7D%20%29%3B%20%20var%20selectors%20%3D%20%5B%20%27body%20%5Bclass%2A%3D%22modal%22%5D%27%2C%20%27body%20%5Bclass%2A%3D%22overlay%22%5D%27%2C%20%27body%20%5Bclass%2A%3D%22popup%22%5D%27%2C%20%27body%20%5Bstyle%2A%3D%22width%22%5D%5Bstyle%2A%3D%22height%22%5D%5Bstyle%2A%3D%22100%25%22%5D%27%2C%20%27.frame-container%27%2C%20%27iframe%5Bstyle%5D%27%2C%20%5D%3B%20%5B%5D.forEach.call%28%20document.querySelectorAll%28selectors.join%28%27%2C%20%27%29%29%2C%20function%20%28elem%29%20%7B%20if%20%28elem.offsetWidth%20%2F%20window.innerWidth%20%3E%200.75%20%7C%7C%20elem.offsetHeight%20%2F%20window.innerHeight%20%3E%200.75%29%20%7B%20elem.parentNode.removeChild%28elem%29%3B%20%7D%20%7D%20%29%3B%20%20document.body.classList.remove%28%27login_no_scroll%27%29%3B%20%20%5B%5D.forEach.call%28%20document.querySelectorAll%28%27%5Bstyle%2A%3D%22overflow%22%5D%5Bstyle%2A%3D%22hidden%22%5D%27%29%2C%20function%20%28elem%29%20%7B%20elem.setAttribute%28%27style%27%2C%20elem.getAttribute%28%27style%27%29.replace%28%2Foverflow%5Cs%2A%3A%5Cs%2Ahidden%5Cs%2A%3B%3F%2F%2C%20%27%27%29%29%3B%20%7D%20%29%3B%20%7D%29%28%29%3B" ADD_DATE="1452295742" LAST_MODIFIED="1454366362" SHORTCUTURL="kill-overlays">Kill overlays</A>
<DD><P>Get rid of common overlays, such as full-page ads.</P></DD>
</DL>
<DT><H3>Development</H3>
Expand Down
17 changes: 14 additions & 3 deletions content/kill-overlays.js
Expand Up @@ -5,17 +5,28 @@
* @keyword kill-overlays
*/
(function killOverlays() {
/* Remove known overlays. */
var selectors = [
'body [class^="nyroModal"]',
'.optimonk-holder',
'#spout-friendly-iframe',
];

[].forEach.call(
document.querySelectorAll(selectors.join(', ')),
function (elem) {
elem.parentNode.removeChild(elem);
}
);

/* Remove "suspicious" elements. */
var selectors = [
'body [class*="modal"]',
'body [class*="overlay"]',
'body [class*="popup"]',
'body [style*="width"][style*="height"][style*="100%"]',
'body [class^="nyroModal"]',
'.frame-container',
'.optimonk-holder',
'iframe[style]',
'#spout-friendly-iframe',
];

[].forEach.call(
Expand Down

0 comments on commit fc4e183

Please sign in to comment.