Skip to content

Instantly share code, notes, and snippets.

@intellectronica
Created October 25, 2024 13:20
Show Gist options
  • Save intellectronica/5316e9f3477bbf3347e7d2a40a5982de to your computer and use it in GitHub Desktop.
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
// ==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