Skip to content

Instantly share code, notes, and snippets.

@carlosabalde
Last active November 20, 2019 15:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosabalde/6139924 to your computer and use it in GitHub Desktop.
Save carlosabalde/6139924 to your computer and use it in GitHub Desktop.
Simple bookmarklet to flush the state of the New York Times metered paywall. Once the 10 articles per month limit is reached and the subscription popup raises, simply click on the bookmarklet. Your metering quota will be reset to 0 and the current page reloaded to show the full article. Check out comments in the code for further details.
javascript:(function() {
if (window.location.host.match(/nytimes.com$/)) {
/* Flush all cookies. */
var cookies, subdomain, pathname;
cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
subdomain = '.' + window.location.host;
while (subdomain) {
pathname = window.location.pathname;
while (pathname) {
document.cookie=(
cookies[i] +
'; domain=' + subdomain +
'; path=' + pathname +
'; expires=Thu, 01 Jan 1970 00:00:01 GMT;');
pathname = pathname.replace(/.$/, '')
}
subdomain = subdomain.replace(/^(?:\.|[^\.]+)/, '');
}
}
/* Flush local storage. */
try {
localStorage.clear();
} catch (e) { }
/* Flush backup of the metering cookie. */
window.name = null;
/* Reload current page stripping the query string. */
window.location = window.location.href.split('?')[0];
} else {
alert('Please, use this bookmarklet only in the nytimes.com domain.');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment