Created
August 29, 2012 12:01
-
-
Save maripo/3511524 to your computer and use it in GitHub Desktop.
LifelogOrLaphroaig (ライフログとラフロイグの空目を防止する)
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 LifelogOrLaphroaig | |
// @namespace org.maripo.neta | |
// @description ライフログとラフロイグの空目を防止する | |
// @include * | |
// ==/UserScript== | |
(function () { | |
var STRING_LIFELOG = 'Lifelog'; | |
var STRING_LAPHROAIG = 'Laphroaig'; | |
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('ライフログ','ig'),function (all, matched){return ''+all+'('+STRING_LIFELOG+')'}) | |
.replace(new RegExp('ラフロイグ','ig'),function (all, matched){return ''+all+'('+STRING_LAPHROAIG+')'}); | |
} | |
} 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