-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstate.js
More file actions
54 lines (49 loc) · 1.25 KB
/
state.js
File metadata and controls
54 lines (49 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Global state management
window.FastVideo = window.FastVideo || {
// Configuration
config: {
rewindDuration: 5,
normalSpeedDuration: 3,
transitionDuration: 0.3
},
// State tracking
videoStates: new WeakMap(),
// State management methods
getVideoState(video) {
if (!this.videoStates.has(video)) {
this.videoStates.set(video, {
originalSpeed: video.playbackRate,
isInUndo: false,
undoTimeout: null
});
}
return this.videoStates.get(video);
},
// Configuration methods
updateConfig(newConfig) {
return new Promise((resolve) => {
Object.assign(this.config, newConfig);
chrome.runtime.sendMessage({
type: 'updateConfig',
config: this.config
}, () => {
resolve(this.config);
});
});
},
// Initialize config from storage
initConfig() {
return new Promise((resolve) => {
chrome.runtime.sendMessage({ type: 'getConfig' }, (storedConfig) => {
if (Object.keys(storedConfig).length > 0) {
Object.assign(this.config, storedConfig);
}
resolve(this.config);
});
});
}
};
// Initialize config from storage
window.FastVideo.initConfig().then(config => {
window.DEFAULT_CONFIG = config;
});