simtoolsReticentBase

A tool for SimCompanies game.

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/523380/1518729/simtoolsReticentBase.js

  1. // ==UserScript==
  2. // @name SimTools Reticent Base Library
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Provides utility functions for interacting with elements on SimCompanies pages.
  6. // @author Reticent
  7. // @match *://*/*
  8. // @grant none
  9. // @run-at document-idle
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 定义 checkForRealmElement 函数
  16. const checkForRealmElement = (callback) => {
  17. let intervalId;
  18.  
  19. function findRealmElement() {
  20. // 查找 img[alt*="企业家"]
  21. const entrepreneurElement = document.querySelector(`div.css-inxa61.e1uuitfi4 img[alt*="企业家"]`);
  22. // 查找 img[alt*="商业大亨"]
  23. const tycoonElement = document.querySelector(`div.css-inxa61.e1uuitfi4 img[alt*="商业大亨"]`);
  24.  
  25. if (entrepreneurElement) {
  26. clearInterval(intervalId);
  27. callback(1); // 找到 "企业家" 元素后调用回调函数并传入 1
  28. } else if (tycoonElement) {
  29. clearInterval(intervalId);
  30. callback(0); // 找到 "商业大亨" 元素后调用回调函数并传入 0
  31. } else {
  32. console.warn('Neither matching realm element found yet.');
  33. }
  34. }
  35.  
  36. intervalId = setInterval(findRealmElement, 1000);
  37. findRealmElement(); // 立即执行一次以避免不必要的延迟
  38. };
  39.  
  40. // 公开 API
  41. window.SimToolsAPI = {
  42. checkForRealmElement,
  43. // 如果有其他公共方法,可以在这里添加
  44. };
  45. })();

QingJ © 2025

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