Jump to content

MediaWiki:Common.js

From NFF
Revision as of 02:55, 3 October 2026 by Maintenance script (talk | contribs) (Wiki redesign: Play now button, footer, search results; upload tool loads from MediaWiki:MultiUpload.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)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
mw.loader.using("mediawiki.util").then(function(){var e="https://final-fight.com/";mw.util.addPortletLink("p-navigation",e,"Play Final Fight","n-play-now","Go to the Final Fight website");var i=document.querySelector(".vector-header-end");if(i&&!document.querySelector(".ffw-play")){var t=document.createElement("a");t.className="ffw-play",t.href=e,t.title="Go to the Final Fight website",t.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 4.5v15l12-7.5z"/></svg>Play now',i.insertBefore(t,i.firstChild)}var n=document.getElementById("footer");if(n&&!document.querySelector(".ffw-footer")){var o=[["Play now",e],["Discord","https://discord.gg/YZ7f5tJ"],["YouTube","https://www.youtube.com/@finalfight4099"],["Twitch","https://www.twitch.tv/final_fight_streamer"]],a=document.createElement("div");a.className="ffw-footer",a.innerHTML='<a class="ffw-footer-brand" href="'+e+'">Final Fight</a><nav>'+o.map(function(r){return'<a href="'+r[1]+'">'+r[0]+"</a>"}).join("")+"</nav>",n.appendChild(a)}}),mw.config.get("wgCanonicalSpecialPageName")==="Search"&&document.querySelectorAll(".searchresult").forEach(function(e){var i="";e.childNodes.forEach(function(n){i+=n.nodeType===1?""+n.textContent+"":n.nodeValue}),i=i.replace(/\n\.\.\.\s*$/," \u2026").replace(/\{\{[^}]*(\}\}|$)|\}\}|<\/?[a-z][^>]*>|\[\[(?:[^|\]]*\|)?|\]\]|'{2,}|={2,}|__[A-Z]+__/gi," ").replace(/\|\s*[\w \u0001\u0002]+?\s*=\s*/g,`
`).replace(/(^|\n)\s*[*#:]+\s*/g,"$1").replace(/\s*\n[\s\n]*/g," \xB7 ").replace(/ {2,}/g," ").replace(/^[\s\u00b7]+|[\s\u00b7]+$/g,""),e.textContent="";var t=null;i.split(/([\u0001\u0002])/).forEach(function(n){n===""?t||(t=e.appendChild(Object.assign(document.createElement("span"),{className:"searchmatch"}))):n===""?t=null:n&&(t||e).appendChild(document.createTextNode(n))})}),mw.config.get("wgCanonicalSpecialPageName")==="Upload"&&mw.loader.load(mw.config.get("wgScript")+"?title=MediaWiki:MultiUpload.js&action=raw&ctype=text/javascript");var discordOnline=document.querySelector(".ffw-discord-online");discordOnline&&fetch("https://discord.com/api/guilds/715225351055474719/widget.json").then(function(e){return e.json()}).then(function(e){if(!e||typeof e.presence_count!="number")throw new Error("no count");discordOnline.textContent=e.presence_count.toLocaleString("en-US")}).catch(function(){discordOnline.parentNode.remove()}),mw.config.get("wgCanonicalSpecialPageName")==="Search"&&mw.loader.using("mediawiki.api").then(function(){var e={};document.querySelectorAll(".mw-search-result").forEach(function(t){var n=t.querySelector(".mw-search-result-heading a");if(!(!n||t.querySelector(".ffw-sr-icon"))){var o=document.createElement("div");for(o.className="ffw-sr-body";t.firstChild;)o.appendChild(t.firstChild);var a=document.createElement("span");a.className="ffw-sr-icon",t.appendChild(a),t.appendChild(o),(e[n.title]=e[n.title]||[]).push(a)}});var i=Object.keys(e);i.length&&new mw.Api().get({action:"query",prop:"pageimages",piprop:"thumbnail",pithumbsize:96,pilimit:50,titles:i.join("|"),formatversion:2}).then(function(t){(t.query.pages||[]).forEach(function(n){n.thumbnail&&(e[n.title]||[]).forEach(function(o){var a=document.createElement("img");a.src=n.thumbnail.source,a.alt="",o.appendChild(a),o.classList.add("ffw-sr-has-icon")})})})});