您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
On a Reddit post page, show upvote_ratio (%) as a tooltip on the post title.
// ==UserScript== // @name Reddit Title Upvote Ratio Tooltip // @namespace https://greasyfork.org/en/users/1479408 // @license MIT // @version 1.0 // @description On a Reddit post page, show upvote_ratio (%) as a tooltip on the post title. // @match https://www.reddit.com/*/*/comments/* // @grant GM.xmlHttpRequest // @connect reddit.com // @run-at document-idle // ==/UserScript== (function() { 'use strict'; // Run once on page load const titleEl = document.querySelector('h1[id^="post-title-t3_"]'); if (!titleEl) return; // Extract the base‑36 post ID from the element's id attribute const [, postId] = titleEl.id.split('t3_'); if (!postId) return; // Fetch JSON and set tooltip to upvote_ratio × 100 GM.xmlHttpRequest({ method: "GET", url: `https://www.reddit.com/comments/${postId}.json?raw_json=1`, responseType: 'json', onload: resp => { try { const ratio = resp.response[0].data.children[0].data.upvote_ratio; titleEl.title = ratio != null ? `${(ratio * 100).toFixed(1)}%` : 'N/A'; } catch (e) { console.error('TitleUpPctTooltip error', e); } } }); })();