Aternos Ultimate Script 2024

Implemented adblock, automatically extends the server time and automatically starts the server.

当前为 2024-05-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Aternos Ultimate Script 2024
  3. // @namespace Mite's Scripts
  4. // @version 1.0.1
  5. // @description Implemented adblock, automatically extends the server time and automatically starts the server.
  6. // @author Mite
  7. // @match https://aternos.org/*
  8. // @icon https://upload.wikimedia.org/wikipedia/commons/thumb/1/10/Userbox_creeper.svg/567px-Userbox_creeper.svg.png
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Overriding Date.now to prevent adblock detection
  17. let oldDateNow = Date.now;
  18. unsafeWindow.Date.now = function () {
  19. try {
  20. throw new Error();
  21. } catch (e) {
  22. if (e.stack.includes('data:text/javascript')) {
  23. throw new Error();
  24. } else {
  25. return oldDateNow();
  26. }
  27. }
  28. };
  29.  
  30. // Intersection Observer to handle extend button
  31. const extendButtonObserver = new IntersectionObserver(handleIntersection, {
  32. root: null,
  33. rootMargin: '0px',
  34. threshold: 0.1
  35. });
  36.  
  37. function handleIntersection(entries, observer) {
  38. entries.forEach(entry => {
  39. if (entry.isIntersecting) {
  40. const extendButton = entry.target;
  41. if (extendButton.textContent.trim().toLowerCase() !== "stop") {
  42. extendButton.click();
  43. }
  44. observer.unobserve(extendButton);
  45. }
  46. });
  47. }
  48.  
  49. // Function to observe extend button visibility
  50. function checkButtonVisibility() {
  51. const extendButton = document.querySelector('.btn.btn-tiny.btn-success.server-extend-end');
  52. if (extendButton) {
  53. extendButtonObserver.observe(extendButton);
  54. } else {
  55. console.error('[Aternos Extend Server Time] Button not found.');
  56. }
  57. }
  58.  
  59. // Function to check the timer and extend server time at 0:30
  60. function checkTimerAndExtend() {
  61. const timerElement = document.querySelector('.server-end-countdown');
  62. if (timerElement) {
  63. const timerValue = timerElement.textContent.trim();
  64. if (timerValue === '0:30') {
  65. const extendButton = document.querySelector('.btn.btn-tiny.btn-success.server-extend-end');
  66. if (extendButton && extendButton.textContent.trim().toLowerCase() !== "stop") {
  67. extendButton.click();
  68. }
  69. }
  70. }
  71. }
  72.  
  73. // Function to check for white screen and refresh the page if detected
  74. function checkForWhiteScreen() {
  75. const whiteScreenElement = document.querySelector('.white-screen-element');
  76. if (whiteScreenElement) {
  77. console.error('[Aternos White Screen] White screen detected. Refreshing page...');
  78. window.location.reload();
  79. }
  80. }
  81.  
  82. // Function to check if the server is offline and click the "Start" button if it is
  83. function checkAndStartServerIfOffline() {
  84. const serverStatus = document.querySelector('.server-actions');
  85. if (serverStatus && serverStatus.classList.contains('offline')) {
  86. const startButton = document.querySelector('#start');
  87. if (startButton && startButton.offsetParent !== null) {
  88. startButton.click();
  89. }
  90. }
  91. }
  92.  
  93. // Function to click the "No" button if the alert dialog is present
  94. function clickNoButtonIfAlertPresent() {
  95. const alertDialog = document.querySelector('dialog.alert.alert-danger');
  96. if (alertDialog && alertDialog.open) {
  97. const noButton = alertDialog.querySelector('.btn-danger');
  98. if (noButton) {
  99. noButton.click();
  100. }
  101. }
  102. }
  103.  
  104. // Set up intervals to check continuously
  105. const checkInterval = 1000; // 1 second
  106. setInterval(checkButtonVisibility, checkInterval);
  107. setInterval(checkTimerAndExtend, checkInterval);
  108. setInterval(checkForWhiteScreen, checkInterval);
  109. setInterval(checkAndStartServerIfOffline, checkInterval);
  110. setInterval(clickNoButtonIfAlertPresent, checkInterval);
  111. })();