Skip to content

Commit 245bff1

Browse files
committed
Change SW to module, portabilize defaults
1 parent 31c32ab commit 245bff1

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

mink-plugin/MinkDefaults.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11

2-
function MinkDefaults () {
3-
this.defaultAggregators = [
2+
const defaultAggregators = [
43
'https://memgator.cs.odu.edu',
54
'https://aggregator.matkelly.com'
65
]
76

8-
}
9-
10-
export {MinkDefaults}
7+
export {defaultAggregators}

mink-plugin/manifest.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"homepage_url": "https://matkelly.com/mink",
88
"author": "Mat Kelly <[email protected]>",
99
"background": {
10-
"service_worker": "mink.js"
10+
"service_worker": "mink.js",
11+
"type": "module"
1112
},
1213
"action": {
1314
"default_title": "Mink - Integrating the Live and Archived Web",

mink-plugin/mink.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
/* global chrome, $, Timemap */
22

3+
import {defaultAggregators} from './MinkDefaults.js'
4+
5+
console.log(defaultAggregators)
6+
7+
38
const debug = false
49
let tmData
510
const maxBadgeDisplay = '> 1k'
@@ -10,11 +15,6 @@ const browserActionTitleNormal = 'Mink - Integrating the Live and Archived Web'
1015
const browserActionTitleNoMementos = 'Mink - No Mementos Available'
1116
const browserActionTitleIgnorelisted = 'Mink - Viewing Ignored Site'
1217

13-
const defaultAggregators = [ // TODO: pull this in from the MinkDefaults module
14-
'https://memgator.cs.odu.edu',
15-
'https://aggregator.matkelly.com'
16-
]
17-
1818
const badgeImagesDisabled = {
1919
38: chrome.runtime.getURL('images/minkLogo38_disabled.png'),
2020
19: chrome.runtime.getURL('images/minkLogo19_disabled.png')
@@ -787,6 +787,7 @@ chrome.runtime.onInstalled.addListener(({ reason }) => {
787787
if (reason === 'install') {
788788
console.log('extension installed, reported via SW registration')
789789
console.log('setting default aggregators')
790+
console.log(defaultAggregators)
790791
chrome.storage.local.set({'aggregators': defaultAggregators})
791792
//chrome.storage.local.set({
792793
// apiSuggestions: ['tabs', 'storage', 'scripting']

mink-plugin/options.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var debug = true
55
const tmDropdownString = '<option>&nbsp;&nbsp;&darr; Mink has TimeMaps for... &darr;</option>'
66
const tmDropdownNoTimemapsString = '<option>--- No TimeMaps available ---</option>'
77

8-
import {MinkDefaults} from './MinkDefaults.js'
8+
import {defaultAggregators} from './MinkDefaults.js'
99

1010
function restoreOptions () {
1111
chrome.storage.local.get('ignorelist').then(function (items) {
@@ -292,7 +292,7 @@ function clearAggregatorListInLocalStorage () {
292292
}
293293

294294
function resetDefaultAggregators () {
295-
chrome.storage.local.set({'aggregators': MinkDefaults.defaultAggregators})
295+
chrome.storage.local.set({'aggregators': defaultAggregators})
296296
}
297297

298298
function updateAggregatorsUIBasedOnLocalStorage () {
@@ -349,15 +349,18 @@ function populateDropdownWithAggregatorsInStorage (arrayOfAggregators) {
349349
function setAggregatorsInStorage (arrayOfAggregatorHostnames, cb) {
350350
// Returns a promise
351351
return chrome.storage.local.set({ 'aggregators': arrayOfAggregatorHostnames }).then(() => {
352-
console.log('Attempting to invoke the callback')
352+
console.log('Attempting to invoke the callback, this is failing w/ reload')
353353
console.log(cb)
354354
cb()
355+
}, function writeFailed () {
356+
console.log("Failed to write to localstorage")
357+
console.log(arrayOfAggregatorHostnames)
355358
})
356359
}
357360

358361
function test_writeToLocalStorageAndReload () {
359362
let testAggregators = ['https://memento.example.com', 'https://aggregator.somehostname.net']
360-
setAggregatorsInStorage(testAggregators, window.location.reload)
363+
setAggregatorsInStorage(defaultAggregators)//, window.location.reload)
361364
}
362365

363366

0 commit comments

Comments
 (0)