// ==UserScript== // @name Fix Aternos Site // @namespace http://tampermonkey.net/ // @version 0.5 // @description Fixes site design issues, and has a blocks ads somehow i have asked some users to say whats the most annoing thing about the aternos ui some told me is the slow load times coused by ads and auto playing videos and some ask my somthing else // @author You // @match https://aternos.org/* // @icon https://www.google.com/s2/favicons?sz=64&domain=aternos.org // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Variable to track whether content is already being replaced let isContentReplaced = false; let sidebaron = false; // Set this to true if you want to enable the sidebar, false otherwise. let canClickDivs = true; // The target text to search for const targetText = 'Continue with adblocker anyway'; // Function to remove elements by class name function removeElementsByClass(classNames) { classNames.forEach(className => { const elements = document.querySelectorAll(`.${className}`); elements.forEach(element => element.remove()); }); } // Function to replace the content of an element by class name function replaceContentByClass(className, newContent) { const elements = document.querySelectorAll(`.${className}`); elements.forEach(element => { // Avoid redundant replacement if the content is already replaced if (!isContentReplaced) { element.innerHTML = newContent; isContentReplaced = true; // Set flag to prevent infinite changes } }); } // Function to click divs that meet a specific condition (auto-click for adblocker prompt) function clickDivsBasedOnCondition() { if (!canClickDivs) return; // Exit the function if clicking is not allowed const divs = document.querySelectorAll('div'); divs.forEach(div => { // Click if div contains the target text if (div.textContent.trim().toLowerCase() === targetText.toLowerCase()) { div.click(); } }); } // Function to stop clicking divs function stopClickingDivs() { canClickDivs = false; } // Function to remove an element with exact styles function removeElementWithExactStyles() { const allElements = document.querySelectorAll('*'); allElements.forEach((element) => { const style = window.getComputedStyle(element); if ( style.display === 'inline' && style.position === 'fixed' && style.left === '0px' && style.bottom === '0px' && style.width === '100%' && style.minWidth === '100%' && style.backdropFilter === 'none' && style.backgroundColor === 'rgba(255, 255, 255, 0.83)' && style.zIndex === '2147483646' && style.textAlign === 'center' && style.fontSize === '0px' && style.lineHeight === '0' && style.pointerEvents === 'none' && style.overflow === 'clip' && style.overflowClipMargin === 'content-box' && style.minHeight === '20px' ) { element.parentNode.removeChild(element); } }); } // Function to set the height of the header-right element function adjustHeaderHeight() { const header = document.querySelector('.header-right'); if (header) { header.style.height = '100px'; header.style.position = 'fixed'; // Ensure it's fixed header.style.right = '16px'; // Preserve the right alignment } } // Specify the classes to remove based on sidebaron flag let classesToRemove = [ 'responsive-leaderboard', 'ad-dfp', 'server-b-tutorials', 'header-center', 'fa-ban' ]; // Remove sidebar-related class if sidebaron is false if (!sidebaron) { classesToRemove.push('sidebar'); // Remove the sidebar if sidebaron is false } else { // If sidebaron is true, you can modify the sidebar's content or do nothing let classToModify = 'sidebar'; let newSidebarContent = ` `; replaceContentByClass(classToModify, newSidebarContent); // Replace sidebar content when sidebaron is true } // Observe changes in the DOM for the removal of classes and content replacement const observer = new MutationObserver(mutations => { mutations.forEach(() => { adjustHeaderHeight(); // Ensure the header-right height is adjusted dynamically removeElementsByClass(classesToRemove); removeElementWithExactStyles(); // Check and remove elements with exact styles clickDivsBasedOnCondition(); // Check for divs meeting the condition }); }); // Start observing the body for added nodes (subtree includes all descendants) observer.observe(document.body, { childList: true, subtree: true }); // Initial cleanup, replacement, and button click in case the elements already exist adjustHeaderHeight(); // Set header-right height initially removeElementsByClass(classesToRemove); removeElementWithExactStyles(); // Check and remove elements with exact styles initially clickDivsBasedOnCondition(); // Check and click matching divs initially // Optionally, call stopClickingDivs at a certain time or condition to disable clicking })();