您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Simple userscript to replace "followers and follows" with an f2f ratio on bluesky
当前为
// ==UserScript== // @name Bluesky F2F Ratio // @description Simple userscript to replace "followers and follows" with an f2f ratio on bluesky // @version 1 // @match https://bsky.app/profile/* // @grant none // @license MIT // @namespace https://greasyfork.org/users/1453680 // ==/UserScript== // INSPIRED BY https://bsky.app/profile/jcsalterego.bsky.social/post/3llw7lwcios2q let textMult = function(s) { return(s.endsWith("M") ? 1.0e6 : s.endsWith("K") ? 1.0e3 : 1) } /** * Wait for an element before resolving a promise * @param {String} querySelector - Selector of element to wait for * @param {Integer} timeout - Milliseconds to wait before timing out, or 0 for no timeout */ function waitForElement(querySelector, timeout){ return new Promise((resolve, reject)=>{ var timer = false; if(document.querySelector(querySelector)) return resolve(); const observer = new MutationObserver(()=>{ if(document.querySelector(querySelector)){ observer.disconnect(); if(timer !== false) clearTimeout(timer); return resolve(); } }); observer.observe(document.body, { childList: true, subtree: true }); if(timeout) timer = setTimeout(()=>{ observer.disconnect(); reject(); }, timeout); }); } let followBarSelector = '.r-2llsf > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(3) > div:nth-child(1)'; waitForElement(followBarSelector, 3000).then(function(){ var followerEl = document.querySelector('a.css-146c3p1:nth-child(1) > span:nth-child(1)'); let followingEl = document.querySelector('a.css-146c3p1:nth-child(2) > span:nth-child(1)'); let followerText = followerEl.innerText.trim(); let followingText = followingEl.innerText.trim(); let followRatio = (parseFloat(followerText) * textMult(followerText) / parseFloat(followingText) * textMult(followingText)).toFixed(2); let followBar = document.querySelector(followBarSelector); followBar.firstChild.remove(); followBar.firstChild.firstChild.innerText = "" + followRatio + ":1 "; followBar.firstChild.lastChild.innerText = "f2f ratio" console.log(followRatio); }).catch(()=>{ alert("element did not load in 3 seconds"); });