Skip to content

Instantly share code, notes, and snippets.

@yoozoosato
Created January 11, 2012 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoozoosato/1592371 to your computer and use it in GitHub Desktop.
Save yoozoosato/1592371 to your computer and use it in GitHub Desktop.
全角英数字記号を半角英数字記号に変換するグリモンスクリプト
// ==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