File tree Expand file tree Collapse file tree 1 file changed +15
-13
lines changed
Expand file tree Collapse file tree 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -14,22 +14,24 @@ function updateStorage() {
1414
1515function backgroundCheck ( ) {
1616 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 ) {
17+ if ( currentWindow . focused ) {
18+ var activeTab = currentWindow . tabs . find ( t => t . active === true ) ;
19+ if ( activeTab !== undefined && activity . isValidPage ( activeTab ) ) {
2020 var activeUrl = activity . extractHostname ( activeTab . url ) ;
2121 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- chrome . browserAction . setBadgeText ( {
27- tabId : activeTab . id ,
28- text : String ( convertSummaryTimeToString ( tab . summaryTime ) )
29- } ) ;
30- }
31- } ) ;
22+ if ( tab === undefined ) {
23+ activity . addTab ( activeTab ) ;
3224 }
25+
26+ chrome . idle . queryState ( SETTINGS_INTERVAL_INACTIVITY , function ( state ) {
27+ if ( state === 'active' ) {
28+ tab . summaryTime += 1 ;
29+ chrome . browserAction . setBadgeText ( {
30+ tabId : activeTab . id ,
31+ text : String ( convertSummaryTimeToString ( tab . summaryTime ) )
32+ } ) ;
33+ }
34+ } ) ;
3335 }
3436 }
3537 } ) ;
You can’t perform that action at this time.
0 commit comments