Last active
November 20, 2019 15:09
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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