Skip to content

Instantly share code, notes, and snippets.

@canweriotnow
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canweriotnow/35dfabb8552e68f406f9 to your computer and use it in GitHub Desktop.
Save canweriotnow/35dfabb8552e68f406f9 to your computer and use it in GitHub Desktop.
Sun Paywall Defeater
// Alternately, a bookmarklet using the Sun's jQuery dependency against it:
// If you don't know what to do with this, create a new bookmark in your browser
// and paste this line as teh "address."
javascript:$("#reg-overlay").remove();$("html,body").css("overflow","visible");
/* Userscript for Tampermonkey or Greasemonkey to skip the paywall on the
* Baltimore Sun website
*/
// ==UserScript==
// @name Sun Paywall Defeater
// @namespace http://decomplecting.org
// @version 0.2
// @description Get rid of the paywall on The Baltimore Sun's website
// @author Jason Lewis
// @match *://*.baltimoresun.com/*
// @grant none
// ==/UserScript==
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.addedNodes) {
Array.prototype.forEach.call(mutation.addedNodes, function(node) {
if (node.id == "reg-overlay") {
node.parentNode.removeChild(node); // Fix for when body is not the parent node
document.body.style.overflow = "visible";
document.body.parentNode.style.overflow = "visible";
}
});
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true,
attributes: true,
characterData: false
});
@canweriotnow
Copy link
Author

Issues at the moment: scrolling through additional stories is a little buggy, as something in the UX code relies on detecting the offsetHeight (I'm pretty sure for article count to throw up another paywall... it would explain both errrors here:

(anonymous function) @ VM7931:24(anonymous function) @ VM7931:22(anonymous function) @ VM7931:20
baltngux.min.js:2 
Uncaught TypeError: Cannot read property 'offsetHeight' of undefinedn @ baltngux.min.js:2
VM7931:24 
Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

@canweriotnow
Copy link
Author

Also DISCLAIMER NOTICE: something something this is an academic exercise and should never be used by anyone I would certainly never use it because DMCA something something something about the dark side.

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