MediaWiki:Gadget-vultus.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
// This script changes all occurrences of one letter (combination)
// to another letter (combination).
//
// This only affects the following namespaces:
// the main namespace, the Categoria: namespace, and the Porta: namespace.
// Editing is not affected.
jQuery(document).ready(function() {
if (!window.vultus_modify) return;
var namespaceNumber = mw.config.get('wgNamespaceNumber');
if (namespaceNumber != 0 && namespaceNumber != 14 && namespaceNumber != 100) return;
function vultus_text_a_to_b(text) {
for (var re in window.vultus_modify) {
var rep = new RegExp(re, "g");
text = text.replace(rep, window.vultus_modify[re]);
}
return text;
}
function vultus_node_a_to_b(node) {
if (node.nodeType == 3) {
node.data = vultus_text_a_to_b(node.data);
} else {
for (var i=0; i<node.childNodes.length; i++) {
if (window.vultus_punct && node.className == 'thumbcaption' && i+1==node.childNodes.length) {
if (node.childNodes[i].nodeType == 3 &&
(node.childNodes[i].data.length < window.vultus_punct.length ||
node.childNodes[i].data.substring(node.childNodes[i].data.length - window.vultus_punct.length) != window.vultus_punct)) {
node.childNodes[i].data = node.childNodes[i].data + window.vultus_punct;
} else if (node.childNodes[i].nodeType != 3) {
node.appendChild(document.createTextNode(window.vultus_punct));
}
}
if ((node.id != 'editform') && (node.className != 'citatio'))
vultus_node_a_to_b(node.childNodes[i]);
}
}
}
document.title = vultus_text_a_to_b(document.title);
vultus_node_a_to_b(document.getElementById('content'));
});