@@ -62,7 +62,7 @@ chrome.browserAction.onClicked.addListener(function (tab) {
62
62
} )
63
63
64
64
function setEnabledBasedOnURIInBlacklist ( cb ) {
65
- chrome . tabs . query ( { active : true } , function ( tab ) {
65
+ chrome . tabs . query ( { active : true } , function ( tab ) {
66
66
if ( debug ) {
67
67
console . log ( 'is URI in blacklist?' )
68
68
console . log ( tab )
@@ -91,9 +91,9 @@ function showMinkBadgeInfoBasedOnProcessingState (tabid) {
91
91
function setBadgeTextBasedOnBrowserActionState ( tabid ) {
92
92
// TODO: This should not rely on the badge count to detect zero mementos, as badges are no longer used for no mementos present
93
93
// - maybe rely on the title, since the icon's src path cannot be had.
94
- chrome . browserAction . getBadgeText ( { tabId : tabid } , function ( result ) {
94
+ chrome . browserAction . getBadgeText ( { tabId : tabid } , function ( result ) {
95
95
if ( ! result . length && ! Number . isInteger ( result ) && result !== maxBadgeDisplay ) {
96
- chrome . browserAction . getTitle ( { tabId : tabid } , function ( result ) {
96
+ chrome . browserAction . getTitle ( { tabId : tabid } , function ( result ) {
97
97
// Only set badge text if not viewing a memento
98
98
if ( result === browserActionTitleNoMementos ) {
99
99
displayMinkUI ( tabid )
@@ -116,13 +116,18 @@ function setBadgeTextBasedOnBrowserActionState (tabid) {
116
116
return // Badge has not yet been set
117
117
}
118
118
if ( debug ) { console . log ( 'u' ) }
119
- displayMinkUI ( tabid )
119
+
120
+ chrome . browserAction . getBadgeText ( { tabId : tabid } , function ( currentBadgeText ) {
121
+ if ( currentBadgeText !== stillProcessingBadgeDisplay ) {
122
+ displayMinkUI ( tabid )
123
+ }
124
+ } )
120
125
} )
121
126
}
122
127
123
128
function displayMinkUI ( tabId ) {
124
129
if ( debug ) { console . log ( 'Injecting displayMinkUI.js' ) }
125
- chrome . tabs . executeScript ( tabId , { code : 'var tmData = ' + JSON . stringify ( tmData ) + '; var tabId = ' + tabId + ';' } ,
130
+ chrome . tabs . executeScript ( tabId , { code : 'var tmData = ' + JSON . stringify ( tmData ) + '; var tabId = ' + tabId + ';' } ,
126
131
function ( ) {
127
132
chrome . tabs . executeScript ( tabId , {
128
133
// TODO: Account for data: URIs like the "connection unavailable" page.
@@ -145,7 +150,7 @@ chrome.runtime.onMessage.addListener(
145
150
window . localStorage . setItem ( 'mementos' , request . mementos )
146
151
window . localStorage . setItem ( 'memento_datetime' , request . memento_datetime )
147
152
148
- sendResponse ( { value : 'noise' } )
153
+ sendResponse ( { value : 'noise' } )
149
154
} else if ( request . method === 'findTMURI' ) {
150
155
if ( debug ) { console . log ( 'Got findTMURI' ) }
151
156
findTMURI ( request . timegate , sender . tab . id )
@@ -235,7 +240,7 @@ function fetchTimeMap (uri, tabid) {
235
240
// TODO: data.normalize()
236
241
const mems = data . mementos
237
242
delete data . mementos
238
- data . mementos = { list : mems }
243
+ data . mementos = { list : mems }
239
244
if ( debug ) { console . log ( data ) }
240
245
}
241
246
@@ -289,22 +294,22 @@ function setBadgeText (value, tabid) {
289
294
badgeValue = ''
290
295
}
291
296
292
- chrome . browserAction . setBadgeText ( { text : badgeValue + '' , tabId : tabid } )
293
- chrome . browserAction . setBadgeBackgroundColor ( { color : badgeColor , tabId : tabid } )
297
+ chrome . browserAction . setBadgeText ( { text : badgeValue + '' , tabId : tabid } )
298
+ chrome . browserAction . setBadgeBackgroundColor ( { color : badgeColor , tabId : tabid } )
294
299
}
295
300
296
301
function setBadgeTitle ( newTitle , tabid ) {
297
302
if ( debug ) { console . warn ( 'setting badge title' ) }
298
- chrome . browserAction . setTitle ( { title : newTitle , tabId : tabid } )
303
+ chrome . browserAction . setTitle ( { title : newTitle , tabId : tabid } )
299
304
}
300
305
301
306
function setBadgeIcon ( icons , tabid ) {
302
- chrome . browserAction . setIcon ( { tabId : tabid , path : icons } )
307
+ chrome . browserAction . setIcon ( { tabId : tabid , path : icons } )
303
308
}
304
309
305
310
function setBadge ( value , icon , tabid ) {
306
311
if ( value === '' ) {
307
- chrome . browserAction . getBadgeText ( { tabId : tabid } , function ( currentBadgeText ) {
312
+ chrome . browserAction . getBadgeText ( { tabId : tabid } , function ( currentBadgeText ) {
308
313
setBadgeText ( currentBadgeText + '' , tabid )
309
314
} )
310
315
} else {
@@ -314,9 +319,9 @@ function setBadge (value, icon, tabid) {
314
319
setBadgeIcon ( icon , tabid )
315
320
316
321
if ( JSON . stringify ( icon ) === JSON . stringify ( badgeImagesIsAMemento ) ) {
317
- chrome . browserAction . setTitle ( { title : browserActionTitleViewingMemento } )
322
+ chrome . browserAction . setTitle ( { title : browserActionTitleViewingMemento } )
318
323
} else {
319
- chrome . browserAction . setTitle ( { title : browserActionTitleNormal } )
324
+ chrome . browserAction . setTitle ( { title : browserActionTitleNormal } )
320
325
}
321
326
}
322
327
@@ -347,7 +352,7 @@ function startWatchingRequests () {
347
352
348
353
function stopWatchingRequests ( ) {
349
354
if ( debug ) { console . log ( 'stopWatchingRequests() executing' ) }
350
- chrome . storage . local . set ( { 'disabled' : true } , function ( ) {
355
+ chrome . storage . local . set ( { 'disabled' : true } , function ( ) {
351
356
chrome . contextMenus . update ( 'mink_stopStartWatching' , {
352
357
'title' : 'Restart Live-Archived Web Integration' ,
353
358
'onclick' : startWatchingRequests
@@ -429,7 +434,7 @@ chrome.webRequest.onCompleted.addListener(function (deets) {
429
434
} )
430
435
} )
431
436
} ,
432
- { urls : [ '*://twitter.com/*/status/*' ] , types : [ 'xmlhttprequest' ] } , [ 'responseHeaders' ] )
437
+ { urls : [ '*://twitter.com/*/status/*' ] , types : [ 'xmlhttprequest' ] } , [ 'responseHeaders' ] )
433
438
434
439
chrome . webRequest . onHeadersReceived . addListener ( function ( deets ) {
435
440
chrome . storage . local . get ( 'headers' , function ( items ) {
@@ -451,7 +456,7 @@ chrome.webRequest.onHeadersReceived.addListener(function (deets) {
451
456
}
452
457
453
458
data [ deets . url ] = deets . responseHeaders
454
- chrome . storage . local . set ( { 'headers' : data } , function ( ) {
459
+ chrome . storage . local . set ( { 'headers' : data } , function ( ) {
455
460
if ( chrome . runtime . lastError ) {
456
461
if ( debug ) { console . log ( 'There was an error last time we tried to store a memento ' + chrome . runtime . lastError . message ) }
457
462
if ( chrome . runtime . lastError . message . indexOf ( 'QUOTA_BYTES_PER_ITEM' ) > - 1 ) {
@@ -462,7 +467,7 @@ chrome.webRequest.onHeadersReceived.addListener(function (deets) {
462
467
} )
463
468
} )
464
469
} ,
465
- { urls : [ '<all_urls>' ] , types : [ 'main_frame' ] } , [ 'responseHeaders' , 'blocking' ] )
470
+ { urls : [ '<all_urls>' ] , types : [ 'main_frame' ] } , [ 'responseHeaders' , 'blocking' ] )
466
471
467
472
function createTimemapFromURI ( uri , tabId , accumulatedArrayOfTimemaps ) {
468
473
if ( debug ) {
@@ -512,7 +517,7 @@ function createTimemapFromURI (uri, tabId, accumulatedArrayOfTimemaps) {
512
517
// Send two messages first stop animation then display stored
513
518
// If use displayUIBasedOnContext the correctly gotten items wont be display
514
519
// Rather we will ask memgator.cs for mementos
515
- chrome . tabs . sendMessage ( tabId , { 'method' : 'stopAnimatingBrowserActionIcon' } )
520
+ chrome . tabs . sendMessage ( tabId , { 'method' : 'stopAnimatingBrowserActionIcon' } )
516
521
chrome . tabs . sendMessage ( tabId , {
517
522
'method' : 'displayUIStoredTM' ,
518
523
'data' : firstTm
@@ -529,7 +534,7 @@ function displayMementosMissingTM (mementos, urir, tabId) {
529
534
tm . original = urir
530
535
setTimemapInStorage ( tm , tm . original )
531
536
532
- chrome . tabs . sendMessage ( tabId , { 'method' : 'stopAnimatingBrowserActionIcon' } )
537
+ chrome . tabs . sendMessage ( tabId , { 'method' : 'stopAnimatingBrowserActionIcon' } )
533
538
chrome . tabs . sendMessage ( tabId , {
534
539
'method' : 'displayUIStoredTM' ,
535
540
'data' : tm
@@ -619,7 +624,7 @@ function setTimemapInStorageAndCall (tm, url, cb) {
619
624
console . log ( tms )
620
625
}
621
626
622
- chrome . storage . local . set ( { 'timemaps' : tms } , function ( ) {
627
+ chrome . storage . local . set ( { 'timemaps' : tms } , function ( ) {
623
628
chrome . storage . local . getBytesInUse ( 'timemaps' , function ( bytesUsed ) {
624
629
if ( debug ) {
625
630
console . log ( 'current bytes used:' + bytesUsed )
@@ -639,7 +644,7 @@ function setTimemapInStorageAndCall (tm, url, cb) {
639
644
console . log ( 'Re-setting chrome.storage.local with:' )
640
645
console . log ( tms )
641
646
}
642
- chrome . storage . local . set ( { 'timemaps' : tms } , function ( ) {
647
+ chrome . storage . local . set ( { 'timemaps' : tms } , function ( ) {
643
648
cb ( )
644
649
} )
645
650
}
@@ -683,7 +688,7 @@ function setTimemapInStorage (tm, url) {
683
688
console . log ( tms )
684
689
}
685
690
686
- chrome . storage . local . set ( { 'timemaps' : tms } , function ( ) {
691
+ chrome . storage . local . set ( { 'timemaps' : tms } , function ( ) {
687
692
chrome . storage . local . getBytesInUse ( 'timemaps' , function ( bytesUsed ) {
688
693
if ( debug ) { console . log ( 'current bytes used:' + bytesUsed ) }
689
694
} )
@@ -697,7 +702,7 @@ function setTimemapInStorage (tm, url) {
697
702
console . log ( 'Re-setting chrome.storage.local with:' )
698
703
console . log ( tms )
699
704
}
700
- chrome . storage . local . set ( { 'timemaps' : tms } , function ( ) { } )
705
+ chrome . storage . local . set ( { 'timemaps' : tms } , function ( ) { } )
701
706
}
702
707
}
703
708
} )
0 commit comments