mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-08-22 02:18:45 -04:00
Moved ratechange listener into its own function
Placed call for adding listener after call to document ready/disabled check Placed setupListener within try/catch block
This commit is contained in:
18
inject.js
18
inject.js
@@ -374,11 +374,7 @@ function refreshCoolDown() {
|
|||||||
log("End refreshCoolDown", 5);
|
log("End refreshCoolDown", 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeWhenReady(document) {
|
function setupListener() {
|
||||||
log("Begin initializeWhenReady", 5);
|
|
||||||
if (isBlacklisted()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
document.body.addEventListener(
|
document.body.addEventListener(
|
||||||
"ratechange",
|
"ratechange",
|
||||||
function(event) {
|
function(event) {
|
||||||
@@ -391,6 +387,13 @@ function initializeWhenReady(document) {
|
|||||||
},
|
},
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initializeWhenReady(document) {
|
||||||
|
log("Begin initializeWhenReady", 5);
|
||||||
|
if (isBlacklisted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
initializeNow(window.document);
|
initializeNow(window.document);
|
||||||
};
|
};
|
||||||
@@ -449,6 +452,11 @@ function initializeNow(document) {
|
|||||||
if (!document.body || document.body.classList.contains("vsc-initialized")) {
|
if (!document.body || document.body.classList.contains("vsc-initialized")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
setupListener();
|
||||||
|
} catch {
|
||||||
|
// no operation
|
||||||
|
}
|
||||||
document.body.classList.add("vsc-initialized");
|
document.body.classList.add("vsc-initialized");
|
||||||
log("initializeNow: vsc-initialized added to document body", 5);
|
log("initializeNow: vsc-initialized added to document body", 5);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user