您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
为http://www.heyzxz.me/pcol/添加W/A/S/D/空格虚拟按键,解决iOS平板无键盘操作问题
当前为
// ==UserScript== // @name PCOL-ASSIST // @author 葉月Hikaru // @match http://www.heyzxz.me/pcol/* // @version 0.0.1.20250623133852 // @namespace https://gf.qytechs.cn/users/your-id // @description 为http://www.heyzxz.me/pcol/添加W/A/S/D/空格虚拟按键,解决iOS平板无键盘操作问题 // ==/UserScript== (function() { 'use strict'; // 按键配置(option键替换ctrl,空格键绿色) 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 }, // option键(替换原ctrl键,同时触发cmd和ctrl) { key: 'Option', text: '⌥', top: 120, left: 20 } ]; // 创建按键函数 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'}; ${keyConfig.key === 'space' ? 'background-color: rgba(0, 128, 0, 0.9);' : ''} /* 空格键绿色 */ color: white; border: 2px solid white; border-radius: 50%; cursor: pointer; z-index: 9999; `; // 模拟按键事件(option键同时触发cmd和ctrl) function triggerKeyEvent(type) { if (keyConfig.key === '+' || keyConfig.key === '-') { // 滚轮事件(文本互换功能不变) const wheelEvent = new WheelEvent('wheel', { deltaY: keyConfig.key === '+' ? -300 : 300, bubbles: true, cancelable: true }); document.dispatchEvent(wheelEvent); } else if (keyConfig.key === 'Option') { // option键同时触发cmd和ctrl(Mac环境下option=alt,此处模拟组合键) const cmdEvent = new KeyboardEvent(type, { key: 'Meta', code: 'MetaLeft', keyCode: 91, bubbles: true, cancelable: true }); const ctrlEvent = new KeyboardEvent(type, { key: 'Control', code: 'ControlLeft', keyCode: 17, bubbles: true, cancelable: true }); document.dispatchEvent(cmdEvent); document.dispatchEvent(ctrlEvent); } 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.dispatchEvent(event); } } // 绑定事件 ['touchstart', 'mousedown'].forEach(e => btn.addEventListener(e, e => { e.preventDefault(); triggerKeyEvent('keydown'); })); ['touchend', 'mouseup'].forEach(e => btn.addEventListener(e, e => { e.preventDefault(); triggerKeyEvent('keyup'); })); document.body.appendChild(btn); } // 延迟初始化 setTimeout(() => { keysConfig.forEach(createVirtualKey); console.log('【PCOL-ASSIST】已更新:option键触发cmd+ctrl,空格键绿色'); }, 500); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址