Skip to content

Commit

Permalink
clear timeout on terminate
Browse files Browse the repository at this point in the history
  • Loading branch information
nunsez committed Sep 26, 2024
1 parent d46e8b7 commit ad07961
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions dist/bookmarklet-video-speed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @file A script to control the speed of html5 video playback in the browser.
* @author Alexander Mandrikov <mad.nunsez@gmail.com>
* @version 2.1.0
* @version 2.1.1
* @license AGPLv3
* @see {@link https://github.com/nunsez/bookmarklet-video-speed GitHub} for further information.
*/
Expand All @@ -27,7 +27,7 @@ const STYLES =
`#${CONTROLLER_ID} .range ~ * {display: none;}`;

interface MyElement extends HTMLDivElement {
[STATE_ID]?: State
[STATE_ID]?: State;
}

function addStyles(document: Document) {
Expand Down Expand Up @@ -101,8 +101,8 @@ class State {
}

refresh(_mutationRecords: MutationRecord[]) {
console.log('_mutationRecords', _mutationRecords)
console.log('refresh', this.searchTimeoutId, this.controller);
console.log("_mutationRecords", _mutationRecords);
console.log("refresh", this.searchTimeoutId, this.controller);
clearTimeout(this.searchTimeoutId);

this.searchTimeoutId = setTimeout(() => {
Expand All @@ -112,8 +112,10 @@ class State {
}

terminate() {
console.log('terminate observer', this.observer)
console.log('terminate oldController', this.controller)
console.log("terminate observer", this.observer);
console.log("terminate oldController", this.controller);
console.log("terminate searchTimeoutId", this.searchTimeoutId);
clearTimeout(this.searchTimeoutId);
this.observer.disconnect();
this.controller.el.remove();
this.videos.forEach((v) => v.playbackRate = DEFAULT_SPEED / 100);
Expand All @@ -140,7 +142,7 @@ class State {
this.controller.range.value = speedString;
this.videos.forEach((v) => v.playbackRate = this.speed / 100);

console.log('set speed', this.videos, this.controller);
console.log("set speed", this.videos, this.controller);

localStorage.setItem(STORAGE_ID, speedString);
}
Expand Down

0 comments on commit ad07961

Please sign in to comment.