MediaWiki:Common.js

From Nookipedia, the Animal Crossing wiki

Note: After saving, 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: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Autoplay videos with autoplay class */
var vids = document.getElementsByClassName("autoplay");
for(var i = 0; i < vids.length; i++){
  vids[i].controls = true;
  vids[i].setAttribute("playsinline", "");
  vids[i].muted = true;
  vids[i].autoplay = true;
  vids[i].loop = true;
  vids[i].play();
}

/* Customize audio players */
var audio = document.getElementsByTagName("audio");
for(var i = 0; i < audio.length; i++){
  audio[i].setAttribute("controlslist", "nodownload");
}

/* Log warning + links to Discord and API for developers */
setTimeout(function() {
    console.log("%cHold up!", "color: #67AD42; font-family: Coustard, sans-serif; font-size: 40px;");
    console.log("%cIf someone told you to paste something here and you're not 100% sure of what you're doing, you may be getting scammed!", "font-family: sans-serif; font-size: 15px;");
    console.log("%cPasting anything here could give scammers access to your account.", "font-family: sans-serif; font-size: 15px;");
    console.log("%cAre you a developer?", "color: #67AD42; font-family: Coustard, sans-serif; font-size: 35px;");
	console.log("%cJoin our Discord for help and questions: https://nookipedia.com/wiki/Nookipedia:Discord", "font-family: sans-serif; font-size: 15px;");
	console.log("%cIf you're looking to scrape the site for data, check out our API: https://api.nookipedia.com/", "font-family: sans-serif; font-size: 15px;");
}, 2000)

// ------------------------------------------------
// Link to module dependencies 
// Author: RheingoldRiver
// License: CC BY-SA 3.0
// Source: https://lol.fandom.com/wiki/MediaWiki:Common.js#L-28
// ------------------------------------------------
$(function() {
    if (mw.config.get('wgCanonicalNamespace') != 'Module') return;
    $('.s1, .s2').each(function() {
        var html = $(this).html();
        var quote = html[0];
        var quoteRE = new RegExp('^' + quote + '|' + quote + '$', 'g');
        var name = html.replace(quoteRE,"");
        if (name.startsWith("Module:")) {
            var target = name.replace(/ /g,'%20');
            var url = mw.config.get('wgServer') + '/wiki/' + target;
            var str = quote + '<a href="' + url + '">' + name + '</a>' + quote;
            $(this).html(str);
        }
    });
});