Skip to content

Instantly share code, notes, and snippets.

@maripo
Created August 29, 2012 11:55
Show Gist options
  • Save maripo/3511465 to your computer and use it in GitHub Desktop.
Save maripo/3511465 to your computer and use it in GitHub Desktop.
AndroidOrArduino AndroidとArduinoの空目を防止する
// ==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