Shift-JIS Letter Fixer

Replaces Shift-JIS encoded Latin letters with Unicode equivalents, making pages a bit more searchable

当前为 2016-01-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          Shift-JIS Letter Fixer
// @namespace     DoomTay
// @description   Replaces Shift-JIS encoded Latin letters with Unicode equivalents, making pages a bit more searchable
// @version       1.0.1
// @grant         none

// ==/UserScript==

var replacementTable = [
	["A","A"],
	["B","B"],
	["C","C"],
	["D","D"],
	["E","E"],
	["F","F"],
	["G","G"],
	["H","H"],
	["I","I"],
	["J","J"],
	["K","K"],
	["L","L"],
	["M","M"],
	["N","N"],
	["O","O"],
	["P","P"],
	["Q","Q"],
	["R","R"],
	["S","S"],
	["T","T"],
	["U","U"],
	["V","V"],
	["W","W"],
	["X","X"],
	["Y","Y"],
	["Z","Z"],
	["a","a"],
	["b","b"],
	["c","c"],
	["d","d"],
	["e","e"],
	["f","f"],
	["g","g"],
	["h","h"],
	["i","i"],
	["j","j"],
	["k","k"],
	["l","l"],
	["m","m"],
	["n","n"],
	["o","o"],
	["p","p"],
	["q","q"],
	["r","r"],
	["s","s"],
	["t","t"],
	["u","u"],
	["v","v"],
	["w","w"],
	["x","x"],
	["y","y"],
	["z","z"],
	["0","0"],
	["1","1"],
	["2","2"],
	["3","3"],
	["4","4"],
	["5","5"],
	["6","6"],
	["7","7"],
	["8","8"],
	["9","9"]
	];
	
function replaceText(node, scan, replacement) {
	var nodes = node.childNodes;
	for (var n=0; n<nodes.length; n++) {				
		if(nodes[n].nodeType == Node.TEXT_NODE && nodes[n].textContent.trim().indexOf(scan) > -1)
		{
			while(nodes[n].textContent.indexOf(scan) > -1) nodes[n].textContent = nodes[n].textContent.replace(scan,replacement);
		}
		
		//Nothing in this node. Look at the children of this node.
		else
		{
			replaceText(nodes[n],scan,replacement);
		}
	}
}

for(var i = 0; i < replacementTable.length; i++)
{
	replaceText(document.body,replacementTable[i][0], replacementTable[i][1]);
}