From a71897aee84379f71c99543e0165040a63a1e395 Mon Sep 17 00:00:00 2001 From: Corbin Davenport Date: Sat, 23 Jan 2021 23:05:52 -0500 Subject: [PATCH] Update checkProtocol function to fix #29 --- js/background.js | 19 ------------------- js/peek.js | 19 ++++++------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/js/background.js b/js/background.js index 1c547f4..1b20472 100644 --- a/js/background.js +++ b/js/background.js @@ -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') - }) - } - } - }) }) diff --git a/js/peek.js b/js/peek.js index 7fa5a05..176ef06 100644 --- a/js/peek.js +++ b/js/peek.js @@ -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 } } @@ -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