Animation Script

a script to support animated skins on Jstris

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Animation Script
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  a script to support animated skins on Jstris
// @author       Oki
// @match        https://*.jstris.jezevec10.com/*
// @grant        none
// ==/UserScript==

/**************************
     Animation Script         
**************************/

(function() {
    window.addEventListener('load', function(){

localStorage.animSpeed = localStorage.animSpeed || '100';
localStorage.animToggle = localStorage.animToggle || 'b'

Game['animationRunning'] = false;

//Add toggle key option
var animationKey = document.createElement("tr");
animationKey.innerHTML = '<td>Toggle animation:</td><td><input maxlength="1" id="input420" type="text" size="7" value="'+localStorage.animToggle+'"></td><td id="kc420">0</td>'
tab_controls.children[2].appendChild(animationKey);

//Add speed option
var animOption = document.createElement("tr");
animOption.innerHTML = '<td>Animation speed:</td><td><input onchange="localStorage.animSpeed=parseInt(this.value)||100" size="10" id="animSpeed" type="text" value="'+localStorage.animSpeed+'"></td>'
tab_settings.children[1].appendChild(animOption);

//Custom skin here
Game['animatedSkin'] = [
["https://cdn.discordapp.com/attachments/429007833992790036/564703035196964864/ppt_crayon_1.png",36],
["https://cdn.discordapp.com/attachments/429007833992790036/564703064234131464/ppt_crayon_2.png",36],
["https://cdn.discordapp.com/attachments/429007833992790036/564703091375734804/ppt_crayon_3.png",36],
["https://cdn.discordapp.com/attachments/429007833992790036/564703116331843584/ppt_crayon_4.png",36]]

var intervals = []

Game['stopAnim'] = function() {
    for (var i=0; i < intervals.length; i++) {
        clearInterval(intervals[i]);
    }
}

Game['startAnim'] = function() {
    var animLength = Game['animatedSkin'].length*localStorage.animSpeed
    Game['animatedSkin'].map((x,i)=>{
        setTimeout(()=>{intervals.push(setInterval(()=>{loadSkin(x[0],x[1])}, animLength))}, i*(animLength/Game['animatedSkin'].length));
    })
}


window.onkeyup = function(e) {
    if(e.target.id == "input420") {
        event.preventDefault()
        input420.value=e.key
        kc420.innerHTML=e.keyCode
        localStorage.animToggle=e.key
    } else {
        if (e.key == localStorage.animToggle) {
            if(Game['animationRunning']) {
                Game['stopAnim']();
            } else {
                Game['startAnim']();
            }
            Game['animationRunning'] ^= 1
        }
    }
    "input421"==e.target.id?(e.preventDefault(),input421.value=e.key,kc421.innerHTML=e.keyCode,localStorage.randomizeKey=e.key):e.key==localStorage.randomizeKey&&Game['deployRandomSkin']();
}

})})()