User:MathAfrique/Moyai.js

/** * @name mediawiki-userscript-moyai * @version 1.0.0 * @description Put some 🗿 in your Wikipedia! * @author https://en.wikipedia.org/wiki/User:MathAfrique * @see https://en.wikipedia.org/wiki/User:MathAfrique/Moyai * @icon https://upload.wikimedia.org/wikipedia/commons/c/c6/Fluent_Emoji_flat_1f5ff.svg * @include http://*.wikipedia.org/* * @updateURL https://en.wikipedia.org/w/index.php?title=User:MathAfrique/Moyai.js&action=raw&ctype=text/javascript * @usage mw.loader.load("/w/index.php?title=User:MathAfrique/Moyai.js&action=raw&ctype=text/javascript"); // Backlink: User:MathAfrique/Moyai.js */
 * (function {

if (mw.config.get("wgServer") !== '//en.wikipedia.org') { return; }	if (mw.config.get("gmMediawikiUserScriptMoyai")) { return; }	mw.config.set("gmMediawikiUserScriptMoyai", true);

/** Moyai fountain generator - shows the script is working. */	class Fountain { constructor { this.limit = 10; this.particles = [];

this.width = this.height = 600; this.sizes = [8, 12, 16, 20, 24];

this.$container = $(document.createElement("div")); this.$container.addClass(""); $(document.body).append(this.$container);

this.$container.css("height", "600px"); this.$container.css("width", "600px");

this.$container.css("pointer-events", "none"); this.$container.css("user-select", "none");

this.$container.css("position", "fixed"); this.$container.css("right", "0"); this.$container.css("bottom", "0");

if (mw.config.get("wgPageName") !== "Moai") { this.$container.css("opacity", "25%"); }		}		loop { if (this.particles.length < this.limit) { this.voxel; }			this.particles.forEach(this.recompute, this); const reloopFn = requestAnimationFrame.bind(null, this.loop.bind(this)); setTimeout(reloopFn, 12); }

voxel { const size = this.sizes[Math.floor(Math.random * this.sizes.length)];

const speedHorz = Math.random * 10; const speedVert = Math.random * 25; const spinVal = Math.random * 360; const spinSpeed = Math.random * 35 * (Math.random <= 0.5 ? -1 : 1); const top = this.height - size / 2; const left = this.width - size / 2; const $element = $(document.createElement("span")); $element.text("🗿"); $element.addClass("particle"); $element.css({               "font-size": size + "px",                "left": left + "px",				"pointer-events": "none",				"position": "absolute",                "top": top + "px",                "transform": "initial",				"user-select": "none",				"will-change": "transform"			}); this.$container.append($element); this.particles.push({ $element, size, speedHorz, speedVert, spinVal, spinSpeed, top, left }); }		recompute(p) { p.left = p.left - p.speedHorz; p.top = p.top - p.speedVert; p.speedVert = Math.min(p.size, p.speedVert - 1); p.spinVal = p.spinVal + p.spinSpeed; if (p.top >= this.height + p.size) { this.particles = this.particles.filter((o) => o !== p); p.$element.remove; return; }           p.$element.css({                "font-size": p.size + "px",                "left": p.left + "px",				"pointer-events": "none",				"position": "absolute",                "top": p.top + "px",                "transform": "rotate(" + p.spinVal + "deg);",				"user-select": "none",				"will-change": "transform"            }); }	}	const fountain = new Fountain; fountain.loop;

const skin = mw.config.get("skin");

const moyai = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMTAwcHgiIHdpZHRoPSIxMDBweCI+PGZvcmVpZ25PYmplY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIHN0eWxlPSJkaXNwbGF5OiBmbGV4O3RleHQtYWxpZ246IGNlbnRlcjsiPjxzcGFuIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hodG1sIiBzdHlsZT0iZm9udC1zaXplOjEwMHB4O2xpbmUtaGVpZ2h0OjFlbTt0ZXh0LWluZGVudDotMXJlbTt2ZXJ0aWNhbC1hbGlnbjpib3R0b207Ij7wn5e/PC9zcGFuPjwvZm9yZWlnbk9iamVjdD48L3N2Zz4="; const wordmark = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyODYgNDIiPjxmb3JlaWduT2JqZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiPjxkaXYgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGh0bWwiIGlkPSJ0aXRsZSIgc3R5bGU9Ii13ZWJraXQ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dNalV1ZDQvbHhKbVdUaE1jZGRZcGxXSjF4MnFaak51dHVNMXUvcno4NXdmeDFnNE5BQUI0MmsyUG9ZN0NRQlJGejNRb2tFSldZQkJvVWd3S2kwUWdDV29GUVJFK0FOSlVvUGtKTkhyMWVqUjY3ZUw0QWdTSyt6cERTaWR2M3J2M251bTBPQ0RqbnpzTHBsMk5iZ0xKRXZ3ZnBHTndQOUkzOWJrOHdjbEIyME5hdWJFK2svNVdIWlVSZWtPNXYwQ1RrS2Nuc2Fya0xHK3IvQnE0aXIxR2J4czQ4MXhXNXpiN1NkUjZMOHRZbi9PdnVGVjl4dXFwKzVueGZqYnNDQi80UlkrMitpZ205bE80Zml1MzNocHE1VGh6cFBMSXBCVXo4RVYxWUs5VkdFTkpHWmphY3dNcDQ1eHU2N0IrQWRveUpBND0iKSBmb3JtYXQoIndvZmYiKTtmb250LXdlaWdodDpub3JtYWw7Zm9udC1zdHlsZTpub3JtYWw7fTwvc3R5bGU+PC9mb3JlaWduT2JqZWN0Pjwvc3ZnPg==";

switch (skin) { case "vector-2022": $(".mw-logo-icon").attr("src", moyai); $(".mw-logo-wordmark").attr("src", wordmark); $(".mw-logo-wordmark").css("height", "auto"); break; case "vector": case "monobook": $(".mw-wiki-logo").css("background-image", "url('" + moyai + "')"); $(".mw-wiki-logo").css("background-size", "128px"); break; case "cologneblue": $("#sitetitle").css("background-image", "url('" + moyai + "')"); $("#sitetitle").css("background-position", "center left"); $("#sitetitle").css("background-repeat", "no-repeat"); $("#sitetitle").css("background-size", "contain"); $("#sitetitle").css("background-color", "#6a8"); $("#sitetitle").css("padding-left", "53px"); break; case "minerva": $(".branding-box img").removeAttr("style"); $(".branding-box img").removeAttr("width"); $(".branding-box img").attr("src", wordmark); break; case "timeless": $(".mw-wiki-title img").attr("src", wordmark); $(".mw-wiki-logo img").attr("src", moyai); } });