@@ -180,6 +180,27 @@ function saveUrlToData(enabled, time = 0) {
180
180
} ) ;
181
181
}
182
182
}
183
+
184
+ if ( timeSpentToday >= 0 && timeSpentToday < 60 * 30 ) {
185
+ //30 minutes || OK
186
+ changeIcon ( 0 ) ;
187
+ setBadgeText ( ( ( timeSpentToday - ( timeSpentToday % 60 ) ) / 60 ) . toString ( ) + "m" ) ;
188
+ } else if ( timeSpentToday >= 60 * 30 && timeSpentToday < 60 * 60 ) {
189
+ //60 minutes (1 hour) || Yellow
190
+ changeIcon ( 2 ) ;
191
+ createNotification ( 2 , currentUrl , "30 minutes" , "You have already spent 30 minutes on this site today" ) ;
192
+ setBadgeText ( ( ( timeSpentToday - ( timeSpentToday % 60 ) ) / 60 ) . toString ( ) + "m" , "#FFD400" , "#000000" ) ;
193
+ } else if ( timeSpentToday >= 60 * 60 && timeSpentToday < 60 * 60 * 3 ) {
194
+ //3 hours || Orange
195
+ changeIcon ( 3 ) ;
196
+ createNotification ( 3 , currentUrl , "1 hour" , "You have already spent 1 hour on this site today" ) ;
197
+ setBadgeText ( ( ( timeSpentToday - ( timeSpentToday % ( 60 * 60 ) ) ) / ( 60 * 60 ) ) . toString ( ) + "h" , "#FF7C00" , "#000000" ) ;
198
+ } else if ( timeSpentToday >= 60 * 60 * 3 ) {
199
+ //>3 hours || Red
200
+ changeIcon ( 4 ) ;
201
+ createNotification ( 4 , currentUrl , "3 hours" , "You have already spent 3 hours on this site today" ) ;
202
+ setBadgeText ( ">3h" , "#FF0000" ) ;
203
+ }
183
204
} )
184
205
}
185
206
@@ -265,29 +286,6 @@ function increaseTime(url) {
265
286
if ( url == currentUrl ) {
266
287
saveUrlToData ( true , 1 ) ;
267
288
}
268
-
269
- if ( timeSpentToday >= 0 && timeSpentToday < 60 * 30 ) {
270
- //30 minutes || OK
271
- changeIcon ( 0 ) ;
272
- setBadgeText ( ( ( timeSpentToday - ( timeSpentToday % 60 ) ) / 60 ) . toString ( ) + "m" ) ;
273
- } else if ( timeSpentToday >= 60 * 30 && timeSpentToday < 60 * 60 ) {
274
- //60 minutes (1 hour) || Yellow
275
- changeIcon ( 2 ) ;
276
- createNotification ( 2 , currentUrl , "30 minutes" , "You have already spent 30 minutes on this site today" ) ;
277
- setBadgeText ( ( ( timeSpentToday - ( timeSpentToday % 60 ) ) / 60 ) . toString ( ) + "m" , "#FFD400" , "#000000" ) ;
278
- } else if ( timeSpentToday >= 60 * 60 && timeSpentToday < 60 * 60 * 3 ) {
279
- //3 hours || Orange
280
- changeIcon ( 3 ) ;
281
- createNotification ( 3 , currentUrl , "1 hour" , "You have already spent 1 hour on this site today" ) ;
282
- setBadgeText ( ( ( timeSpentToday - ( timeSpentToday % ( 60 * 60 ) ) ) / ( 60 * 60 ) ) . toString ( ) + "h" , "#FF7C00" , "#000000" ) ;
283
- } else if ( timeSpentToday >= 60 * 60 * 3 ) {
284
- //>3 hours || Red
285
- changeIcon ( 4 ) ;
286
- createNotification ( 4 , currentUrl , "3 hours" , "You have already spent 1 hours on this site today" ) ;
287
- setBadgeText ( ">3h" , "#FF0000" ) ;
288
- }
289
-
290
- //console.log("All websites: " + JSON.stringify(websites_json));
291
289
}
292
290
}
293
291
@@ -342,4 +340,4 @@ function setBadgeText(text, background_color = "#0080FF", text_color = "#FFFFFF"
342
340
browser . browserAction . setBadgeBackgroundColor ( { color : background_color } ) ;
343
341
}
344
342
345
- loaded ( ) ;
343
+ loaded ( ) ;
0 commit comments