Custom Jstris Skins

Set custom skins and ghost skins for Jstris

当前为 2019-11-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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

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

    window.addEventListener('load', () => {
        if (typeof Game != 'undefined') {
            // Game Mode
            loadSkin(skinUrl, skinSize);
            loadGhostSkin(ghostUrl, ghostSize);

            // Hide other players since I only ever play sprint
            $('.slots').css('visibility', 'hidden');
        } 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));

            const ghost = new Image;
            ghost.src = ghostUrl;
            // They don't have loadGhostSkin in replays, so we gotta do it this way
            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);
                }
            }
        }
    });
})();