自研 - 多个站点 - 隐藏悬浮球

按下`\`后展示或隐藏悬浮球。目前已适配云·原神、云·星穹铁道和移动云手机。

  1. // ==UserScript==
  2. // @name 自研 - 多个站点 - 隐藏悬浮球
  3. // @name:en_US Self-made - Multi-site - Hidden float-ball
  4. // @description 按下`\`后展示或隐藏悬浮球。目前已适配云·原神、云·星穹铁道和移动云手机。
  5. // @description:en_US Press the `\` key, the floating button will be displayed or hidden. Currently adapted for Genshin Impact · Cloud, Star Rail · Cloud, and Mobile Cloud Phone.
  6. // @version 1.0.3
  7. // @author CPlayerCHN
  8. // @license MulanPSL-2.0
  9. // @namespace https://www.gitlink.org.cn/CPlayerCHN
  10. // @match https://ys.mihoyo.com/cloud/
  11. // @match https://sr.mihoyo.com/cloud/
  12. // @match https://cloudphoneh5.buy.139.com/
  13. // @exclude http://*/*
  14. // @icon https://ys.mihoyo.com/cloud/ico/favicon_128.4.3.0.ico
  15. // @grant GM_addStyle
  16. // @run-at document-idle
  17. // @noframes
  18. // ==/UserScript==
  19.  
  20. (function() {
  21. 'use strict';
  22.  
  23. // 调整样式
  24. GM_addStyle('.game-menu-fab__btn, .drag-ball { transition: opacity .1s cubic-bezier(0.00, 0.00, 0.00, 1.00) }');
  25.  
  26. // 监听按键按下
  27. addEventListener('keydown', (e) => {
  28. // 定义当前按下的按键和悬浮球变量
  29. let Key = e.key,
  30. floatBall = document.querySelector('.game-menu-fab__btn, .drag-ball');
  31.  
  32. // 如果按下斜杠 为了节省资源先判断按下的按键
  33. if(Key === '\\') {
  34. // 悬浮球存在且悬浮球被隐藏
  35. if(floatBall && floatBall.style.opacity === '0') {
  36. // 就展示悬浮球
  37. floatBall.setAttribute('style', 'opacity: 1');
  38. // 不然如果按下斜杠且悬浮球存在
  39. } else if(floatBall) {
  40. // 就隐藏悬浮球
  41. floatBall.setAttribute('style', 'opacity: 0');
  42. };
  43. }
  44. });
  45.  
  46. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址