Created
November 19, 2020 21:31
-
-
Save ilyaskarim/61284772ee4a4b665f252d7b80da557f to your computer and use it in GitHub Desktop.
limit-speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var allSpeeds = document.querySelectorAll(".bEptLHDSpeeds"); | |
var limits = document.querySelectorAll(".bEptLHDDownLimit"); | |
allSpeeds.forEach((element, index) => { | |
element.setAttribute(`idx`, index); | |
}); | |
limits.forEach((element, index) => { | |
element.setAttribute(`computer-${index}-limit`, null); | |
}); | |
var limitUserSpeed = (el) => { | |
var id = el.getAttribute("idx") | |
var button = document.querySelector(`[computer-${id}-limit]`); | |
var downButton = button.querySelector(".bEptDownLSImg"); | |
console.log(button) | |
var label = button.querySelector("label"); | |
downButton.click() | |
var input = button.querySelector("input") | |
setTimeout(() => { | |
input.value = 300; | |
setTimeout(() => { | |
button.click() | |
}, 100); | |
}, 50); | |
}; | |
allSpeeds.forEach((element, index) => { | |
let speed = element.querySelector(".bEptHostSpeedB .bSpeedSpn"); | |
if (speed) { | |
var html = speed.innerHTML.split(" "); | |
var currentUserSpeed = html[0]; | |
var currentUserSpeedType = html[1].toLowerCase().replace(/ /g,"") | |
if (currentUserSpeedType === "kb/s") { | |
if (currentUserSpeed > 600) { | |
limitUserSpeed(element) | |
} | |
} else if (currentUserSpeedType === "mb/s") { | |
limitUserSpeed(element) | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment