Greasy Fork

Greasy Fork is available in English.

AO3: No Re-Kudos

Hide kudos button if you've already left kudos.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AO3: No Re-Kudos
// @version      1.1
// @author       BlackBatCat
// @description  Hide kudos button if you've already left kudos.
// @license      MIT
// @match        *://archiveofourown.org/works/*
// @match        *://archiveofourown.org/chapters/*
// @grant        none
// @namespace http://greasyfork.icu/users/1498004
// ==/UserScript==

(function () {
  "use strict";

  // Get work ID from the kudos form (not URL, since chapter IDs differ from work IDs)
  const kudoButton = document.getElementById("kudo_submit");
  if (!kudoButton) return;

  const workIdInput = document.getElementById("kudo_commentable_id");
  if (!workIdInput) return;

  const workId = workIdInput.value;
  if (!workId) return;

  // Check if we've already given kudos to this work
  const kudosHistory = JSON.parse(
    localStorage.getItem("ao3_no_rekudos_config") || "{}"
  );

  if (kudosHistory[workId]) {
    // Hide the kudos button immediately
    kudoButton.style.display = "none";
  } else {
    // Set up click listener to record when kudos is given
    kudoButton.addEventListener("click", function () {
      // Record that we've given kudos to this work
      const kudosHistory = JSON.parse(
        localStorage.getItem("ao3_no_rekudos_config") || "{}"
      );
      kudosHistory[workId] = true;
      localStorage.setItem(
        "ao3_no_rekudos_config",
        JSON.stringify(kudosHistory)
      );

      // Hide the button
      this.style.display = "none";
    });
  }
})();