全给我变成小南娘!

变!

目前為 2024-08-21 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         全给我变成小南娘!
// @namespace    https://penyo.ru/
// @version      1.0.4
// @description  变!
// @author       Penyo
// @match        *://*/*
// @exclude      *://greasyfork.org/*
// @grant        none
// @license      WTFPL
// ==/UserScript==

(function () {
  "use strict";

  const elementToMatch = [
    "title",
    "h1",
    "h2",
    "h3",
    "h4",
    "h5",
    "h6",
    "p",
    "article",
    "section",
    "blockquote",
    "li",
    "a",
  ];

  /**
   * @param {Element} root
   */
  function replace(root) {
    const orophilia = () => (Math.random() < 0.33 ? "です" : "");

    requestIdleCallback(() => {
      root
        .querySelectorAll(
          elementToMatch
            .concat(elementToMatch.map((name) => name + " *"))
            .join(",")
        )
        .forEach((candidate) => {
          if (
            candidate.textContent &&
            candidate.textContent == candidate.innerHTML
          ) {
            candidate.textContent = candidate.textContent
              .replace(/我们/g, "咱喵和其它猫猫们")
              .replace(/大家/g, "各位猫猫们")
              .replace(/(?!自|本)我/g, "咱喵")
              .replace(/你们/g, "汝等")
              .replace(/你|您/g, "汝")
              .replace(/(?!每|个)人(?!类|民)/g, "顺÷")
              .replace(/恋爱|溜冰|爆改|白嫖|游戏|神金/, "援交")
              .replace(
                /([也矣兮乎者焉哉]|[啊吗呢吧哇呀哦嘛])([ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~\u3000-\u303F\uFF00-\uFFEF]|$)/g,
                (_, $1, $2) => `喵${orophilia()}${$2}`
              )
              .replace(
                /([的了辣])([!"#$%&'()*+,-./:;/,=>?@[\]^_`{|}~\u3000-\u303F\uFF00-\uFFEF]|\s+(?!<|\w)|$)/g,
                (_, $1, $2) => `${$1}喵${orophilia()}${$2}`
              );
          }
        });
    });
  }

  /**
   * @param {Element} root
   */
  async function afterDomLoaded(root) {
    if (!root) return;

    const fn = () => {
      replace(root);

      root.querySelectorAll("*").forEach(async (node) => {
        if (node.shadowRoot) {
          await afterDomLoaded(node.shadowRoot);
        }
      });
    };

    while (document.readyState == "loading") {
      await new Promise((r) => setTimeout(r, 1000));
    }
    fn();
  }

  afterDomLoaded(document);
  setInterval(() => afterDomLoaded(document), 2500);
})();