MediaWiki:Gadget-oneko.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 101: Line 101:


     let nekoFile = "https://wiki.vencord.dev/images/8/8c/Oneko.gif";
     let nekoFile = "https://wiki.vencord.dev/images/8/8c/Oneko.gif";
     const curScript = document.currentScript
     const curScript = document.currentScript;
     if (curScript && curScript.dataset.cat) {
     if (curScript && curScript.dataset.cat) {
       nekoFile = curScript.dataset.cat
       nekoFile = curScript.dataset.cat;
     }
     }
     nekoEl.style.backgroundImage = `url(${nekoFile})`;
     nekoEl.style.backgroundImage = `url(${nekoFile})`;
Line 128: Line 128:
     }
     }
     if (timestamp - lastFrameTimestamp > 100) {
     if (timestamp - lastFrameTimestamp > 100) {
       lastFrameTimestamp = timestamp
       lastFrameTimestamp = timestamp;
       frame()
       frame();
     }
     }
     window.requestAnimationFrame(onAnimationFrame);
     window.requestAnimationFrame(onAnimationFrame);
Line 204: Line 204:
     const diffX = nekoPosX - mousePosX;
     const diffX = nekoPosX - mousePosX;
     const diffY = nekoPosY - mousePosY;
     const diffY = nekoPosY - mousePosY;
     const distance = Math.sqrt(diffX ** 2 + diffY ** 2);
     const distance = Math.sqrt(Math.pow(diffX, 2) + Math.pow(diffY, 2));


     if (distance < nekoSpeed || distance < 48) {
     if (distance < nekoSpeed || distance < 48) {

Navigation menu