Skip to content

Commit

Permalink
Update checkProtocol function to fix #29
Browse files Browse the repository at this point in the history
  • Loading branch information
corbindavenport committed Jan 24, 2021
1 parent 725f0cc commit a71897a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 32 deletions.
19 changes: 0 additions & 19 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,6 @@ chrome.runtime.onInstalled.addListener(function (details) {
})
}

// Transfer data from Peek 2.x
if (localStorage.getItem('docviewer') != null) {
if (localStorage.getItem('docviewer') === 'google') {
chrome.storage.sync.set({
docViewer: 'google'
}, function () {
// Delete old setting
localStorage.removeItem('docviewer')
})
} else if (localStorage.getItem('docviewer') === 'office') {
chrome.storage.sync.set({
docViewer: 'office'
}, function () {
// Delete old setting
localStorage.removeItem('docviewer')
})
}
}

})
})

Expand Down
19 changes: 6 additions & 13 deletions js/peek.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ function addToolbar(html) {
return html
}

// Prevent mixed protocol alerts in Chrome
// Prevent mixed protocol warnings
function checkProtocol(url) {
if (url.includes('https:')) {
// HTTPS link on HTTP and HTTPS pages
return true
} else if (url.startsWith('http:') && window.location.protocol === 'http:') {
// HTTP link on HTTP page
return true
} else {
// Insecure mixed protocol
if (url.startsWith('http:') && window.location.protocol === 'https:') {
// HTTP link on HTTPS page
return false
} else {
// HTTPS link on HTTP page, HTTPS on HTTPS, etc.
return true
}
}

Expand All @@ -53,10 +50,6 @@ function processURL(url) {
// Append '_id' to the end of the date, so the Internet Archive returns the original file and not an HTML file
url = 'https://web.archive.org/web/' + date + 'id_/' + originalURL
}
// Fix Imgur links
if ((url.includes('http://')) && (url.includes('imgur.com'))) {
url = url.replace('http://', 'https://')
}
// Don't continue if checkProtocol returns false
if (checkProtocol(url)) {
// Don't continue if the link already has a tooltip, or if the link is a wiki page
Expand Down

0 comments on commit a71897a

Please sign in to comment.