Skip to content

Instantly share code, notes, and snippets.

@maripo
Created August 29, 2012 12:01
Show Gist options
  • Save maripo/3511524 to your computer and use it in GitHub Desktop.
Save maripo/3511524 to your computer and use it in GitHub Desktop.
LifelogOrLaphroaig (ライフログとラフロイグの空目を防止する)
// ==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