PO18 Filter

Hide books in index search results based on specified keywords, authors, and tags.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         PO18 Filter
// @description  Hide books in index search results based on specified keywords, authors, and tags.
// @version      1.0
// @author       null
// @match        https://www.po18.tw/findbooks/*
// @grant        none
// @license      MIT
// @namespace https://greasyfork.org/users/1272411
// ==/UserScript==

(function () {
  "use strict";

  const KEYWORDS = [
    /标题关键词1/i,
    /标题关键词2/i,
    /标题关键词3/i,
  ];
  const AUTHORS = [
    /作者关键词1/i,
    /作者关键词2/i,
    /作者关键词3/i,
  ];
  const TAGS = [
    /标签关键词1/i,
    /标签关键词2/i,
    /标签关键词3/i,
  ];

  function hideRowsByCriteria() {
    const rows = document.querySelectorAll(".row");
    rows.forEach((row) => {
      const textContent = row.textContent || row.innerText;
      const shouldHide =
        KEYWORDS.some((keyword) => keyword.test(textContent)) ||
        AUTHORS.some((author) => author.test(textContent)) ||
        TAGS.some((tag) => tag.test(textContent));

      if (shouldHide) {
        row.style.display = "none";
      }
    });
  }

  function observeDOMChanges() {
    const observer = new MutationObserver((mutations) => {
      mutations.forEach((mutation) => {
        if (mutation.addedNodes.length || mutation.removedNodes.length) {
          hideRowsByCriteria();
        }
      });
    });

    const config = { childList: true, subtree: true };
    const targetNode = document.querySelector("body");
    if (targetNode) {
      observer.observe(targetNode, config);
    } else {
      console.error("Failed to find the target node.");
    }
  }

  window.addEventListener("load", () => {
    hideRowsByCriteria();
    observeDOMChanges();
  });
})();