File tree Expand file tree Collapse file tree 4 files changed +25
-5
lines changed
Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 1818 "permissions" : [
1919 " tabs" ,
2020 " activeTab" ,
21- " storage"
21+ " storage" ,
22+ " idle"
2223 ],
2324 "background" : {
2425 "scripts" : [" scripts/common.js" ,
Original file line number Diff line number Diff line change @@ -10,6 +10,23 @@ chrome.tabs.onActivated.addListener(function (info) {
1010 } ) ;
1111} ) ;
1212
13- chrome . windows . getLastFocused ( { populate : true } , function ( window ) {
14- var s = window ;
15- } ) ;
13+ setInterval ( backgroundCheck , SETTINGS_INTERVAL_CHECK ) ;
14+
15+ function backgroundCheck ( ) {
16+ chrome . windows . getLastFocused ( { populate : true } , function ( currentWindow ) {
17+ if ( tabs . length > 0 ) {
18+ var activeTab = currentWindow . tabs . find ( o => o . active === true ) ;
19+ if ( activeTab !== undefined ) {
20+ var activeUrl = activity . extractHostname ( activeTab . url ) ;
21+ var tab = activity . getTab ( activeUrl ) ;
22+ if ( tab !== undefined ) {
23+ chrome . idle . queryState ( SETTINGS_INTERVAL_INACTIVITY , function ( state ) {
24+ if ( state === 'active' ) {
25+ tab . summaryTime += 1 ;
26+ }
27+ } ) ;
28+ }
29+ }
30+ }
31+ } ) ;
32+ }
Original file line number Diff line number Diff line change 11var STORAGE_TABS = 'tabs' ;
2+ var SETTINGS_INTERVAL_INACTIVITY = 30 ;
3+ var SETTINGS_INTERVAL_CHECK = 1000 ;
24
35function isEmpty ( obj ) {
46 for ( var prop in obj ) {
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ class Tab {
44 constructor ( url , favicon ) {
55 this . url = url ;
66 this . favicon = favicon ;
7- this . summaryTime = '' ;
7+ this . summaryTime = 0 ;
88 }
99} ;
You can’t perform that action at this time.
0 commit comments