@@ -19,6 +19,7 @@ function updateStorage() {
1919}
2020
2121function backgroundCheck ( ) {
22+ loadBlackList ( ) ;
2223 storage . getSettings ( SETTINGS_INTERVAL_INACTIVITY , function ( item ) { setting_interval_inactivity = item ; } ) ;
2324 storage . getSettings ( SETTINGS_VIEW_TIME_IN_BADGE , function ( item ) { setting_view_in_badge = item ; } ) ;
2425 chrome . windows . getLastFocused ( { populate : true } , function ( currentWindow ) {
@@ -37,23 +38,39 @@ function backgroundCheck() {
3738 if ( state === 'active' ) {
3839 if ( ! activity . isInBlackList ( activeUrl ) )
3940 tab . incSummaryTime ( ) ;
40- //todo: сделать, чтобы, если страница в черном списке,
41- //то показываем крестик на badge text
4241 if ( setting_view_in_badge === true ) {
43- var today = new Date ( ) . toLocaleDateString ( ) ;
44- var summary = tab . days . find ( s => s . date === today ) . summary ;
45- chrome . browserAction . setBadgeText ( {
46- tabId : activeTab . id ,
47- text : String ( convertSummaryTimeToBadgeString ( summary ) )
48- } ) ;
42+ if ( activity . isInBlackList ( activeUrl ) ) {
43+ chrome . browserAction . setBadgeBackgroundColor ( { color : '#FF0000' } )
44+ chrome . browserAction . setBadgeText ( {
45+ tabId : activeTab . id ,
46+ text : 'n/a'
47+ } ) ;
48+ } else {
49+ chrome . browserAction . setBadgeBackgroundColor ( { color : [ 0 , 0 , 0 , 0 ] } )
50+ var today = new Date ( ) . toLocaleDateString ( ) ;
51+ var summary = tab . days . find ( s => s . date === today ) . summary ;
52+ chrome . browserAction . setBadgeText ( {
53+ tabId : activeTab . id ,
54+ text : String ( convertSummaryTimeToBadgeString ( summary ) )
55+ } ) ;
56+ }
4957 } else {
58+ chrome . browserAction . setBadgeBackgroundColor ( { color : [ 0 , 0 , 0 , 0 ] } )
5059 chrome . browserAction . setBadgeText ( {
5160 tabId : activeTab . id ,
5261 text : ''
5362 } ) ;
5463 }
5564 }
5665 } ) ;
66+ } else {
67+ if ( activity . isInBlackList ( activeUrl ) ) {
68+ chrome . browserAction . setBadgeBackgroundColor ( { color : '#FF0000' } )
69+ chrome . browserAction . setBadgeText ( {
70+ tabId : activeTab . id ,
71+ text : 'n/a'
72+ } ) ;
73+ }
5774 }
5875 }
5976 }
@@ -73,8 +90,8 @@ function setDefaultSettings() {
7390}
7491
7592function checkSettingsImEmpty ( ) {
76- chrome . storage . local . getBytesInUse ( [ 'inactivity_interval' ] , function ( item ) {
77- if ( item == 0 ) {
93+ chrome . storage . local . getBytesInUse ( [ 'inactivity_interval' ] , function ( item ) {
94+ if ( item == 0 ) {
7895 setDefaultSettings ( ) ;
7996 }
8097 } ) ;
@@ -111,8 +128,8 @@ function loadTabs() {
111128 } ) ;
112129}
113130
114- function loadBlackList ( ) {
115- storage . getSettings ( STORAGE_BLACK_LIST , function ( items ) {
131+ function loadBlackList ( ) {
132+ storage . getSettings ( STORAGE_BLACK_LIST , function ( items ) {
116133 setting_black_list = items ;
117134 } )
118135}
0 commit comments