您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
On MetaFilter.com, adds a "comment 1 of 30" to each comment.
当前为
// ==UserScript== // @name MetaFilter number all comments // @version 9 // @grant none // @match http://*.metafilter.com/* // @match https://*.metafilter.com/* // @description On MetaFilter.com, adds a "comment 1 of 30" to each comment. // @locale en-us // @run-at document-idle // @namespace https://gf.qytechs.cn/users/324881 // ==/UserScript== function addCountToComments() { // first, clear all counts in case this runs more than once on a page. let allCommentCountSpans = Array.from(document.getElementsByClassName('tehhundUserScriptCommentCount')); for (let currentSpan of allCommentCountSpans) { currentSpan.remove(); } // then add counts to every comment div. let allCommentDivs = document.getElementsByClassName('comments'); allCommentDivs = Array.from(allCommentDivs).filter( function(div) { return div.previousSibling.tagName == 'A'; }); for (let [i,divToHighlight] of allCommentDivs.entries()) { divToHighlight.lastChild.innerHTML += '<span class=\'tehhundUserScriptCommentCount\'>Comment ' + (i+1) + ' of ' + allCommentDivs.length + '. </span>'; } } // Observe the main content div for changes such as new comments and run addCountToComments() again. // Temporarily removing due to performance issues. Will reenable if I can find a performant way to do this. // const mutationObserver = new MutationObserver(addCountToComments); // mutationObserver.observe(document.getElementById('posts'), { attributes: true, childList: true, subtree: true }) // Attach event listeners window.addEventListener('load',addCountToComments); // In case this script runs before the window load event, highlight when that event fires. addCountToComments(); // In case this script runs after the window load event, highlight as soon as Greasemonkey runs the script.
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址