linux.do.cq.auto.fire

auto fire wall

当前为 2024-12-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name linux.do.cq.auto.fire
  3. // @namespace https://linux.do/u/io.oi/cq.auto.fire
  4. // @version 1.0.0
  5. // @author io.oi
  6. // @description auto fire wall
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=e-hai.one
  8. // @match http://cq.e-hai.one/play?*
  9. // @match http://chuanqi.proxy2world.com/play?*
  10. // @license MIT
  11. // @grant GM_addStyle
  12. // ==/UserScript==
  13.  
  14. (o=>{if(typeof GM_addStyle=="function"){GM_addStyle(o);return}const t=document.createElement("style");t.textContent=o,document.head.append(t)})(" .control-panel{position:fixed;bottom:0;left:0;min-width:auto}.control-panel .control-group{display:flex}.control-panel .control-group .button{color:#ece6cf;background-color:#084552;padding:.4rem;border:none;cursor:pointer;border-radius:.1rem} ");
  15.  
  16. (function () {
  17. 'use strict';
  18.  
  19. var __defProp = Object.defineProperty;
  20. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  21. var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  22. class Icons {
  23. }
  24. __publicField(Icons, "startIcon", '<svg class="icon" style="width: 1em;height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M823.8 603.5l-501.2 336c-50.7 34-119.3 20.4-153.2-30.2-12.2-18.2-18.7-39.6-18.7-61.5v-672c0-61 49.5-110.4 110.4-110.4 21.9 0 43.3 6.5 61.5 18.7l501.1 336c50.7 34 64.2 102.6 30.2 153.2-7.8 11.9-18.1 22.2-30.1 30.2z m0 0"></path></svg>');
  25. __publicField(Icons, "stopIcon", '<svg class="icon" style="width: 1em;height: 1em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M941.967463 109.714286v804.571428q0 14.857143-10.857143 25.714286t-25.714286 10.857143H100.824606q-14.857143 0-25.714286-10.857143t-10.857143-25.714286V109.714286q0-14.857143 10.857143-25.714286t25.714286-10.857143h804.571428q14.857143 0 25.714286 10.857143t10.857143 25.714286z"></path></svg>');
  26. function createControlPanel(clicked) {
  27. const controlPanel = document.createElement("div");
  28. controlPanel.id = "control-panel";
  29. controlPanel.className = "control-panel";
  30. controlPanel.innerHTML = `
  31. <div class="control-group">
  32. <button id="toggle" class="button" title="将火墙技能放在快捷键4上,点击开始自动释放火墙">${Icons.startIcon}</button>
  33. </div>`;
  34. const btn = controlPanel.querySelector("#toggle");
  35. if (btn) {
  36. btn.addEventListener("click", () => {
  37. clicked(btn);
  38. });
  39. }
  40. return controlPanel;
  41. }
  42. window.addEventListener("load", () => {
  43. let timer = void 0;
  44. const buttonColor = "#55b47d";
  45. const buttonColor2 = "#084552";
  46. const event4 = new KeyboardEvent("keydown", {
  47. key: "4",
  48. bubbles: true,
  49. keyCode: 52,
  50. which: 52
  51. });
  52. function passKey4() {
  53. document.dispatchEvent(event4);
  54. }
  55. const panel = createControlPanel((btn) => {
  56. if (timer) {
  57. clearInterval(timer);
  58. timer = void 0;
  59. btn.style.backgroundColor = buttonColor2;
  60. btn.innerHTML = Icons.startIcon;
  61. } else {
  62. passKey4();
  63. timer = setInterval(() => {
  64. passKey4();
  65. }, 9e3);
  66. btn.style.backgroundColor = buttonColor;
  67. btn.innerHTML = Icons.stopIcon;
  68. }
  69. });
  70. document.body.appendChild(panel);
  71. });
  72.  
  73. })();