非公開 定型文・エディタ

    @@ -1,5 +1,5 @@ /* - * @title 陣取り・エディタ + * @title 定型文・エディタ * @description 定型文を6つまで編集・保存します * @private */
  • /*
     * @title 定型文・エディタ
     * @description 定型文を6つまで編集・保存します
     * @private
     */
    (function(){
        const old = document.getElementById('j-editor'); if(old) old.remove();
    
        // デフォルトのセリフ
        const defaultPhrases = ['味方カモン!', '引き付けておいてくれ!', '包囲するぞ!', 'ナイスゥ!!', '敵の潜水艦を発見!', '駄目だ!'];
        
        let saved = localStorage.getItem('j-phrases');
        let phrases = saved ? JSON.parse(saved) : defaultPhrases;
    
        const style = document.createElement('style');
        style.innerHTML = `
            #j-editor { position:fixed; top:50px; right:50px; background:rgba(20,30,50,0.95); border:3px solid #3b82f6; border-radius:10px; padding:15px; z-index:100001; color:#fff; width:300px; box-shadow:0 0 20px #000; }
            .je-line { display:flex; align-items:center; margin-bottom:8px; }
            .je-input { flex:1; background:#000; border:1px solid #60a5fa; color:#fff; padding:8px; border-radius:4px; font-size:12px; }
            .je-footer { display: flex; gap: 8px; margin-top: 10px; }
            .je-btn-save { flex: 2; background:#2563eb; color:#fff; border:none; border-radius:5px; padding:12px; cursor:pointer; font-weight:bold; }
            .je-btn-reset { flex: 1; background:#475569; color:#fff; border:none; border-radius:5px; padding:12px; cursor:pointer; font-size: 11px; }
            .je-btn-close { position:absolute; top:5px; right:5px; background:none; border:none; color:#aaa; cursor:pointer; font-size:16px; }
        `;
        document.head.appendChild(style);
    
        const ed = document.createElement('div'); ed.id = 'j-editor';
        ed.innerHTML = '<button class="je-btn-close" onclick="this.parentNode.remove()">✕</button><div style="text-align:center;font-weight:bold;margin-bottom:10px;">チームチャット定型文編集エディタ</div>';
        
        const inputs = [];
        for(let i=0; i<6; i++) {
            const line = document.createElement('div'); line.className = 'je-line';
            const inp = document.createElement('input'); inp.className = 'je-input';
            inp.value = phrases[i] || '';
            inp.placeholder = `ボタン ${i+1}`;
            line.appendChild(inp);
            ed.appendChild(line);
            inputs.push(inp);
        }
    
        const footer = document.createElement('div'); footer.className = 'je-footer';
    
        // 保存ボタン
        const saveBtn = document.createElement('button'); saveBtn.className = 'je-btn-save'; saveBtn.innerText = '💾 保存';
        saveBtn.onclick = () => {
            const newPhrases = inputs.map(input => input.value.trim()).filter(p => p !== '');
            localStorage.setItem('j-phrases', JSON.stringify(newPhrases));
            alert('定型文を保存しました!');
            ed.remove();
        };
    
        // リセットボタン
        const resetBtn = document.createElement('button'); resetBtn.className = 'je-btn-reset'; resetBtn.innerText = '🔄 リセット';
        resetBtn.onclick = () => {
            if(confirm('全ての入力をデフォルト(味方カモン!等)に戻しますか?')) {
                inputs.forEach((inp, i) => {
                    inp.value = defaultPhrases[i] || '';
                });
            }
        };
    
        footer.appendChild(resetBtn);
        footer.appendChild(saveBtn);
        ed.appendChild(footer);
        document.body.appendChild(ed);
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。