@@ -3,12 +3,10 @@ import Messenger from "./messenger";
3
3
import TabManager from "./tab-manager" ;
4
4
import UserStorage from "./user-storage" ;
5
5
import {
6
- getFontList ,
7
6
getCommands ,
8
7
setShortcut ,
9
8
canInjectScript
10
9
} from "./utils/extension-api" ;
11
- import { isInTimeInterval , getDuration } from "../utils/time" ;
12
10
import { isURLInList , getURLHost , isURLEnabled } from "../utils/url" ;
13
11
import ThemeEngines from "../generators/theme-engines" ;
14
12
import createCSSFilterStylesheet from "../generators/css-filter" ;
@@ -27,13 +25,10 @@ import {
27
25
TabInfo
28
26
} from "../definitions" ;
29
27
30
- const AUTO_TIME_CHECK_INTERVAL = getDuration ( { seconds : 10 } ) ;
31
-
32
28
export class Extension {
33
29
ready : boolean ;
34
30
35
31
config : ConfigManager ;
36
- fonts : string [ ] ;
37
32
messenger : Messenger ;
38
33
tabs : TabManager ;
39
34
user : UserStorage ;
@@ -52,24 +47,14 @@ export class Extension {
52
47
}
53
48
54
49
isEnabled ( ) {
55
- if ( this . user . settings . automation === "time" ) {
56
- const now = new Date ( ) ;
57
- return isInTimeInterval (
58
- now ,
59
- this . user . settings . time . activation ,
60
- this . user . settings . time . deactivation
61
- ) ;
62
- }
63
50
return this . user . settings . enabled ;
64
51
}
65
52
66
53
private awaiting : ( ( ) => void ) [ ] ;
67
54
68
55
async start ( ) {
69
56
await this . config . load ( { local : true } ) ;
70
- this . fonts = await getFontList ( ) ;
71
57
72
- await this . user . loadSettings ( ) ;
73
58
this . changeSettings ( this . user . settings ) ;
74
59
console . log ( "loaded" , this . user . settings ) ;
75
60
@@ -81,7 +66,6 @@ export class Extension {
81
66
this . awaiting . forEach ( ready => ready ( ) ) ;
82
67
this . awaiting = null ;
83
68
84
- this . startAutoTimeCheck ( ) ;
85
69
this . user . cleanup ( ) ;
86
70
}
87
71
@@ -121,8 +105,7 @@ export class Extension {
121
105
if ( command === "toggle" ) {
122
106
console . log ( "Toggle command entered" ) ;
123
107
this . changeSettings ( {
124
- enabled : ! this . isEnabled ( ) ,
125
- automation : ""
108
+ enabled : ! this . isEnabled ( )
126
109
} ) ;
127
110
}
128
111
if ( command === "addSite" ) {
@@ -157,7 +140,6 @@ export class Extension {
157
140
isEnabled : this . isEnabled ( ) ,
158
141
isReady : this . ready ,
159
142
settings : this . user . settings ,
160
- fonts : this . fonts ,
161
143
shortcuts : await this . getShortcuts ( )
162
144
} ;
163
145
}
@@ -174,25 +156,7 @@ export class Extension {
174
156
}
175
157
}
176
158
177
- private wasEnabledOnLastCheck : boolean ;
178
-
179
- private startAutoTimeCheck ( ) {
180
- setInterval ( ( ) => {
181
- if ( ! this . ready || this . user . settings . automation !== "time" ) {
182
- return ;
183
- }
184
- const isEnabled = this . isEnabled ( ) ;
185
- if ( this . wasEnabledOnLastCheck !== isEnabled ) {
186
- this . wasEnabledOnLastCheck = isEnabled ;
187
- this . tabs . sendMessage ( this . getTabMessage ) ;
188
- this . reportChanges ( ) ;
189
- }
190
- } , AUTO_TIME_CHECK_INTERVAL ) ;
191
- }
192
-
193
159
changeSettings ( $settings : Partial < UserSettings > ) {
194
- const prev = { ...this . user . settings } ;
195
-
196
160
this . user . set ( $settings ) ;
197
161
this . onSettingsChanged ( ) ;
198
162
}
@@ -239,7 +203,6 @@ export class Extension {
239
203
return ;
240
204
}
241
205
242
- this . wasEnabledOnLastCheck = this . isEnabled ( ) ;
243
206
this . tabs . sendMessage ( this . getTabMessage ) ;
244
207
this . saveUserSettings ( ) ;
245
208
this . reportChanges ( ) ;
@@ -342,7 +305,6 @@ export class Extension {
342
305
// User settings
343
306
344
307
private async saveUserSettings ( ) {
345
- await this . user . saveSettings ( ) ;
346
308
console . log ( "saved" , this . user . settings ) ;
347
309
}
348
310
}
0 commit comments