非公開 自陣色強調

    @@ -4,40 +4,37 @@ * @private */ javascript:(function(){ - const cvs = document.querySelector('canvas'); - if(!cvs) return; - const ctx = cvs.getContext('2d'); + const ctx = document.querySelector('canvas')?.getContext('2d'); + if(!ctx) return; - /* 状態管理変数 */ - let myCurrentColor = null; + /* 保存用の変数(計算を使い回す) */ + let myColor = ''; - /* 1. 自分の色を特定・更新する関数 */ - const updateMyColor = () => { + /* 自分の色(とチームの色)を0.5秒に1回だけ「下準備」しておく */ + setInterval(() => { if(typeof players === 'undefined' || typeof myId === 'undefined') return; const me = players.find(p => p.id === myId); if(me && me.color) { - myCurrentColor = me.color.toLowerCase(); + myColor = me.color.toLowerCase(); } - }; - - /* 定期的に色を更新(試合終了やリスポーン対策) */ - setInterval(updateMyColor, 500); + }, 500); - /* 2. 描画命令(fill)に割り込む */ const originalFill = ctx.fill; ctx.fill = function() { - /* 現在の塗りつぶし色を取得 */ - const currentStyle = this.fillStyle.toString().toLowerCase(); - - /* 今塗ろうとしている色が、最新の「自分の色」と一致するか判定 */ - if (myCurrentColor && currentStyle.includes(myCurrentColor)) { - this.save(); - this.globalAlpha = 0.8; /* 自陣(と偶然色が被った人)を濃くする */ + /* fillStyleの取得は1回だけにして変数に入れる */ + const style = this.fillStyle; + + /* 文字列比較の前に myColor がセットされているかチェック */ + /* includes よりも高速な indexOf を使用 */ + if (myColor && style.toString().toLowerCase().indexOf(myColor) !== -1) { + const oldAlpha = this.globalAlpha; + this.globalAlpha = 0.8; originalFill.apply(this, arguments); - this.restore(); + this.globalAlpha = oldAlpha; } else { originalFill.apply(this, arguments); } }; + console.log('High-Performance Color Boost: Optimized.'); })();
  • /*
     * @title 自陣色強調
     * @description 自陣の色が強調されて見えやすくなるぞ
     * @private
     */
    javascript:(function(){
        const ctx = document.querySelector('canvas')?.getContext('2d');
        if(!ctx) return;
    
        /* 保存用の変数(計算を使い回す) */
        let myColor = '';
    
        /* 自分の色(とチームの色)を0.5秒に1回だけ「下準備」しておく */
        setInterval(() => {
            if(typeof players === 'undefined' || typeof myId === 'undefined') return;
            const me = players.find(p => p.id === myId);
            if(me && me.color) {
                myColor = me.color.toLowerCase();
            }
        }, 500);
    
        const originalFill = ctx.fill;
        ctx.fill = function() {
            /* fillStyleの取得は1回だけにして変数に入れる */
            const style = this.fillStyle;
            
            /* 文字列比較の前に myColor がセットされているかチェック */
            /* includes よりも高速な indexOf を使用 */
            if (myColor && style.toString().toLowerCase().indexOf(myColor) !== -1) {
                const oldAlpha = this.globalAlpha;
                this.globalAlpha = 0.8;
                originalFill.apply(this, arguments);
                this.globalAlpha = oldAlpha;
            } else {
                originalFill.apply(this, arguments);
            }
        };
    
        console.log('High-Performance Color Boost: Optimized.');
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2026/05/07 18:24:18 - 7 hours ago
  2. 2026/05/07 18:12:26 - 7 hours ago
  3. 2026/05/07 13:48:54 - 12 hours ago
  4. 2026/05/07 13:45:02 - 12 hours ago