Skip to content

Instantly share code, notes, and snippets.

@vnys
Last active August 29, 2015 14:07
Show Gist options
  • Save vnys/0c4821b1934ad8d0fb9d to your computer and use it in GitHub Desktop.
Save vnys/0c4821b1934ad8d0fb9d to your computer and use it in GitHub Desktop.
Make working with our newspapers less disruptive

Disable ad-loading for faster page loads:

  • ?ads=placeholder

Disable page reload so you don’t lose your console code

api.pageRefresh.clear()

Replace lowercase characters with the previous ascii character to make text unreadable

[].forEach.call(document.querySelectorAll('h1, h2, h3, p'), function(el){ el.textContent = el.textContent.replace(/([a-z])/g, function(m){ return String.fromCharCode(m.charCodeAt() - 1) } ) })

Replace all images with grey boxes

[].forEach.call(document.querySelectorAll('img'), function(img){ img.setAttribute('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'); img.style.backgroundColor = '#aaa' });

Remove script-tags

[].forEach.call(document.querySelectorAll('script, noscript'), function(script){ script.parentNode.removeChild(script) })

Remove all child elements from body except .apiMultifix

[].forEach.call(document.querySelectorAll('body > *:not(.apiMultifix)'), function(el){ el.parentNode.removeChild(el) })

Remove meta-tags except viewport

[].forEach.call(document.querySelectorAll('meta[property], meta[name]:not([name=viewport])') function(el){ el.parentNode.removeChild(el) })

Remove script-tags, all child elements from body except .apiMultifix, meta-tags except viewport and response

[].forEach.call(document.querySelectorAll('body > *:not(.apiMultifix), script, noscript, meta[property], meta[name]:not([name=viewport]), .response, .apiRecommendOrTweet'), function(script){ script.parentNode.removeChild(script) })

Point all links to #

[].forEach.call(document.querySelectorAll('a'), function(a){ a.setAttribute('href', '#' )})

Make adreplacement less intrusive

First load the page with ads=placeholder

[].forEach.call(document.querySelectorAll('.apiAdPlaceHolder'), function(ad){ ad.style.backgroundColor = '#aaa'; ad.style.color = '#666'; while(ad.childNodes.length > 0) { ad.removeChild(ad.firstChild) }; ad.innerText = 'annonse'  })
@vnys
Copy link
Author

vnys commented Oct 15, 2014

[].forEach.call(document.querySelectorAll('.apiPage img'), function(img){ img.setAttribute('src', 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'); img.style.backgroundColor = '#aaa' });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment