非公開 定型文・エディタ

    
      
  • /*
     * @title 陣取り・エディタ
     * @description 定型文を編集してブラウザに保存します
     * @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:10px; }
            .je-input { flex:1; background:#000; border:1px solid #60a5fa; color:#fff; padding:5px; border-radius:4px; font-size:12px; margin-right:5px; }
            .je-btn-save { width:100%; background:#2563eb; color:#fff; border:none; border-radius:5px; padding:10px; cursor:pointer; font-weight:bold; }
            .je-btn-close { position:absolute; top:5px; right:5px; background:none; border:none; color:#aaa; cursor:pointer; font-size:16px; }
        `;
        document.head.appendChild(style);
    
        // エディタのUI作成
        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<4; i++) {
            const line = document.createElement('div'); line.className = 'je-line';
            const inp = document.createElement('input'); inp.className = 'je-input';
            inp.value = phrases[i] || '';
            line.appendChild(inp);
            // ※鉛筆マークは編集画面では不要(入力欄そのものなので)
            ed.appendChild(line);
            inputs.push(inp);
        }
    
        // 保存ボタン
        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();
        };
        ed.appendChild(saveBtn);
        document.body.appendChild(ed);
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。