TruceMonitor

dove mon test

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

  1. // truceMonitor.js (New Tab for Truce/AP Monitoring)
  2.  
  3. Tabs.TruceMonitor = {
  4. tabOrder: 2180, // Adjust order as needed
  5. tabLabel: "Truce Monitor",
  6. tabColor: "grey", // Or another suitable color
  7. myDiv: null,
  8. targets: [], // Array to store monitored players/cities
  9.  
  10. init(div) {
  11. this.myDiv = div;
  12. this.paint();
  13. },
  14.  
  15. paint() {
  16. // ... (UI for adding and removing targets to monitor) ...
  17. // This could be a text input for player names/UIDs or a more
  18. // sophisticated system using a searchable list.
  19.  
  20. const m = `
  21. <div class="divHeader" align="center">Truce/AP Monitor</div>
  22. <br>
  23. <div align="center">
  24. <label for="targetInput">Player Name/UID:</label>
  25. <input type="text" id="targetInput" class="btInput">
  26. <button id="addTargetButton" class="buttonv2 std blue">Add Target</button>
  27. <br><br>
  28. <div id="targetList"></div> <br>
  29. <div id="truceMonitorStatus"></div>
  30. </div>
  31. `;
  32.  
  33. this.myDiv.innerHTML = m;
  34.  
  35. // Event listeners
  36. $("#addTargetButton").click(() => this.addTarget());
  37. },
  38.  
  39. addTarget() {
  40. const targetInput = $("#targetInput").val().trim();
  41. if (targetInput === "") {
  42. return;
  43. }
  44.  
  45. // ... (Your logic to resolve player name/UID to a Player object) ...
  46. // This might involve using your existing player search functionality
  47. // or making an API request to get player information.
  48.  
  49. // Example (assuming you have a Player class):
  50. getPlayerInfo(targetInput) // Your function to get player info
  51. .then(player => {
  52. if (player) {
  53. this.targets.push(player);
  54. this.saveTargets(); // Save targets to storage
  55. this.displayTargetList();
  56. this.updateStatus(tx("Target added."));
  57. } else {
  58. this.updateStatus(tx("Player not found."));
  59. }
  60. });
  61.  
  62.  
  63. $("#targetInput").val(""); // Clear input field
  64. },
  65.  
  66. displayTargetList() {
  67. // ... (Display the list of monitored targets in the #targetList div) ...
  68. },
  69.  
  70. checkTrucesAndAP() {
  71. this.targets.forEach(target => {
  72. // ... (Your logic to check truce and AP expiration for the target) ...
  73. // This might involve fetching player data using the API or
  74. // monitoring the game UI for changes.
  75.  
  76. // Example (assuming you have functions to check truce and AP):
  77. const truceEnds = getTruceEndTime(target);
  78. const apEnds = getAPEndTime(target);
  79.  
  80. if (truceEnds) {
  81. this.displayTruceInfo(target, truceEnds);
  82. }
  83.  
  84. if (apEnds) {
  85. this.displayAPInfo(target, apEnds);
  86. }
  87. });
  88. },
  89.  
  90. displayTruceInfo(target, endTime) {
  91. // ... (Display truce information for the target, including end time) ...
  92. const timeLeft = endTime - unixTime();
  93. if (timeLeft <= 0) { // Truce has ended
  94. this.notifyTruceEnded(target);
  95. } else {
  96. // ... (Display time remaining) ...
  97. }
  98. },
  99.  
  100. displayAPInfo(target, endTime) {
  101. // ... (Display AP information for the target, including end time) ...
  102. const timeLeft = endTime - unixTime();
  103. if (timeLeft <= 0) { // AP has ended
  104. this.notifyAPEnded(target);
  105. } else {
  106. // ... (Display time remaining) ...
  107. }
  108. },
  109.  
  110. notifyTruceEnded(target) {
  111. // ... (Notify the user that the target's truce has ended) ...
  112. // This could be a chat message, sound alert, or other notification.
  113. this.updateStatus(`Target ${target.name}'s truce has ended!`);
  114. },
  115.  
  116. notifyAPEnded(target) {
  117. // ... (Notify the user that the target's AP has ended) ...
  118. this.updateStatus(`Target ${target.name}'s AP has ended!`);
  119. },
  120.  
  121.  
  122. updateStatus(message) {
  123. $("#truceMonitorStatus").html(message);
  124. },
  125.  
  126. // ... (Implement saveTargets and loadTargets using GM_setValue or IndexedDB) ...
  127.  
  128. show() {
  129. this.loadTargets(); // Load saved targets
  130. this.displayTargetList();
  131. },
  132.  
  133. hide() {
  134. // ...
  135. },
  136.  
  137. EverySecond: function() {
  138. this.checkTrucesAndAP();
  139. }
  140. };

QingJ © 2025

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