Created
October 25, 2024 13:20
-
-
Save intellectronica/5316e9f3477bbf3347e7d2a40a5982de to your computer and use it in GitHub Desktop.
Userscript (for running with your monkey extension of choice) to redirect paywalled site articles to their archive.ph copy
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
// ==UserScript== | |
// @name redirect-to-archive-ph | |
// @match *://*/* | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
if (window.location.href.includes('archive.ph')) return; | |
const websites = [ | |
'bloomberg.com', | |
'nytimes.com', | |
'wsj.com', | |
'washingtonpost.com', | |
]; | |
function isTargetUrl(url) { | |
for (const website of websites) { | |
if (url.includes(website) && url.length > 50) return true; | |
} | |
return false; | |
} | |
if (isTargetUrl(window.location.href)) { | |
window.location.replace( | |
`https://archive.ph/${window.location.href.split('?')[0]}` | |
); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment