Fullwidth Letter Fixer

Replaces fullwidth letters with ASCII equivalents, making pages a bit more searchable

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          Fullwidth Letter Fixer
// @namespace     DoomTay
// @description   Replaces fullwidth letters with ASCII equivalents, making pages a bit more searchable
// @version       1.0.4
// @include       *
// @exclude       *.svg
// @grant         none

// ==/UserScript==

function replaceText(node) {
	if(node == null) return;
	var nodes = node.childNodes;
	for (var n=0; n<nodes.length; n++) {
		if(nodes[n].nodeType == Node.TEXT_NODE)
		{
			nodes[n].textContent = nodes[n].textContent.replace(/[\uFF01-\uFF5E]/g, function(char) {
			  return String.fromCharCode(char.charCodeAt(0) - 0xFF01 + 0x21);
			});
		}
		//Nothing left to do here. Look at the children of this node
		replaceText(nodes[n]);
	}
}

replaceText(document.body);