Created
August 1, 2012 12:19
-
-
Save maripo/3226374 to your computer and use it in GitHub Desktop.
Render Latin Wikipedia (VICIPAEDIA LATINA) in classical Latin style
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 VICIPAEDIA LATINA | |
// @namespace maripo.org | |
// @include http://la.wikipedia.org/wiki/* | |
// @version 1 | |
// ==/UserScript== | |
(function () { | |
document.body.style.fontFamily = "'Trajan Pro','Trajan','Serif'"; | |
var REPLACE_CHARS = [ | |
// ['G','C'], | |
['J','I'], | |
['U','V'], | |
['W','V'] | |
]; | |
var REPLACE_REGEXPS = []; | |
for (var i=0; i<REPLACE_CHARS.length; i++) { | |
REPLACE_REGEXPS.push(new RegExp(REPLACE_CHARS[i][0],"g")); | |
} | |
var scanTree = 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) { | |
var str = item.data.toUpperCase(); | |
for (var regexIndex = 0; regexIndex<REPLACE_REGEXPS.length; regexIndex++) { | |
str = str.replace(REPLACE_REGEXPS[regexIndex], REPLACE_CHARS[regexIndex][1]); | |
} | |
item.data = str; | |
} | |
} else if ('TEXTAREA'!=item.nodeName && item.childNodes){ | |
scanTree (item); | |
} | |
} | |
}; | |
scanTree (document.body); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment