From 5b9da606fd38ee3a1a6a3d44d044f1c00c389cf6 Mon Sep 17 00:00:00 2001 From: ashley Date: Thu, 24 Oct 2024 19:41:07 +0000 Subject: [PATCH] add limit speed cpu --- css/app.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/css/app.js b/css/app.js index a6a81d17..1648d8ce 100644 --- a/css/app.js +++ b/css/app.js @@ -335,23 +335,15 @@ speedOption.addEventListener("click", function() { var currentSpeed = video.playbackRate; var newSpeed = getNextSpeed(currentSpeed); - if (navigator.hardwareConcurrency < 3) { - var userChoice = confirm( - "Your system has less than 3 CPU cores ;_; Increasing the video speed will CPU usage and affect performance - Do u want to continue?" - ); - - if (!userChoice) { - return; - } - } - video.playbackRate = newSpeed; document.getElementById("aud").playbackRate = newSpeed; speedOption.innerHTML = " Speed: " + newSpeed.toFixed(2) + "x"; }); function getNextSpeed(currentSpeed) { - if (currentSpeed === 2) { + var maxSpeed = (navigator.hardwareConcurrency < 3) ? 1 : 2; // Limit max speed based on CPU cores - for optimization + + if (currentSpeed === maxSpeed) { return 0.25; } else if (currentSpeed === 0.25) { return 0.5; @@ -360,9 +352,10 @@ function getNextSpeed(currentSpeed) { } else if (currentSpeed === 0.75) { return 1; } else { - return 2; + return maxSpeed; } } + const GoogleTranslateEndpoint = "https://translate.google.com/_/TranslateWebserverUi/data/batchexecute?rpcids=MkEWBc&rt=c" // @license-end \ No newline at end of file