Created
August 29, 2012 11:55
-
-
Save maripo/3511465 to your computer and use it in GitHub Desktop.
AndroidOrArduino AndroidとArduinoの空目を防止する
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 AndroidOrArduino | |
// @namespace org.maripo.neta | |
// @description AndroidとArduinoの空目を防止する | |
// @include * | |
// ==/UserScript== | |
(function () { | |
var STRING_ARDUINO = 'あるどぅいーの'; | |
var STRING_ANDROID = 'あんどろいど'; | |
var crawlTree = function (node){ | |
for (var index = 0, length=node.childNodes.length; index<length; index++) { | |
var item=node.childNodes[index]; | |
if ('\#text'==item.nodeName) { | |
if (item.data) { | |
item.data = item.data | |
.replace(new RegExp('arduino','ig'),function (all, matched){return ''+all+'('+STRING_ARDUINO+')'}) | |
.replace(new RegExp('android','ig'),function (all, matched){return ''+all+'('+STRING_ANDROID+')'}); | |
} | |
} else if ('TEXTAREA'!=item.nodeName && item.childNodes){ | |
crawlTree (item); | |
} | |
} | |
}; | |
crawlTree (document.body); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment