Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7
Browse files Browse the repository at this point in the history
Fixed "setting the speed on the fly"
  • Loading branch information
avi12 committed Nov 28, 2021
2 parents 765bb44 + 5d674a8 commit 617da7e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/scripts/ytsc-content-script-initialize.ts
Expand Up @@ -10,11 +10,13 @@ declare global {
interface Window {
ytscLastSpeedSet: number;
ytscLastSpeedRateSet: SpeedRate;
ytscIsSetSpeedByStorage: boolean;
}
}

window.ytscLastSpeedSet = null;
window.ytscLastSpeedRateSet = null;
window.ytscIsSetSpeedByStorage = true;

const gObserverOptions = {
childList: true,
Expand Down Expand Up @@ -55,6 +57,7 @@ function addTemporaryBodyListener(): void {

window.ytscLastSpeedSet = null;
window.ytscLastSpeedRateSet = null;
window.ytscIsSetSpeedByStorage = true;
injectPlaybackText();

await prepareToChangeSpeed();
Expand All @@ -64,7 +67,7 @@ function addTemporaryBodyListener(): void {

function addStorageListener(): void {
chrome.storage.onChanged.addListener(() => {
if (!window.ytscLastSpeedSet) {
if (window.ytscIsSetSpeedByStorage) {
prepareToChangeSpeed();
}
});
Expand All @@ -79,6 +82,7 @@ function addKeyboardListener(): void {
document.activeElement.getAttribute("contenteditable") === "true";

if (elVideo && isPressedToChangeSpeed && !isFocusedOnInput) {
window.ytscIsSetSpeedByStorage = false;
await changeSpeedManuallyIfNeeded(elVideo, e.key);
}
});
Expand Down

0 comments on commit 617da7e

Please sign in to comment.