您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Fix opening redd.it image links on Old Reddit
当前为
// ==UserScript== // @name Fix image links on Old Reddit // @namespace https://github.com/fxolan // @version 1.0 // @description Fix opening redd.it image links on Old Reddit // @author Abdurazaaq Mohammed // @homepage https://github.com/fxolan/userscripts // @license The Unlicense // @supportURL https://github.com/fxolan/userscripts/issues // @match https://old.reddit.com/* // @match https://fxolan.github.io/website/imgviewer // @grant GM_getValue // @grant GM_setValue // ==/UserScript== (function () { 'use strict'; const url = window.location.href; function openImageViewer(imgLink) { GM_setValue('img', imgLink); // Uncomment below and comment/delete the other line if you want to redirect to the image directly instead of opening in a new tab. //window.location.href = 'https://fxolan.github.io/website/imgviewer'; window.open('https://fxolan.github.io/website/imgviewer'); } function fixImageLinks(mutationsList, observer) { const imageLinks = document.querySelectorAll('a[href^="https://preview.redd.it"], a[href^="https://i.redd.it"]'); imageLinks.forEach(link => { const imgLink = link.href; // Overwriting the href will break copying the image link link.removeAttribute("href"); link.addEventListener("click", function() { openImageViewer(imgLink); }); }); } if (url.startsWith('https://old.reddit.com/')) { const observer = new MutationObserver(fixImageLinks); observer.observe(document.body, { subtree: true, childList: true }); } else { document.getElementById('urlInput').value = GM_getValue('img'); document.getElementById('displayButton').click(); } })();