-
-
Save yoozoosato/1592371 to your computer and use it in GitHub Desktop.
全角英数字記号を半角英数字記号に変換するグリモンスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name z2h | |
// @namespace http://somethingnew2.com/js/monkeys/ | |
// @description 全角英数字を半角に変換するよ | |
// @author SATO Yozo | |
// @version 0.1 | |
// ==/UserScript== | |
(function() { | |
var z = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@-.,:'; | |
var h = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@-.,:'; | |
function z2h(arg) { | |
if (arg.nodeType === 1) { | |
for (var i = 0; i < arg.childNodes.length; ++i) { | |
z2h(arg.childNodes[i]); | |
} | |
} else if (arg.nodeType === 3) { | |
for (i = 0; i < z.length; i++) { | |
var regex = new RegExp(z[i], "gm"); | |
arg.nodeValue = arg.nodeValue.replace(regex, h[i]); | |
} | |
} | |
} | |
z2h(document.body); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment