Skip to content

Commit 539f625

Browse files
authored
Merge pull request #266 from machawk1/issue-265
Fix issue of double-clicking WAIT displaying the DOM-based UI
2 parents e14273a + b0d3cce commit 539f625

File tree

5 files changed

+42
-37
lines changed

5 files changed

+42
-37
lines changed

mink-plugin/content.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ setInitialStateWithChecks()
2626
function setActiveBasedOnDisabledProperty (cb) {
2727
chrome.storage.local.get('disabled', function (items) {
2828
if (items.disabled) {
29-
chrome.runtime.sendMessage({method: 'stopWatchingRequests'}, function (response) {})
29+
chrome.runtime.sendMessage({ method: 'stopWatchingRequests' }, function (response) {})
3030
} else {
3131
cb()
3232
}
@@ -44,7 +44,7 @@ function setActiveBasedOnBlacklistedProperty (cb) {
4444
const documentHostname = (new window.URL(document.URL)).hostname
4545
const blacklistEntryHostname = (new window.URL(items.blacklist[ii])).hostname
4646
if (documentHostname === blacklistEntryHostname) {
47-
chrome.runtime.sendMessage({method: 'stopWatchingRequestsBlacklisted'})
47+
chrome.runtime.sendMessage({ method: 'stopWatchingRequestsBlacklisted' })
4848
return
4949
}
5050
}
@@ -219,7 +219,7 @@ function displayUIBasedOnStoredTimeMap (tmDataIn) {
219219

220220
if (debug) { console.log(tmDataIn) }
221221
const mementoCountFromCache = tmDataIn.mementos.list.length
222-
chrome.runtime.sendMessage({method: 'setBadgeText', value: '' + mementoCountFromCache})
222+
chrome.runtime.sendMessage({ method: 'setBadgeText', value: '' + mementoCountFromCache })
223223
}
224224

225225
function getBlacklist (cb) {
@@ -322,7 +322,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
322322
'19': clockIcons19[clockIcons19.length - 1]
323323
}
324324
})
325-
chrome.runtime.sendMessage({method: 'setBadgeText', text: ''}, function (response) {
325+
chrome.runtime.sendMessage({ method: 'setBadgeText', text: '' }, function (response) {
326326
})
327327
animateBrowserActionIcon = true
328328
setTimeout(animatePageActionIcon, 500)
@@ -376,15 +376,15 @@ function getMementos (uri) {
376376
if (debug) { console.log('getMementosWithTimemap()') }
377377
const timemapLocation = memgatorJson + uri
378378

379-
chrome.runtime.sendMessage({method: 'setBadge',
379+
chrome.runtime.sendMessage({ method: 'setBadge',
380380
text: '',
381381
iconPath: {
382382
'38': clockIcons38[clockIcons38.length - 1],
383383
'19': clockIcons19[clockIcons19.length - 1]
384384
}
385385
})
386386

387-
chrome.runtime.sendMessage({method: 'setBadgeText', text: ''}, function (response) {})
387+
chrome.runtime.sendMessage({ method: 'setBadgeText', text: '' }, function (response) {})
388388

389389
animateBrowserActionIcon = true
390390

@@ -423,7 +423,7 @@ function animatePageActionIcon () {
423423
chrome.runtime.sendMessage({
424424
method: 'setBadge',
425425
text: '',
426-
iconPath: {'38': clockIcons38[iteration], '19': clockIcons19[iteration]}})
426+
iconPath: { '38': clockIcons38[iteration], '19': clockIcons19[iteration] } })
427427
iteration--
428428

429429
if (iteration < 0) { iteration = clockIcons38.length - 1 }

mink-plugin/js/displayMinkUI.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ function bindSteps () {
544544

545545
function bindOptions () {
546546
$('#options').click(function () {
547-
chrome.runtime.sendMessage({method: 'openOptionsPage'})
547+
chrome.runtime.sendMessage({ method: 'openOptionsPage' })
548548
})
549549
}
550550

mink-plugin/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "Mink - Integrate Live & Archived Web +Memento",
44
"short_name": "Mink",
5-
"version": "2.3.3.1",
5+
"version": "2.3.3.2",
66
"description": "Integrating the Live and Archived Web Viewing Experience Using Memento",
77
"homepage_url": "http://matkelly.com/mink",
88
"author": "Mat Kelly <mink@matkelly.com>",

mink-plugin/mink.js

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ chrome.browserAction.onClicked.addListener(function (tab) {
6262
})
6363

6464
function setEnabledBasedOnURIInBlacklist (cb) {
65-
chrome.tabs.query({active: true}, function (tab) {
65+
chrome.tabs.query({ active: true }, function (tab) {
6666
if (debug) {
6767
console.log('is URI in blacklist?')
6868
console.log(tab)
@@ -91,9 +91,9 @@ function showMinkBadgeInfoBasedOnProcessingState (tabid) {
9191
function setBadgeTextBasedOnBrowserActionState (tabid) {
9292
// TODO: This should not rely on the badge count to detect zero mementos, as badges are no longer used for no mementos present
9393
// - 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) {
9595
if (!result.length && !Number.isInteger(result) && result !== maxBadgeDisplay) {
96-
chrome.browserAction.getTitle({tabId: tabid}, function (result) {
96+
chrome.browserAction.getTitle({ tabId: tabid }, function (result) {
9797
// Only set badge text if not viewing a memento
9898
if (result === browserActionTitleNoMementos) {
9999
displayMinkUI(tabid)
@@ -116,13 +116,18 @@ function setBadgeTextBasedOnBrowserActionState (tabid) {
116116
return // Badge has not yet been set
117117
}
118118
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+
})
120125
})
121126
}
122127

123128
function displayMinkUI (tabId) {
124129
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 + ';' },
126131
function () {
127132
chrome.tabs.executeScript(tabId, {
128133
// TODO: Account for data: URIs like the "connection unavailable" page.
@@ -145,7 +150,7 @@ chrome.runtime.onMessage.addListener(
145150
window.localStorage.setItem('mementos', request.mementos)
146151
window.localStorage.setItem('memento_datetime', request.memento_datetime)
147152

148-
sendResponse({value: 'noise'})
153+
sendResponse({ value: 'noise' })
149154
} else if (request.method === 'findTMURI') {
150155
if (debug) { console.log('Got findTMURI') }
151156
findTMURI(request.timegate, sender.tab.id)
@@ -235,7 +240,7 @@ function fetchTimeMap (uri, tabid) {
235240
// TODO: data.normalize()
236241
const mems = data.mementos
237242
delete data.mementos
238-
data.mementos = {list: mems}
243+
data.mementos = { list: mems }
239244
if (debug) { console.log(data) }
240245
}
241246

@@ -289,22 +294,22 @@ function setBadgeText (value, tabid) {
289294
badgeValue = ''
290295
}
291296

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 })
294299
}
295300

296301
function setBadgeTitle (newTitle, tabid) {
297302
if (debug) { console.warn('setting badge title') }
298-
chrome.browserAction.setTitle({title: newTitle, tabId: tabid})
303+
chrome.browserAction.setTitle({ title: newTitle, tabId: tabid })
299304
}
300305

301306
function setBadgeIcon (icons, tabid) {
302-
chrome.browserAction.setIcon({tabId: tabid, path: icons})
307+
chrome.browserAction.setIcon({ tabId: tabid, path: icons })
303308
}
304309

305310
function setBadge (value, icon, tabid) {
306311
if (value === '') {
307-
chrome.browserAction.getBadgeText({tabId: tabid}, function (currentBadgeText) {
312+
chrome.browserAction.getBadgeText({ tabId: tabid }, function (currentBadgeText) {
308313
setBadgeText(currentBadgeText + '', tabid)
309314
})
310315
} else {
@@ -314,9 +319,9 @@ function setBadge (value, icon, tabid) {
314319
setBadgeIcon(icon, tabid)
315320

316321
if (JSON.stringify(icon) === JSON.stringify(badgeImagesIsAMemento)) {
317-
chrome.browserAction.setTitle({title: browserActionTitleViewingMemento})
322+
chrome.browserAction.setTitle({ title: browserActionTitleViewingMemento })
318323
} else {
319-
chrome.browserAction.setTitle({title: browserActionTitleNormal})
324+
chrome.browserAction.setTitle({ title: browserActionTitleNormal })
320325
}
321326
}
322327

@@ -347,7 +352,7 @@ function startWatchingRequests () {
347352

348353
function stopWatchingRequests () {
349354
if (debug) { console.log('stopWatchingRequests() executing') }
350-
chrome.storage.local.set({'disabled': true}, function () {
355+
chrome.storage.local.set({ 'disabled': true }, function () {
351356
chrome.contextMenus.update('mink_stopStartWatching', {
352357
'title': 'Restart Live-Archived Web Integration',
353358
'onclick': startWatchingRequests
@@ -429,7 +434,7 @@ chrome.webRequest.onCompleted.addListener(function (deets) {
429434
})
430435
})
431436
},
432-
{urls: ['*://twitter.com/*/status/*'], types: ['xmlhttprequest']}, ['responseHeaders'])
437+
{ urls: ['*://twitter.com/*/status/*'], types: ['xmlhttprequest'] }, ['responseHeaders'])
433438

434439
chrome.webRequest.onHeadersReceived.addListener(function (deets) {
435440
chrome.storage.local.get('headers', function (items) {
@@ -451,7 +456,7 @@ chrome.webRequest.onHeadersReceived.addListener(function (deets) {
451456
}
452457

453458
data[deets.url] = deets.responseHeaders
454-
chrome.storage.local.set({'headers': data}, function () {
459+
chrome.storage.local.set({ 'headers': data }, function () {
455460
if (chrome.runtime.lastError) {
456461
if (debug) { console.log('There was an error last time we tried to store a memento ' + chrome.runtime.lastError.message) }
457462
if (chrome.runtime.lastError.message.indexOf('QUOTA_BYTES_PER_ITEM') > -1) {
@@ -462,7 +467,7 @@ chrome.webRequest.onHeadersReceived.addListener(function (deets) {
462467
})
463468
})
464469
},
465-
{urls: ['<all_urls>'], types: ['main_frame']}, ['responseHeaders', 'blocking'])
470+
{ urls: ['<all_urls>'], types: ['main_frame'] }, ['responseHeaders', 'blocking'])
466471

467472
function createTimemapFromURI (uri, tabId, accumulatedArrayOfTimemaps) {
468473
if (debug) {
@@ -512,7 +517,7 @@ function createTimemapFromURI (uri, tabId, accumulatedArrayOfTimemaps) {
512517
// Send two messages first stop animation then display stored
513518
// If use displayUIBasedOnContext the correctly gotten items wont be display
514519
// Rather we will ask memgator.cs for mementos
515-
chrome.tabs.sendMessage(tabId, {'method': 'stopAnimatingBrowserActionIcon'})
520+
chrome.tabs.sendMessage(tabId, { 'method': 'stopAnimatingBrowserActionIcon' })
516521
chrome.tabs.sendMessage(tabId, {
517522
'method': 'displayUIStoredTM',
518523
'data': firstTm
@@ -529,7 +534,7 @@ function displayMementosMissingTM (mementos, urir, tabId) {
529534
tm.original = urir
530535
setTimemapInStorage(tm, tm.original)
531536

532-
chrome.tabs.sendMessage(tabId, {'method': 'stopAnimatingBrowserActionIcon'})
537+
chrome.tabs.sendMessage(tabId, { 'method': 'stopAnimatingBrowserActionIcon' })
533538
chrome.tabs.sendMessage(tabId, {
534539
'method': 'displayUIStoredTM',
535540
'data': tm
@@ -619,7 +624,7 @@ function setTimemapInStorageAndCall (tm, url, cb) {
619624
console.log(tms)
620625
}
621626

622-
chrome.storage.local.set({'timemaps': tms}, function () {
627+
chrome.storage.local.set({ 'timemaps': tms }, function () {
623628
chrome.storage.local.getBytesInUse('timemaps', function (bytesUsed) {
624629
if (debug) {
625630
console.log('current bytes used:' + bytesUsed)
@@ -639,7 +644,7 @@ function setTimemapInStorageAndCall (tm, url, cb) {
639644
console.log('Re-setting chrome.storage.local with:')
640645
console.log(tms)
641646
}
642-
chrome.storage.local.set({'timemaps': tms}, function () {
647+
chrome.storage.local.set({ 'timemaps': tms }, function () {
643648
cb()
644649
})
645650
}
@@ -683,7 +688,7 @@ function setTimemapInStorage (tm, url) {
683688
console.log(tms)
684689
}
685690

686-
chrome.storage.local.set({'timemaps': tms}, function () {
691+
chrome.storage.local.set({ 'timemaps': tms }, function () {
687692
chrome.storage.local.getBytesInUse('timemaps', function (bytesUsed) {
688693
if (debug) { console.log('current bytes used:' + bytesUsed) }
689694
})
@@ -697,7 +702,7 @@ function setTimemapInStorage (tm, url) {
697702
console.log('Re-setting chrome.storage.local with:')
698703
console.log(tms)
699704
}
700-
chrome.storage.local.set({'timemaps': tms}, function () {})
705+
chrome.storage.local.set({ 'timemaps': tms }, function () {})
701706
}
702707
}
703708
})

mink-plugin/options.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function getListItemHTML (uri, classIn, buttonText) {
3535
}
3636

3737
function clearBlacklist () {
38-
chrome.storage.local.set({'blacklist': []})
38+
chrome.storage.local.set({ 'blacklist': [] })
3939
document.location.reload()
4040
}
4141

@@ -200,7 +200,7 @@ function removeTMFromCache (originalURI) {
200200
chrome.storage.local.get('timemaps', function (items) {
201201
let tms = items.timemaps
202202
delete tms[originalURI]
203-
chrome.storage.local.set({'timemaps': tms},
203+
chrome.storage.local.set({ 'timemaps': tms },
204204
function () {
205205
console.log('Cache updated, updating UI')
206206
$('#cachedTimemaps').empty()
@@ -211,15 +211,15 @@ function removeTMFromCache (originalURI) {
211211
}
212212

213213
function clearTimemapCache () {
214-
chrome.storage.local.set({'timemaps': {}},
214+
chrome.storage.local.set({ 'timemaps': {} },
215215
function () {
216216
console.log('Remove all cached TMs')
217217
$('#cachedTimemaps').empty()
218218
populatedCachedTimeMapsUI()
219219
}
220220
)
221221

222-
chrome.storage.local.set({'headers': {}},
222+
chrome.storage.local.set({ 'headers': {} },
223223
function () {
224224
console.log('Remove headers')
225225
}

0 commit comments

Comments
 (0)