您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Removes /gallery/ from old.reddit.com links and redirects to valid link.
// ==UserScript== // @name OLD REDDIT GALLERY REDIRECT // @version 1.0 // @description Removes /gallery/ from old.reddit.com links and redirects to valid link. // @author minnie // @match https://old.reddit.com/gallery/* // @grant none // @run-at document-start // @license MIT // @namespace https://greasyfork.org/users/1101475 // ==/UserScript== /** * Updates the URL by removing "/gallery/" from the path. * @param {string} url - The URL to update. * @returns {string} - The updated URL without "/gallery/". */ function removeGallery(url) { try { const target = new URL(url); // Remove "/gallery/" from the path if (target.pathname.includes('/gallery/')) { target.pathname = target.pathname.replace('/gallery/', '/'); return target.href; } return url; } catch (e) { console.error('Error processing URL:', e); return url; // Return original URL on failure } } // Immediately process and redirect if necessary (function() { const currentUrl = window.location.href; const updatedUrl = removeGallery(currentUrl); // Redirect if the URL was changed if (updatedUrl !== currentUrl) { window.location.assign(updatedUrl); } })();