// ==UserScript== // @name Medium Redirect // @namespace http://tampermonkey.net/ // @version 0.2 // @description Redirect Medium links to Archive.is // @author 573dave (all code written by ChatGPT 4) // @match https://*.medium.com/* // @grant none // @run-at document-end // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Function to check if an article is incomplete function isArticleIncomplete() { // Find button with specific classes let memberOnlyButton = document.querySelector('button.l.ax.ao.am'); // Check if the button exists and contains the "Member-only story" text if (memberOnlyButton) { let memberOnlyText = memberOnlyButton.querySelector('p.be.b.bf.z.dt'); if (memberOnlyText && memberOnlyText.textContent.includes('Member-only story')) { return true; } } return false; } // Function to add a redirect button function addRedirectButton() { let redirectButton = document.createElement('button'); redirectButton.textContent = 'Article incomplete. Try archive.is?'; redirectButton.style.position = 'fixed'; redirectButton.style.top = '10px'; redirectButton.style.left = '50%'; redirectButton.style.transform = 'translateX(-50%)'; redirectButton.style.fontSize = '16px'; redirectButton.style.padding = '10px 20px'; redirectButton.style.backgroundColor = '#FFC017'; redirectButton.style.color = 'black'; redirectButton.style.border = 'none'; redirectButton.style.borderRadius = '5px'; redirectButton.style.cursor = 'pointer'; redirectButton.style.zIndex = '1000'; redirectButton.addEventListener('click', function() { let archiveURL = 'https://archive.is/' + window.location.href; window.location.href = archiveURL; }); document.body.appendChild(redirectButton); } // Check if the article is incomplete and add a redirect button if (isArticleIncomplete()) { addRedirectButton(); } })();