Wikipedia Anarchy Hack

Fun with Wikipedia.org, appealing for 'Ⓐnarchy!!'' on every 'A'

当前为 2022-12-10 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          Wikipedia Anarchy Hack
// @namespace     greasyfork
// @description	  Fun with Wikipedia.org, appealing for 'Ⓐnarchy!!'' on every 'A'
// @author        Noudio
// @license       MIT
// @homepage      -
// @include       http://wikipedia.org/*
// @include       https://wikipedia.org/*
// @include       http://*.wikipedia.org/*
// @include       https://*.wikipedia.org/*
// @include       http://wikimedia.org/*
// @include       https://wikimedia.org/*
// @include       http://*.wikimedia.org/*
// @include       https://*.wikimedia.org/*
// @run-at        document-idle
// @version       1.1
// ==/UserScript==
(function() {

    function isDomain(x) {
        return document.domain.substring(document.domain.indexOf(x)) == x;
    }
    var isPedia = isDomain("wikipedia.org");
    var isMedia = isDomain("wikimedia.org");
    if (!isPedia && !isMedia)
        return;

    // console.log('anarchy1!');

    function doSomething(element) {
      exclNr = Math.floor(Math.random()*4.0);
      element.nodeValue = element.nodeValue.replace(/A([A-Za-z]*)/g,
                                      function(a,b){
                                                      if (b != '') return "Ⓐ"+b+" - Ⓐnarchy"+"!".repeat(exclNr)+" -";
                                                      return "Ⓐ";
                                                    });
      // console.log('anarchy el:'+element.nodeValue);
    }

    function recurse(element)
    {
        if (element.childNodes.length > 0)
            for (var i = 0; i < element.childNodes.length; i++)
                recurse(element.childNodes[i]);

        // do only something for capital letters A
        if (element.nodeType == Node.TEXT_NODE && /A/.test(element.nodeValue))
            doSomething(element);
    }
    var nodeBody = document.body;
    recurse(nodeBody);

})();
//Taf!