Skip to content

Instantly share code, notes, and snippets.

@maripo
Created August 1, 2012 12:19
Show Gist options
  • Save maripo/3226374 to your computer and use it in GitHub Desktop.
Save maripo/3226374 to your computer and use it in GitHub Desktop.
Render Latin Wikipedia (VICIPAEDIA LATINA) in classical Latin style
// ==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