conq

test

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

  1. Tabs.Conquest = {
  2. tabOrder: 1000,
  3. tabLabel: 'Conquest',
  4. tabDisabled: false,
  5. myDiv: null,
  6. timer: null,
  7. options: { // Encapsulate options within the tab
  8. enabled: false,
  9. interval: 60 // Default interval in minutes
  10. },
  11.  
  12. init: function(div) {
  13. var t = Tabs.Conquest;
  14. t.myDiv = div;
  15.  
  16. // Load options from storage (if available)
  17. t.loadOptions();
  18.  
  19. t.createUI();
  20. },
  21.  
  22. createUI: function() {
  23. var t = Tabs.Conquest;
  24. var m = '<DIV class=divHeader align=center>' + tx('CONQUEST') + '</div>';
  25.  
  26. m += '<div id="ConquestContent" style="padding:10px;">';
  27. m += '<table width="100%">';
  28. m += '<tr><td><INPUT id=btConquestEnabled type=checkbox ' + (t.options.enabled ? ' CHECKED' : '') + '> ' + tx('Enable Conquest') + '</td>';
  29. m += '<td>' + tx('Conquest Interval') + ': <INPUT id=btConquestInterval type=text size=3 value="' + t.options.interval + '"> ' + tx('minutes') + '</td></tr>';
  30. m += '</table>';
  31.  
  32. m += '<hr>';
  33. m += '<div id="ConquestStatus"></div>';
  34. m += '<div id="ConquestLog" style="height:400px; overflow-y:auto;"></div>';
  35. m += '</div>';
  36.  
  37. t.myDiv.innerHTML = m;
  38.  
  39. // Add event listeners
  40. ById('btConquestEnabled').addEventListener('change', function() {
  41. t.options.enabled = this.checked;
  42. t.saveOptions();
  43. t.toggleConquest();
  44. }, false);
  45.  
  46. ById('btConquestInterval').addEventListener('change', function() {
  47. var newInterval = parseInt(this.value);
  48. if (!isNaN(newInterval) && newInterval > 0) {
  49. t.options.interval = newInterval;
  50. t.saveOptions();
  51. t.resetConquestTimer(); // Reset the timer with the new interval
  52. } else {
  53. alert('Invalid interval. Please enter a positive number.');
  54. this.value = t.options.interval; // Revert to the previous value
  55. }
  56. }, false);
  57.  
  58. t.toggleConquest(); // Initial toggle
  59. },
  60.  
  61. loadOptions: function() {
  62. var t = Tabs.Conquest;
  63. // Load options from localStorage or similar mechanism
  64. // Example:
  65. var storedOptions = localStorage.getItem('ConquestOptions');
  66. if (storedOptions) {
  67. try {
  68. t.options = JSON.parse(storedOptions);
  69. } catch (e) {
  70. console.error('Error parsing Conquest options:', e);
  71. }
  72. }
  73. },
  74.  
  75. saveOptions: function() {
  76. var t = Tabs.Conquest;
  77. // Save options to localStorage or similar mechanism
  78. // Example:
  79. localStorage.setItem('ConquestOptions', JSON.stringify(t.options));
  80. },
  81.  
  82. toggleConquest: function() {
  83. var t = Tabs.Conquest;
  84. if (t.options.enabled) {
  85. t.start();
  86. ById('ConquestStatus').innerHTML = '<b>' + tx('Conquest is ACTIVE') + '</b>';
  87. } else {
  88. t.stop();
  89. ById('ConquestStatus').innerHTML = '<b>' + tx('Conquest is INACTIVE') + '</b>';
  90. }
  91. },
  92.  
  93. start: function() {
  94. var t = Tabs.Conquest;
  95. if (t.timer == null) {
  96. t.timer = setInterval(t.doConquest.bind(t), t.options.interval * 60 * 1000); // Use bind to maintain the correct 'this' context
  97. t.doConquest(); // Run immediately
  98. }
  99. },
  100.  
  101. stop: function() {
  102. var t = Tabs.Conquest;
  103. if (t.timer != null) {
  104. clearInterval(t.timer);
  105. t.timer = null;
  106. }
  107. },
  108.  
  109. resetConquestTimer: function() {
  110. var t = Tabs.Conquest;
  111. t.stop(); // Stop the existing timer
  112. t.start(); // Start a new timer with the updated interval
  113. },
  114.  
  115. doConquest: function() {
  116. var t = Tabs.Conquest;
  117. // Implement your conquest logic here
  118. // This function will be called every X minutes (based on the interval set)
  119.  
  120. // For example:
  121. var log = ById('ConquestLog');
  122. if (log) {
  123. log.innerHTML += '<div>' + new Date().toLocaleString() + ': Conquest action performed</div>';
  124. log.scrollTop = log.scrollHeight;
  125. } else {
  126. console.error('ConquestLog element not found!');
  127. }
  128. },
  129.  
  130. // Add more functions as needed for your conquest logic
  131. };

QingJ © 2025

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