定型文・エディタ
by
cutfloss
05/01 [2026/05/01 13:11:39]
定型文を6つまで編集・保存します
@@ -34,7 +34,7 @@
inputs.push(inp);
}
- const saveBtn = document.createElement('button'); saveBtn.className = 'je-btn-save'; saveBtn.innerText = '💾 6つの戦術を保存';
+ const saveBtn = document.createElement('button'); saveBtn.className = 'je-btn-save'; saveBtn.innerText = '💾 6つの定型文を保存';
saveBtn.onclick = () => {
const newPhrases = inputs.map(input => input.value.trim()).filter(p => p !== '');
localStorage.setItem('j-phrases', JSON.stringify(newPhrases));
/*
* @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-btn-save { width:100%; background:#2563eb; color:#fff; border:none; border-radius:5px; padding:12px; cursor:pointer; font-weight:bold; margin-top:10px; }
.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;">司令官定型文・エディタ(6連)</div>';
const inputs = [];
for(let i=0; i<6; i++) { // 6つに変更
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 saveBtn = document.createElement('button'); saveBtn.className = 'je-btn-save'; saveBtn.innerText = '💾 6つの定型文を保存';
saveBtn.onclick = () => {
const newPhrases = inputs.map(input => input.value.trim()).filter(p => p !== '');
localStorage.setItem('j-phrases', JSON.stringify(newPhrases));
alert('6つの戦術を保存しました!');
ed.remove();
};
ed.appendChild(saveBtn);
document.body.appendChild(ed);
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。