您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add buttons to open Medium articles in Freedium and Archive.is, hide recommended articles and more from author, adjust story width and image sizes while preserving zoom, then scroll to top
当前为
// ==UserScript== // @name Enhanced Medium Redirect (Compressed) // @namespace http://tampermonkey.net/ // @version 0.3 // @description Add buttons to open Medium articles in Freedium and Archive.is, hide recommended articles and more from author, adjust story width and image sizes while preserving zoom, then scroll to top // @author 573dave (improved by Claude) // @match https://*.medium.com/* // @grant GM_addStyle // @run-at document-idle // @license MIT // ==/UserScript== (function() { 'use strict'; const debug = m => console.log(`[Medium Redirect Debug]: ${m}`); const scrollTop = () => window.scrollTo({top: 0, behavior: 'smooth'}); const hideElement = selector => { const el = document.querySelector(selector); if (el) { el.style.display = 'none'; debug(`Hidden: ${selector}`); return true; } return false; }; const hideRecommended = () => hideElement('#root > div > div.l.c > div:nth-child(2) > div.tj.tk.tl.tm.tn.l.bx > div:nth-child(4)'); const hideMoreFromAuthor = () => hideElement('#root > div > div.l.c > div:nth-child(2) > div.tj.tk.tl.tm.tn.l.bx > div:nth-child(2)'); const adjustStoryWidth = () => { GM_addStyle(` article, .story-body, .story-content, div.ci.bh.fz.ga.gb.gc { width: 100% !important; max-width: 1192px !important; margin-left: auto !important; margin-right: auto !important; padding-left: 20px !important; padding-right: 20px !important; } .story-body { box-sizing: border-box !important; } figure.paragraph-image { max-width: 500px !important; margin-left: auto !important; margin-right: auto !important; } figure.paragraph-image > div[role="button"] { max-width: 100% !important; } figure.paragraph-image > div[role="button"] > div { max-width: 100% !important; } `); debug('Story width and image size styles added'); }; const clickClose = () => ['button[data-testid="close-button"]', 'button[aria-label="close"]', '#root > div > div.l.c > div:nth-child(2) > div.m.uy.uz.va > div > div > div > div.am.l.fs.vp.vq > div.h.k > div > button'].some(s => { const b = document.querySelector(s); if (b) { b.click(); debug('Close button clicked'); return true; } return false; }) || (debug('No close button found'), false); const addButtons = () => { if (document.querySelector('.medium-redirect-buttons')) return; const c = document.createElement('div'); c.className = 'medium-redirect-buttons'; c.style.cssText = 'position:fixed;top:10px;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:10px;z-index:10000;background:white;padding:5px;border-radius:5px;box-shadow:0 2px 5px rgba(0,0,0,0.2);'; const bStyle = 'font-size:14px;padding:5px 10px;background-color:#FFC017;color:black;border:none;border-radius:5px;cursor:pointer;'; c.innerHTML = '<span style="font-size:14px;font-weight:bold;">Load with:</span>'; ['Freedium', 'Archive.is'].forEach(t => { const b = document.createElement('button'); b.textContent = t; b.style.cssText = bStyle; b.onclick = () => { window.open(`https://${t.toLowerCase() === 'freedium' ? 'freedium.cfd/' : 'archive.is/'}${window.location.href}`, '_blank'); }; c.appendChild(b); }); document.body.appendChild(c); debug('Redirect buttons added'); }; const handle = () => { debug('Checking for paywall...'); if (clickClose()) { setTimeout(() => { if (!clickClose()) { addButtons(); hideRecommended(); hideMoreFromAuthor(); adjustStoryWidth(); scrollTop(); } }, 1000); } else { addButtons(); hideRecommended(); hideMoreFromAuthor(); adjustStoryWidth(); scrollTop(); } }; new MutationObserver(ms => ms.some(m => m.addedNodes.length && (debug('DOM mutation detected, rechecking...'), handle(), true))).observe(document.body, { childList: true, subtree: true }); debug('Script started'); handle(); })();