MediaWiki:Gadget-minceraft.js
Перейти до навігації
Перейти до пошуку
- Іншими мовами
Note: After saving, you have to bypass your browser's cache to see the changes.
Google Chrome, Firefox, Microsoft Edge, and Safari: Hold down the Shift key and click the Reload toolbar button.
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Change all text instances of "Minecraft" to "Minceraft"
$( function() {
function text_minceraft(text) {
// Change "Minceraft" to "Minecraft"
text = text.replace(/Minceraft/g, 'Mine\u2060craft');
// Don't change lowercase "minecraft" found in name ids
text = text.replace(/Minecraft/g, 'Minc\u2060eraft').replace(/MINECRAFT/g, 'MINC\u2060ERAFT');
return text;
}
function node_minceraft($node) {
var walker = document.createTreeWalker( $node.get(0),
NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT,
function(node) {
if (node.nodeType !== Node.TEXT_NODE) {
return ( node.id === 'editform' // Not the edit field
|| node.nodeName === 'STYLE' // Not template styles
|| node.className === 'mcwiki-quote' // Not quotes
? NodeFilter.FILTER_REJECT
: NodeFilter.FILTER_SKIP );
}
return ( node.data.toLowerCase().includes('minecraft')
|| node.data.toLowerCase().includes('minceraft')
? NodeFilter.FILTER_ACCEPT
: NodeFilter.FILTER_SKIP );
}
);
var node, text;
while(node = walker.nextNode()) {
text = text_minceraft(node.data);
if (text !== node.data) { // odd Gecko rendering error
node.data = text;
}
}
}
document.title = text_minceraft( document.title );
node_minceraft( $( '#content' ) ); // with firstHeader, sitenotice and so on
node_minceraft( $( '#mw-panel, #mw-mf-page-left' ) ); // sidebar
var search = $( '#searchInput' ).get(0);
search.placeholder = text_minceraft( search.placeholder );
mw.hook( 'wikipage.content' ).add( node_minceraft );
// content-visibility css rule is experimental and not available on firefox
$('body:not(.ns-6) img[src^="/images/Minecraft_Wiki_header.svg?"], .minerva-header .branding-box img').attr('src', '/images/Minceraft_Wiki_header.svg');
} );