您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Replace main links from home subreddits to threads directly rather than posts(Images,other websites etc.)
当前为
// ==UserScript== // @name Old Reddit Open Thread Instead of Post // @namespace http://tampermonkey.net/ // @version 1.0 // @description Replace main links from home subreddits to threads directly rather than posts(Images,other websites etc.) // @author Berkay // @match https://old.reddit.com/r/* // @match https://www.reddit.com/r/* // @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com // @grant none // @license MIT // ==/UserScript== (function() { // Get comment/thread links const links2 = document.getElementsByTagName('a'); const linksArray = Array.from(links2); const commentLinks = linksArray.filter(link => { const eventAction = link.getAttribute('data-event-action'); return eventAction === 'comments'; }); // Function to replace post links with comment/thread links function replacePostLinks() { const links = document.querySelectorAll('a[data-event-action="title"]'); for (let i = 0; i < links.length; i++) { const href = links[i].getAttribute('href'); // Check if the href attribute is a valid URL if (href && href.startsWith('http')) { try { const url = new URL(href); links[i].setAttribute('href', commentLinks[i]); } catch (e) { // If the URL is invalid, log the error (or handle it accordingly) console.error(`Invalid URL: ${href}`, e); } } } } // Run the function when the page loads window.addEventListener('load', replacePostLinks); })()