定型文・コア
by
cutfloss
05/01 [2026/05/01 13:11:50]
6連ボタン対応の完璧版
@@ -1,6 +1,6 @@
/*
* @title 陣取りチャット拡張
- * @description チームチャットの定型文ボタンとログ表示を追加
+ * @description 画面端に戦術ボタンを追加&チャットを常時表示
* @include http://*
* @license MIT License
* @require
@@ -8,45 +8,85 @@
*/
(function() {
- // すでに起動していたら一旦削除してリセット
- $('#jintori-chat-ext').remove();
-
- // コンテナ作成(クリックを透過させるため初期はpointer-events:none)
- let container = $('<div id="jintori-chat-ext">').css({
- 'position': 'fixed', 'top': '0', 'left': '0', 'width': '100%', 'height': '100%',
- 'pointer-events': 'none', 'z-index': '9999'
- }).appendTo('body');
-
- // スタイル定義
- $('<style>').text(`
- .ext-box { pointer-events: auto; position: absolute; top: 50px; background: rgba(0,0,0,0.7); color: white; padding: 10px; border-radius: 8px; }
- .ext-btn { display: block; margin-bottom: 8px; padding: 8px 12px; background: #2563eb; border: none; color: white; cursor: pointer; border-radius: 4px; }
- .ext-log { width: 200px; height: 300px; overflow-y: auto; font-size: 12px; }
- `).appendTo('head');
-
- // --- 左側:ボタンエリア ---
- let leftBox = $('<div class="ext-box" style="left: 10px;">').appendTo(container);
- let phrases = ['攻めるぞ!', '守って!', '集合!', '援護求む'];
-
- phrases.forEach(p => {
- $('<button class="ext-btn">').text(p).appendTo(leftBox).click(function() {
- // ⚠️ ここを調整: ゲームのチャット送信関数に合わせてください
- // 例: socket.emit('chat', {msg: p});
- if(window.socket) {
- window.socket.emit('chat', {msg: p});
- } else {
- alert('socketが見つかりません');
+ // 1. 二重起動防止
+ const oldContainer = document.getElementById('jintori-ext-container');
+ if (oldContainer) oldContainer.remove();
+
+ // 2. 本家のチャット欄を強制的に「常に表示」状態にする
+ const originalChat = document.getElementById('team-chat');
+ if (originalChat) {
+ originalChat.style.display = 'block'; // 常に表示
+ originalChat.style.bottom = '10px'; // 右下に固定
+ originalChat.style.opacity = '0.9'; // 少し透かす
+ // バッジ(丸いアイコン)は邪魔なので消す
+ const badge = document.getElementById('team-chat-badge');
+ if (badge) badge.style.display = 'none';
+ }
+
+ // 3. 全体コンテナの作成
+ const container = document.createElement('div');
+ container.id = 'jintori-ext-container';
+ document.body.appendChild(container);
+
+ // 4. スタイルの追加
+ const style = document.createElement('style');
+ style.innerHTML = `
+ .ext-sidebar {
+ position: fixed;
+ left: 10px;
+ top: 50%;
+ transform: translateY(-50%);
+ z-index: 20000;
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ }
+ .ext-btn {
+ background: #3b82f6;
+ color: white;
+ border: 1px solid #93c5fd;
+ border-radius: 6px;
+ padding: 10px;
+ font-size: 14px;
+ cursor: pointer;
+ box-shadow: 0 4px 6px rgba(0,0,0,0.3);
+ width: 120px;
+ transition: 0.2s;
+ }
+ .ext-btn:hover { background: #2563eb; transform: scale(1.05); }
+ `;
+ document.head.appendChild(style);
+
+ // 5. 左サイドバーの作成
+ const sidebar = document.createElement('div');
+ sidebar.className = 'ext-sidebar';
+ container.appendChild(sidebar);
+
+ // 6. 定型文ボタンを作る関数
+ function addQuickBtn(label, text) {
+ const btn = document.createElement('button');
+ btn.className = 'ext-btn';
+ btn.innerText = label;
+ btn.onclick = () => {
+ const input = document.getElementById('team-chat-input');
+ if (input) {
+ input.value = text; // 入力欄に文字を入れる
+ // 本家の「送信」処理を呼び出す
+ if (typeof sendTeamChat === 'function') {
+ sendTeamChat();
+ } else {
+ alert('送信機能にアクセスできません');
+ }
}
- });
- });
-
- // --- 右側:ログ表示エリア ---
- let rightBox = $('<div class="ext-box" style="right: 10px;">').appendTo(container);
- rightBox.append('<div>チームチャットログ</div>');
- let logArea = $('<div class="ext-log" id="ext-chat-log">').appendTo(rightBox);
-
- // ⚠️ ここを調整: サーバーからチャットを受信した時の処理をフックする
- // 本来はサーバー側のイベントリスナーを上書きする必要があります
- console.log('拡張機能起動: チャットログの監視を開始するにはsocket.onの書き換えが必要です');
+ };
+ sidebar.appendChild(btn);
+ }
+
+ // --- ここに好きな定型文を追加 ---
+ addQuickBtn('⚔️ 攻める!', '攻めましょう!');
+ addQuickBtn('🛡️ 防衛!', '泉を守りましょう!');
+ addQuickBtn('🆘 援護!', '援護お願いします!');
+ addQuickBtn('✨ 感謝', 'ありがとうございます!');
+ console.log("陣取りチャット拡張:起動完了");
})();
/*
* @title 陣取りチャット拡張
* @description 画面端に戦術ボタンを追加&チャットを常時表示
* @include http://*
* @license MIT License
* @require
* @private
*/
(function() {
// 1. 二重起動防止
const oldContainer = document.getElementById('jintori-ext-container');
if (oldContainer) oldContainer.remove();
// 2. 本家のチャット欄を強制的に「常に表示」状態にする
const originalChat = document.getElementById('team-chat');
if (originalChat) {
originalChat.style.display = 'block'; // 常に表示
originalChat.style.bottom = '10px'; // 右下に固定
originalChat.style.opacity = '0.9'; // 少し透かす
// バッジ(丸いアイコン)は邪魔なので消す
const badge = document.getElementById('team-chat-badge');
if (badge) badge.style.display = 'none';
}
// 3. 全体コンテナの作成
const container = document.createElement('div');
container.id = 'jintori-ext-container';
document.body.appendChild(container);
// 4. スタイルの追加
const style = document.createElement('style');
style.innerHTML = `
.ext-sidebar {
position: fixed;
left: 10px;
top: 50%;
transform: translateY(-50%);
z-index: 20000;
display: flex;
flex-direction: column;
gap: 10px;
}
.ext-btn {
background: #3b82f6;
color: white;
border: 1px solid #93c5fd;
border-radius: 6px;
padding: 10px;
font-size: 14px;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0,0,0,0.3);
width: 120px;
transition: 0.2s;
}
.ext-btn:hover { background: #2563eb; transform: scale(1.05); }
`;
document.head.appendChild(style);
// 5. 左サイドバーの作成
const sidebar = document.createElement('div');
sidebar.className = 'ext-sidebar';
container.appendChild(sidebar);
// 6. 定型文ボタンを作る関数
function addQuickBtn(label, text) {
const btn = document.createElement('button');
btn.className = 'ext-btn';
btn.innerText = label;
btn.onclick = () => {
const input = document.getElementById('team-chat-input');
if (input) {
input.value = text; // 入力欄に文字を入れる
// 本家の「送信」処理を呼び出す
if (typeof sendTeamChat === 'function') {
sendTeamChat();
} else {
alert('送信機能にアクセスできません');
}
}
};
sidebar.appendChild(btn);
}
// --- ここに好きな定型文を追加 ---
addQuickBtn('⚔️ 攻める!', '攻めましょう!');
addQuickBtn('🛡️ 防衛!', '泉を守りましょう!');
addQuickBtn('🆘 援護!', '援護お願いします!');
addQuickBtn('✨ 感謝', 'ありがとうございます!');
console.log("陣取りチャット拡張:起動完了");
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。