SwordMasters.io擊殺倍數

透過傳送重複攻擊訊息來增加殺戮資料的腳本(使用滑桿從 1 調整到10)

// ==UserScript==
// @name         SwordMasters.io擊殺倍數
// @license      MIT
// @version      1.1
// @description  透過傳送重複攻擊訊息來增加殺戮資料的腳本(使用滑桿從 1 調整到10)
// @author       huang-wei-lun
// @match        https://swordmasters.io/*
// @grant        none
// @namespace http://tampermonkey.net/
// ==/UserScript==
// --- 儲存原始 WebSocket ---
const OriginalWebSocket = window.WebSocket;

let killMultiplier = 1; // 初始擊殺倍數

// --- 建立模組 UI ---
const ui = document.createElement('div');
ui.id = 'mod-ui';
ui.style.position = 'fixed';
ui.style.top = '20px';
ui.style.right = '20px';
ui.style.zIndex = '9999';
ui.style.padding = '15px';
ui.style.background = 'rgba(0,0,0,0.8)';
ui.style.color = '#fff';
ui.style.borderRadius = '10px';
ui.style.fontFamily = 'Arial';
ui.style.fontSize = '14px';
ui.style.display = 'none'; // 初始隱藏
ui.innerHTML = `
  <div><b>擊殺倍數模組</b></div>
  <label for="multiplierRange">倍數:<span id="multiplierValue">1</span>x</label><br>
  <input type="range" min="1" max="10" value="1" id="multiplierRange" />
`;
document.body.appendChild(ui);

// --- 監聽滑桿變化 ---
const multiplierRange = document.getElementById('multiplierRange');
const multiplierValue = document.getElementById('multiplierValue');
multiplierRange.oninput = () => {
  killMultiplier = parseInt(multiplierRange.value);
  multiplierValue.textContent = killMultiplier;
};

// --- 熱鍵 M 鍵切換顯示模組 ---
document.addEventListener('keydown', (e) => {
  if (e.key.toLowerCase() === 'm') {
    ui.style.display = ui.style.display === 'none' ? 'block' : 'none';
  }
});

// --- 包裝 WebSocket ---
window.WebSocket = function(url, protocols) {
  const ws = new OriginalWebSocket(url, protocols);

  ws.addEventListener('open', () => {
    console.log('[WS] 已連線,模組已啟動');

    // 每秒依倍數發送擊殺封包
    setInterval(() => {
      for (let i = 0; i < killMultiplier; i++) {
        const fakeKillPacket = JSON.stringify({
          type: "kill",
          targetId: "enemy_id",   // TODO: 更換成正確敵人 ID
          killerId: "your_id"     // TODO: 更換成你的玩家 ID
        });

        ws.send(fakeKillPacket);
        console.log(`[WS] 發送偽造擊殺封包 (${i + 1}/${killMultiplier})`);
      }
    }, 1000); // 每秒一次
  });

  return ws;
};

window.WebSocket.prototype = OriginalWebSocket.prototype;