Custom Jstris Skins

Set custom skins and ghost skins for Jstris

目前為 2022-05-15 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Custom Jstris Skins
// @namespace    http://tampermonkey.net/
// @description  Set custom skins and ghost skins for Jstris
// @version      0.15
// @author       leonid
// @match        https://*.jstris.jezevec10.com/*
// @license MIT
// ==/UserScript==

(function() {
    const checkLoaded = setInterval(() => {
        if (typeof loadSkin !== 'undefined') {
            clearInterval(checkLoaded);
            setSkin();
        }
    }, 100);

    function setSkin() {
        const skinUrl = 'https://i.imgur.com/q2Kx060.png';
        const skinSize = 48;
        const ghostUrl = 'https://i.imgur.com/VbOkRzd.png';
        const ghostSize = 36;

        if (typeof Game !== 'undefined') {
            // Game Mode
            loadSkin(skinUrl, skinSize);
            loadGhostSkin(ghostUrl, ghostSize);
        } else {
            // Replay Mode

            // Don't load skin before replay starts playing, otherwise it shows stuff like this https://cdn.discordapp.com/attachments/340282855420723201/642924315272151045/unknown.png
            $('#load').click(() => loadSkin(skinUrl, skinSize));

            // They don't have loadGhostSkin in replays, so we gotta do it this way.
            const ghost = new Image;
            ghost.src = ghostUrl;
            View.prototype.drawGhostBlock = function(t, e, i) {
                if (t >= 0 && e >= 0 && t < 10 && e < 20) {
                    const s = this.drawScale * this.block_size;
                    this.ctx.drawImage(ghost, (this.g.coffset[i] - 2) * ghostSize, 0, ghostSize, ghostSize, t * this.block_size, e * this.block_size, s, s);
                }
            }
        }
    }
})();