您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
为iOS平板优化,添加Command+拖拽滑动区域
当前为
// ==UserScript== // @name PCOL-ASSIST-iOS // @author 葉月Hikaru // @match http://www.heyzxz.me/pcol/* // @version 5.0 // @namespace https://gf.qytechs.cn/users/your-id // @description 为iOS平板优化,添加Command+拖拽滑动区域 // ==/UserScript== (function() { 'use strict'; // 基础按键配置(保留原有功能) const keysConfig = [ { key: '+', text: '-', top: 30, left: 40 }, { key: 'w', text: 'W', top: 30, left: 50 }, { key: '-', text: '+', top: 30, left: 60 }, { key: 'space', text: 'SPACE', top: 30, left: 70 }, { key: 'x', text: 'X', top: 30, left: 80 }, { key: 'c', text: 'C', top: 30, left: 90 }, { key: 'p', text: 'P', top: 120, left: 90 }, { key: 'a', text: 'A', top: 120, left: 30 }, { key: 's', text: 'S', top: 120, left: 50 }, { key: 'd', text: 'D', top: 120, left: 70 } ]; // 创建基础按键(保持原有逻辑) function createVirtualKey(keyConfig) { const btn = document.createElement('button'); btn.id = `pcol-assist-${keyConfig.key}-btn`; btn.textContent = keyConfig.text; btn.style.cssText = ` position: fixed; top: ${keyConfig.top}px; left: ${keyConfig.left}%; transform: ${keyConfig.left === 50 ? 'translateX(-50%)' : 'translateX(0)'}; width: 60px; height: 60px; font-size: ${keyConfig.text === 'SPACE' ? '16px' : '28px'}; background-color: rgba(255, 165, 0, 0.9); color: white; border: 2px solid white; border-radius: 50%; cursor: pointer; z-index: 9999; `; function triggerEvent(type) { if (keyConfig.key === '+' || keyConfig.key === '-') { const wheelEvent = new WheelEvent('wheel', { deltaY: keyConfig.key === '+' ? -300 : 300, bubbles: true, cancelable: true }); document.querySelector('canvas')?.dispatchEvent(wheelEvent) || document.dispatchEvent(wheelEvent); } else { const key = keyConfig.key === 'space' ? ' ' : keyConfig.key; const event = new KeyboardEvent(type, { key: key === ' ' ? 'Spacebar' : key, code: key === ' ' ? 'Space' : `Key${key.toUpperCase()}`, keyCode: key === 'w' ? 87 : key === 'a' ? 65 : key === 's' ? 83 : key === 'd' ? 68 : key === 'x' ? 88 : key === 'c' ? 67 : key === 'p' ? 80 : 32, bubbles: true, cancelable: true }); document.querySelector('canvas')?.dispatchEvent(event) || document.dispatchEvent(event); } } ['touchstart', 'mousedown'].forEach(e => btn.addEventListener(e, e => { e.preventDefault(); triggerEvent('keydown'); })); ['touchend', 'mouseup'].forEach(e => btn.addEventListener(e, e => { e.preventDefault(); triggerEvent('keyup'); })); document.body.appendChild(btn); } // 创建Command+拖拽滑动区域 function createDragArea() { const area = document.createElement('div'); area.id = 'pcol-drag-area'; area.textContent = 'Command+拖拽'; area.style.cssText = ` position: fixed; bottom: 50px; right: 20px; width: 200px; height: 200px; background-color: rgba(75, 0, 130, 0.7); color: white; border-radius: 10px; display: flex; justify-content: center; align-items: center; font-size: 16px; cursor: move; z-index: 9999; `; // 触摸状态标记 let isTouching = false; let lastX = 0, lastY = 0; // 模拟Command键按下 function startCommandPress() { const cmdEvent = new KeyboardEvent('keydown', { key: 'Meta', code: 'MetaLeft', keyCode: 91, bubbles: true, cancelable: true }); document.dispatchEvent(cmdEvent); } // 模拟Command键松开 function endCommandPress() { const cmdEvent = new KeyboardEvent('keyup', { key: 'Meta', code: 'MetaLeft', keyCode: 91, bubbles: true, cancelable: true }); document.dispatchEvent(cmdEvent); } // 模拟鼠标移动事件 function simulateMouseDrag(x, y) { const mouseEvent = new MouseEvent('mousemove', { clientX: x, clientY: y, bubbles: true, cancelable: true }); document.dispatchEvent(mouseEvent); } // 触摸事件绑定 area.addEventListener('touchstart', e => { e.preventDefault(); isTouching = true; startCommandPress(); const touch = e.touches[0]; lastX = touch.clientX; lastY = touch.clientY; }); area.addEventListener('touchmove', e => { if (!isTouching) return; e.preventDefault(); const touch = e.touches[0]; const dx = touch.clientX - lastX; const dy = touch.clientY - lastY; lastX = touch.clientX; lastY = touch.clientY; // 获取游戏画布位置并转换坐标 const canvas = document.querySelector('canvas'); if (canvas) { const rect = canvas.getBoundingClientRect(); const canvasX = touch.clientX - rect.left; const canvasY = touch.clientY - rect.top; simulateMouseDrag(canvasX, canvasY); } }); area.addEventListener('touchend', e => { e.preventDefault(); isTouching = false; endCommandPress(); }); area.addEventListener('touchcancel', e => { e.preventDefault(); isTouching = false; endCommandPress(); }); document.body.appendChild(area); } // 初始化 setTimeout(() => { keysConfig.forEach(createVirtualKey); createDragArea(); console.log('【PCOL-ASSIST】iOS优化版已加载,新增Command+拖拽滑动区域'); }, 500); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址