Bluesky - Remove Zeroes from Buttons

Hides the number 0 for the Reply, Repost and Like buttons.

当前为 2023-10-29 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Bluesky - Remove Zeroes from Buttons
// @author      @thissteveguy.bsky.app
// @version     23.10.20
// @description Hides the number 0 for the Reply, Repost and Like buttons.
// @namespace   https://greasyfork.org/en/users/253-lednerg
// @license     (CC) Attribution Non-Commercial Share Alike; http://creativecommons.org/licenses/by-nc-sa/3.0/
// @match       *://bsky.app/*
// @grant       GM_addStyle
// ==/UserScript==

// For Replies and Likes, we're able to just use simple CSS to detect and hide zeroes.
GM_addStyle(`
  button[aria-label="Reply (0 replies)"] div,
  button[aria-label="Like (0 likes)"] div {
    opacity: 0 !important;
  }
`);

// For Reposts, we have to use a little JavaScript.
function hideZeroReposts() {
  const repostCounts = document.querySelectorAll('[data-testid="repostCount"]');
  repostCounts.forEach((element) => {
    if (element.textContent.trim() === "0") {
      element.style.opacity = "0";
    }
  });
}

// Run the function initially
hideZeroReposts();

// Run the function when the DOM changes
const observer = new MutationObserver(hideZeroReposts);
observer.observe(document.body, { childList: true, subtree: true });