MouseHunt - Gifting Buttons

Adds buttons to easily ignore/accept/return all gifts

目前为 2019-01-11 提交的版本。查看 最新版本

// ==UserScript==
// @name         MouseHunt - Gifting Buttons
// @author       Tran Situ (tsitu)
// @namespace    https://gf.qytechs.cn/en/users/232363-tsitu
// @version      1.0
// @description  Adds buttons to easily ignore/accept/return all gifts
// @match        http://www.mousehuntgame.com/*
// @match        https://www.mousehuntgame.com/*
// ==/UserScript==

(function() {
  document
    .getElementById("hgbar_freegifts")
    .addEventListener("click", function() {
      // 'Show Gifts'
      MutationObserver =
        window.MutationObserver ||
        window.WebKitMutationObserver ||
        window.MozMutationObserver;

      const observer = new MutationObserver(function(mutations, observer) {
        // Callback
        for (let record of mutations) {
          for (let node of record.removedNodes) {
            if (node.id === "giftSelectorView-inbox") {
              // Only render if gift inbox has been expanded
              if (
                document.getElementsByClassName("giftSelectorView").length > 0
              ) {
                buildUI();
                break;
              }
            }
          }
        }
        observer.disconnect();
      });

      observer.observe(document.querySelector("#overlayContainer"), {
        childList: true
      });

      function buildUI() {
        // 'View More Gifts'
        const ignoreAllButton = document.createElement("button");
        ignoreAllButton.innerText = "Ignore All";
        ignoreAllButton.addEventListener("click", function() {
          const rows = document.getElementsByClassName(
            "giftSelectorView-friendRow-actionContainer"
          );
          for (let row of rows) {
            const button = row.querySelectorAll(
              ".giftSelectorView-friendRow-action.ignore:not(.selected):not(.disabled)"
            )[0];
            if (button) button.click();
          }
        });

        const unignoreAllButton = document.createElement("button");
        unignoreAllButton.innerText = "↩️";
        unignoreAllButton.addEventListener("click", function() {
          const rows = document.getElementsByClassName(
            "giftSelectorView-friendRow-actionContainer"
          );
          for (let row of rows) {
            const button = row.querySelectorAll(
              ".giftSelectorView-friendRow-action.ignore.selected"
            )[0];
            if (button) button.click();
          }
        });

        const acceptAllButton = document.createElement("button");
        acceptAllButton.innerText = "Accept All";
        acceptAllButton.addEventListener("click", function() {
          const rows = document.getElementsByClassName(
            "giftSelectorView-friendRow-actionContainer"
          );
          for (let row of rows) {
            const button = row.querySelectorAll(
              ".giftSelectorView-friendRow-action.claim:not(.selected):not(.disabled)"
            )[0];
            if (button) button.click();
          }
        });

        const unacceptAllButton = document.createElement("button");
        unacceptAllButton.innerText = "↩️";
        unacceptAllButton.addEventListener("click", function() {
          const rows = document.getElementsByClassName(
            "giftSelectorView-friendRow-actionContainer"
          );
          for (let row of rows) {
            const button = row.querySelectorAll(
              ".giftSelectorView-friendRow-action.claim.selected"
            )[0];
            if (button) button.click();
          }
        });

        const returnAllButton = document.createElement("button");
        returnAllButton.innerText = "Return All";
        returnAllButton.addEventListener("click", function() {
          const rows = document.getElementsByClassName(
            "giftSelectorView-friendRow-actionContainer"
          );
          for (let row of rows) {
            const button = row.querySelectorAll(
              ".giftSelectorView-friendRow-action.return:not(.selected):not(.disabled)"
            )[0];
            if (button) button.click();
          }
        });

        const unreturnAllButton = document.createElement("button");
        unreturnAllButton.innerText = "↩️";
        unreturnAllButton.addEventListener("click", function() {
          const rows = document.getElementsByClassName(
            "giftSelectorView-friendRow-actionContainer"
          );
          for (let row of rows) {
            const button = row.querySelectorAll(
              ".giftSelectorView-friendRow-action.return.selected"
            )[0];
            if (button) button.click();
          }
        });

        const container = document
          .getElementsByClassName(
            "giftSelectorView-tabContent selectClaimableGift"
          )[0]
          .getElementsByClassName("giftSelectorView-actionContainer")[0];

        const buttonSpan = document.createElement("span");
        buttonSpan.style.cssFloat = "left";

        buttonSpan.appendChild(ignoreAllButton);
        buttonSpan.appendChild(unignoreAllButton);
        buttonSpan.appendChild(document.createTextNode("\u00A0\u00A0"));
        buttonSpan.appendChild(acceptAllButton);
        buttonSpan.appendChild(unacceptAllButton);
        buttonSpan.appendChild(document.createTextNode("\u00A0\u00A0"));
        buttonSpan.appendChild(returnAllButton);
        buttonSpan.appendChild(unreturnAllButton);
        container.appendChild(buttonSpan);
      }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址