您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
4/1/2025, 12:09:44 PM
当前为
// ==UserScript== // @name Rewrite reddit links to use the Narwhal 2 URI scheme // @namespace codes.heals.violentmonkey.narwhal2-opener // @match https://*/* // @require https://update.greasyfork.org/scripts/446257/1059316/waitForKeyElements%20utility%20function.js // @grant GM_addStyle // @unwrap // @version 1.0 // @author HealsCodes // @description 4/1/2025, 12:09:44 PM // @license GPL3 // ==/UserScript== function updatePageLinks(element) { 'use strict'; // Function to extract the original URL and redirect to Narwhal function redirectToNarwhal(link) { var originalUrl = link.href; var originalTextContent = link.textContent; if (originalUrl.startsWith('narwhal://')) { // already processed return; } for(const prefix of ['https://reddit.com', 'https://m.reddit.com', 'https://www.reddit.com', 'https://reddit.app.link']) { if (originalUrl.startsWith(prefix)) { var encodedUrl = encodeURIComponent(originalUrl); Object.assign(link, { textContent: originalTextContent + ' ' + String.fromCodePoint(0x1f433), href: 'narwhal://open-url/' + encodedUrl }); return; } } } if (element !== undefined) { redirectToNarwhal(element); } else { document.querySelectorAll(`a[href*="reddit."]`).forEach(link => redirectToNarwhal(link)); } } (function () { // run on ajax updates waitForKeyElements(`a[href*="reddit."]`, (element) => updatePageLinks(), false); // run on initial page load document.updatePageLinks(undefined); })();