// ==UserScript== // @name tenda index // @namespace http://tampermonkey.net/ // @version 2024-01-07 // @description try to take over the world! // @author You // @match http://192.168.0.1/index.html // @icon https://www.google.com/s2/favicons?sz=64&domain=0.1 // @grant none // ==/UserScript== (function () { 'use strict'; // Your code here... // Define a function that performs the desired actions for bandwidth control function toggleBandwidthControl() { try { return new Promise((resolve) => { let okBtnBoolBand = false; setTimeout(() => { let netCtrNavWrap = document.querySelector("#netCtrNavWrap"); netCtrNavWrap && netCtrNavWrap.click(); console.log("Clicked the bandwidth control wrapper"); }, 5000); setTimeout(() => { try { const blackListDevices = document.querySelector("#qosListAccess"); if (blackListDevices) { const childCount = blackListDevices.childElementCount; if (childCount > 7) { for (let i = 0; i < childCount; i++) { setTimeout(() => { const deviceToRemove = blackListDevices.childNodes[0].childNodes[2].childNodes[0]; deviceToRemove.click(); console.log(`Removed device from the blacklist`); }, 1000 * i); } } } else { console.log("No need to unlimit yet") } } catch (error) { console.log("blacklist is empty"); } const excludedDevices = ["abdiz", "Abdinasir", "Galaxy-A02s", "Redmi 9c Hooyo", "iPhone", "Abdisalam-S22-Ultra", "liban", "as", "abdullahi", "raspberrypi"]; Array.from(qosList.children).forEach((child) => { let deviceName = child.innerText; if (!excludedDevices.some(keyword => deviceName.includes(keyword))) { console.log(`Found ${deviceName}`); okBtnBoolBand = true; let unknown = child; let toggleElement = unknown.childNodes[5]?.childNodes[0]; if (toggleElement && toggleElement.classList.contains("toggle-on-icon")) { console.log("The toggle is off"); toggleElement.classList.replace("toggle-on-icon", "toggle-off-icon"); console.log("Changed the toggle to on"); } else { console.log("The toggle is on, so we don't need to do anything"); blackList = false } } }); setTimeout(() => { let okButton = document.querySelector(".btn.btn-frist.btn-primary"); if (okButton && okBtnBoolBand) { okButton.click(); console.log("Clicked the OK button"); } else { console.log("No need to click the OK button"); } resolve(); // Resolve the promise to signal completion }, 5000); }, 10000); }); } catch (error) { console.log(error); } } // Run the functions sequentially with a delay in between async function runSequentially() { while (true) { try { await toggleBandwidthControl(); await new Promise(resolve => setTimeout(resolve, 15000)); // Wait for 1 minute before repeating } catch (error) { console.log(error); // reload the page window.location.reload(); } } } console.log("Waiting 1 min before starting the sequence"); // Start the sequence setTimeout(() => { runSequentially(); }, 60000); // Log a success message console.log("The function is running successfully"); })();