Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b1f08f2
Begin converting Mink to use manifest v3
machawk1 Dec 24, 2020
5706033
Use chrome.runtime, not deprecated chrome.extension for #316
machawk1 Dec 27, 2020
72af39f
Rebase
machawk1 Dec 2, 2021
6b2d50f
Merge branch 'main' of https://github.com/machawk1/Mink into issue-316
machawk1 Oct 28, 2022
e61969c
Merge pull request #353 from machawk1/main
machawk1 Jul 7, 2023
82a3cbc
Update SW to use chrome storage instead of window localstorage for MV3
machawk1 Jul 7, 2023
cda81db
Mv from browserAction to action for MV3
machawk1 Jul 7, 2023
82b59c6
Convert from xhr to fetch for mv3
machawk1 Jul 7, 2023
dbba21c
Change chrome.ext to chrome.runtime for mv3
machawk1 Jul 7, 2023
0fd2e3a
Integrate further with SW for MV3
machawk1 Jul 7, 2023
7ff1fa1
Merge branch 'main' into issue-316
machawk1 Aug 24, 2023
12e6b29
Rm cruft from last rebase
machawk1 Aug 24, 2023
a4dd094
Update manifest to mv3-style web-accessible resources
machawk1 Aug 24, 2023
e83533a
Tweak pageaction to inject UI injection script
machawk1 Aug 24, 2023
a32a89c
Adapt to use Manifest v3 per #316
machawk1 Nov 2, 2023
c4d57c8
Rm redundant return
machawk1 Nov 2, 2023
871978f
Fix toggle by rm'ing listener after UI creation for #316
machawk1 Nov 2, 2023
1529ac3
Listed web-accessible internal resources and mitigate abortion error
machawk1 Jun 27, 2024
e3e6ce7
Catch when no aggregator is stored in localStorage
machawk1 Jun 27, 2024
07b5960
Re-enable clock animation
machawk1 Jun 27, 2024
a765902
Merge branch 'main' into issue-316
machawk1 Oct 10, 2024
dd374c0
Check if response is not JSON, throw error, for #367
machawk1 Oct 10, 2024
6019e2f
Clean up error reporting logic
machawk1 Oct 14, 2024
31ec85c
Add template to switch aggregator for #367
machawk1 Oct 14, 2024
aeacb6a
Add fallthrough aggregator logic for #316 and #367
machawk1 Oct 14, 2024
7ed2859
Use URIR and not URIT in subsequent query for fallback aggregator
machawk1 Oct 14, 2024
b1a4994
Stop animation when the process has completed
machawk1 Oct 14, 2024
200144f
Add logic to set the default aggregator for fallthrough re:#369
machawk1 Jan 28, 2025
37529eb
Add labels for dropdowns re:#373 #369 #316
machawk1 Jan 28, 2025
0d5237c
Update options dropdown to pull from localStorage re:#373
machawk1 Jan 28, 2025
6c5a235
Update element ID to match label and be consistent w/ RFC7089
machawk1 Jan 29, 2025
327055c
Add button to test writing and restoring to localStorage
machawk1 Jan 29, 2025
cb30e76
Rm default aggregators in UI
machawk1 Jan 29, 2025
6f12b08
Move default aggregator specification to separate module, to be expan…
machawk1 Jan 29, 2025
31c32ab
Add note to eventually deduplicate default aggr spec
machawk1 Jan 29, 2025
245bff1
Change SW to module, portabilize defaults
machawk1 Jan 29, 2025
1cf28d2
Rm log msg
machawk1 Jan 29, 2025
4fb52f7
Revert the premature optimization of tmData
machawk1 Jun 20, 2025
68f0bd4
Merge pull request #381 from machawk1/issue-379
machawk1 Jun 20, 2025
58e158f
Disable ODUCS MemGator due to the deployments' restricted outbound re…
machawk1 Jun 20, 2025
6e653b3
Disable aggregator default setting button in options
machawk1 Jun 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"esversion": 6,
"esversion": 8,
"debug" : true,
"loopfunc" : true,
"latedef" : false,
Expand Down
7 changes: 7 additions & 0 deletions mink-plugin/MinkDefaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

const defaultAggregators = [
//'https://memgator.cs.odu.edu',
'https://aggregator.matkelly.com'
]

export {defaultAggregators}
86 changes: 56 additions & 30 deletions mink-plugin/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function log (...messages) {
for (const msg of messages) {
console.log(msg)
}
// console.log(new Error().stack)
}
// console.trace()
}
Expand Down Expand Up @@ -86,6 +87,7 @@ function setActiveBasedOnIgnorelistedProperty (cb) {
})
}

// TODO: refine the acronym in this function's signature. Beware the axe murderer.
function normalDisplayUIBC (items) {
const hasATimeMapInCache = items.timemaps && items.timemaps[document.URL]

Expand All @@ -97,8 +99,8 @@ function normalDisplayUIBC (items) {
method: 'setBadge',
text: '',
iconPath: {
38: chrome.extension.getURL('images/mLogo38_isAMemento.png'),
19: chrome.extension.getURL('images/mLogo19_isAMemento.png')
38: chrome.runtime.getURL('images/mLogo38_isAMemento.png'),
19: chrome.runtime.getURL('images/mLogo19_isAMemento.png')
}
})
} else { // Live web page revisited w/ a TM in cache
Expand Down Expand Up @@ -138,15 +140,33 @@ function checkAggregatorHealthAndSet (aggregatorIndex) {

const options = { mode: 'no-cors', signal }

console.log(`Checking the health of aggregator #${aggregatorIndex} at ${memgatorHosts[aggregatorIndex]}`)

return window.fetch(url, options)
.then(setTimeout(() => { aborter.abort() }, timeout))
.then(setTimeout(() => { aborter.abort(`The request to ${url} timed out and has been aborted`) }, timeout))
.then(() => {
log(`Aggregator at ${memgatorHosts[aggregatorIndex]} was accessible\nSet as default`)
// TODO: set as default in the options
setDefaultAggregator(aggregatorIndex)
})
.catch(error => {
log(`${url} appears to be down, incrementing host counter`)
log(error)
hostI += 1
})
}

function setDefaultAggregator (indexOfNewDefault) {
chrome.storage.local.get('aggregators', function (ls) {
log(ls)
let aggregatorsArray = ls.aggregators
const newDefault = ls[indexOfNewDefault]
aggregatorsArray.splice(indexOfNewDefault, 1)
aggregatorsArray.unshift(newDefault)
chrome.storage.local.set({ 'aggregators': aggregatorsArray })
})
}

function displayUIBasedOnContext () {
log('displayUIBasedOnContext()', document.URL)

Expand Down Expand Up @@ -324,12 +344,21 @@ function addToIgnorelist (currentIgnorelist, uriIn) {
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
log(`in listener with ${request.method}`)

if (request.method === 'tryNextAggregator') {
++hostI
checkAggregatorHealthAndSet(hostI)
console.log(`trying again with aggregator ${hostI}`)
getMementos(request.uri)
return
}

if (request.method === 'addToIgnorelist') {
getIgnorelist(addToIgnorelist, request.uri) // And add uri
return
}

if (request.method === 'stopAnimatingBrowserActionIcon') {
// Stopping the browser action icon animation
clearTimeout(animationTimer)
animateBrowserActionIcon = false
return
Expand All @@ -342,8 +371,6 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
}

if (request.method === 'startTimer') {
log('Got startTimer')

chrome.runtime.sendMessage({
method: 'setBadge',
text: '',
Expand All @@ -358,12 +385,6 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
setTimeout(animatePageActionIcon, 500)
}

if (request.method === 'stopAnimatingBrowserActionIcon') {
clearTimeout(animationTimer)
animateBrowserActionIcon = false
return
}

if (request.method === 'showArchiveNowUI') {
return
}
Expand All @@ -377,7 +398,6 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
}, function (response) {
log('We have a response!') // This will not occur due to async exec in mink.js
})
return
}
return
}
Expand Down Expand Up @@ -410,6 +430,10 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
chrome.storage.local.set(storedHeaders, displayUIBasedOnContext)
})
}

if (request.method === 'setDefaultAggregators') {
console.log('TODO: set default aggregators from content.js')
}
})

function getMementos (uri) {
Expand All @@ -431,36 +455,38 @@ function getMementos (uri) {

setTimeout(animatePageActionIcon, 500)

log('in getMementos, sending "fetchTimeMap" message')
log(`in getMementos, sending "fetchTimeMap" message to service worker using ${timemapLocation}`)
chrome.runtime.sendMessage({
method: 'fetchTimeMap',
value: timemapLocation
value: timemapLocation,
urir: uri
})
}

const clockIcons38 = [chrome.extension.getURL('images/mementoLogos/mLogo38_7.5.png'),
chrome.extension.getURL('images/mementoLogos/mLogo38_15.png'),
chrome.extension.getURL('images/mementoLogos/mLogo38_22.5.png'),
chrome.extension.getURL('images/mementoLogos/mLogo38_30.png'),
chrome.extension.getURL('images/mementoLogos/mLogo38_37.5.png'),
chrome.extension.getURL('images/mementoLogos/mLogo38_45.png'),
chrome.extension.getURL('images/mementoLogos/mLogo38_52.5.png'),
chrome.extension.getURL('images/mementoLogos/mLogo38_60.png')]
const clockIcons19 = [chrome.extension.getURL('images/mementoLogos/mLogo19_7.5.png'),
chrome.extension.getURL('images/mementoLogos/mLogo19_15.png'),
chrome.extension.getURL('images/mementoLogos/mLogo19_22.5.png'),
chrome.extension.getURL('images/mementoLogos/mLogo19_30.png'),
chrome.extension.getURL('images/mementoLogos/mLogo19_37.5.png'),
chrome.extension.getURL('images/mementoLogos/mLogo19_45.png'),
chrome.extension.getURL('images/mementoLogos/mLogo19_52.5.png'),
chrome.extension.getURL('images/mementoLogos/mLogo19_60.png')]
const clockIcons38 = [chrome.runtime.getURL('images/mementoLogos/mLogo38_7.5.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo38_15.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo38_22.5.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo38_30.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo38_37.5.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo38_45.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo38_52.5.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo38_60.png')]
const clockIcons19 = [chrome.runtime.getURL('images/mementoLogos/mLogo19_7.5.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo19_15.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo19_22.5.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo19_30.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo19_37.5.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo19_45.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo19_52.5.png'),
chrome.runtime.getURL('images/mementoLogos/mLogo19_60.png')]
let iteration = clockIcons38.length - 1

function animatePageActionIcon () {
if (!animateBrowserActionIcon) {
clearTimeout(animationTimer)
return
}

chrome.runtime.sendMessage({
method: 'setBadge',
text: '',
Expand Down
32 changes: 20 additions & 12 deletions mink-plugin/js/displayMinkUI.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global chrome, $, Timemap, tmData */

var MAX_MEMENTOS_IN_DROPDOWN = 500
var tmData

function createShadowDOM (cb) {
const selector = '#minkuiX'
Expand All @@ -19,7 +20,8 @@ function setupDrilldownInteractions () {
}

function appendHTMLToShadowDOM () {
$.ajax(chrome.extension.getURL('minkui.html'))
tmData = arguments[0].tmData
$.ajax(chrome.runtime.getURL('minkui.html')) // There has to be a more native way to do this
.done(function (data) {
// TODO: before invoking any further, check to verify that some mementos exist (the aggregator query has returned).

Expand Down Expand Up @@ -123,6 +125,7 @@ function appendHTMLToShadowDOM () {
appendCSSToShadowDOM(cb)
})
})
chrome.runtime.onMessage.removeListener(appendHTMLToShadowDOM)
}

// In some places, getting addZ has already been declared, thus var for now
Expand Down Expand Up @@ -157,7 +160,7 @@ function switchToArchiveNowInterface () {
}

function appendCSSToShadowDOM (cb) {
$.ajax(chrome.extension.getURL('css/minkui.css'))
$.ajax(chrome.runtime.getURL('css/minkui.css'))
.done(function (data) {
const styleElement = `<style type="text/css">\n${data}\n</style>\n`
$('#minkuiX').prepend(styleElement)
Expand Down Expand Up @@ -567,11 +570,11 @@ function setupUI () {
}

function replaceContentScriptImagesWithChromeExtensionImages () {
document.getElementById('minkLogo').src = chrome.extension.getURL('images/mink_marvel_80.png')
document.getElementById('minkLogo').src = chrome.runtime.getURL('images/mink_marvel_80.png')

document.getElementById('archivelogo_ia').src = chrome.extension.getURL('images/archives/iaLogo.png')
document.getElementById('archivelogo_ais').src = chrome.extension.getURL('images/archives/archiveisLogo.png')
document.getElementById('archivelogo_ala').src = chrome.extension.getURL('images/archives/allListedArchives.png')
document.getElementById('archivelogo_ia').src = chrome.runtime.getURL('images/archives/iaLogo.png')
document.getElementById('archivelogo_ais').src = chrome.runtime.getURL('images/archives/archiveisLogo.png')
document.getElementById('archivelogo_ala').src = chrome.runtime.getURL('images/archives/allListedArchives.png')
}

function bindSteps () {
Expand Down Expand Up @@ -750,7 +753,7 @@ function bindArchiveLogos () {

const that = this
const newSrc = $(this).attr('src').replace('.png', '_success.png')
$(this).attr('src', chrome.extension.getURL('./images/spinner.gif'))
$(this).attr('src', chrome.runtime.getURL('./images/spinner.gif'))

const archiveLogoID = $(this).attr('id')

Expand Down Expand Up @@ -782,8 +785,8 @@ function bindArchiveLogos () {
changeArchiveAllIconWhenComplete(alaLogo)
}

$(iaLogo).attr('src', chrome.extension.getURL('./images/spinner.gif'))
$(aisLogo).attr('src', chrome.extension.getURL('./images/spinner.gif'))
$(iaLogo).attr('src', chrome.runtime.getURL('./images/spinner.gif'))
$(aisLogo).attr('src', chrome.runtime.getURL('./images/spinner.gif'))

openInNewTab = true
archiveURIArchiveOrg(iaCb, openInNewTab)
Expand All @@ -797,7 +800,7 @@ var archivesFinished = 0 /* TOFIX This is doubly declared if 'let' */
function changeArchiveAllIconWhenComplete (iconObj) {
archivesFinished++
if (archivesFinished >= 2) {
$(iconObj).attr('src', chrome.extension.getURL('./images/archives/allListedArchives_success.png'))
$(iconObj).attr('src', chrome.runtime.getURL('./images/archives/allListedArchives_success.png'))
$(iconObj).unbind()
$(iconObj).removeClass('archiveLogo')
}
Expand All @@ -819,8 +822,13 @@ function bindNavigationButtons () {
})
}

if ($('#minkWrapper').length === 0) {
appendHTMLToShadowDOM()
function echoTMDataForMV3 (tmData) {
console.log('Echoing TM Data For MV3')
console.log(tmData)
}

if (document.getElementById('minkWrapper') === null) {
chrome.runtime.onMessage.addListener(appendHTMLToShadowDOM)
} else {
$('#minkWrapper').toggle()
}
Loading