共创世界(CCW)快捷键暂停

使用模拟点击元素实现的快捷暂停

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         共创世界(CCW)快捷键暂停
// @namespace    https://greasyfork.org/zh-CN/scripts/477123-ccw%E5%BF%AB%E6%8D%B7%E9%94%AE%E6%9A%82%E5%81%9C
// @version      1.5
// @description  使用模拟点击元素实现的快捷暂停
// @match        https://www.ccw.site/detail/*
// @grant        none
// @license MIT
// ==/UserScript==


(function() {
  'use strict';

  // 用户自定义的触发按键
  const customKey = 'x';

  // 需要点击的元素选择器
  const elementSelector = 'div.action-item-P9SP6.action-control-8nmb9';

  window.addEventListener('keydown', function(event) {
    const key = event.key.toLowerCase();
    // 判断是否按下用户定义的按键
    if (key === customKey) {
      // 获取要点击的元素
      const element = document.querySelector(elementSelector);
      console.log(element.style.visibility);

      if (element && element.style.visibility === '' && typeof element.click === 'function') {
        element.click();
      }
    }
  });
})();