From e03e05d203dc9685e20a9f1769b078b1ff79aace Mon Sep 17 00:00:00 2001 From: wassname Date: Thu, 2 Aug 2018 10:31:34 +0800 Subject: [PATCH] Update to manifest version 2 It mostly works but there are still some bugs in RedditAPI.getReddits() --- html/background.html | 19 ++----------------- html/popup.html | 21 ++------------------- js/background.js | 14 ++++++++++++++ js/common.js | 2 ++ js/popup.js | 16 ++++++++++++++++ manifest.json | 3 ++- 6 files changed, 38 insertions(+), 37 deletions(-) create mode 100644 js/background.js create mode 100644 js/popup.js diff --git a/html/background.html b/html/background.html index 3a136d8..56c77f0 100644 --- a/html/background.html +++ b/html/background.html @@ -6,22 +6,7 @@ - + - \ No newline at end of file + diff --git a/html/popup.html b/html/popup.html index f526151..59e0774 100644 --- a/html/popup.html +++ b/html/popup.html @@ -6,26 +6,9 @@ - + Loading... - \ No newline at end of file + diff --git a/js/background.js b/js/background.js new file mode 100644 index 0000000..393cde0 --- /dev/null +++ b/js/background.js @@ -0,0 +1,14 @@ +var background; + +background = new Background(); + +function initBackground() { + cache.removeAll(); + button.setBadgeDefaults(); + chrome.tabs.onUpdated.addListener(background.prepareBrowserAction); + background.watchMail(); + window.setInterval(background.clearCache, (settings.get('cacheTime') * 60 * 1000)); + reddit.getReddits(); +} + +window.onload = initBackground; diff --git a/js/common.js b/js/common.js index 038ef31..81f2bf3 100644 --- a/js/common.js +++ b/js/common.js @@ -1308,3 +1308,5 @@ Popup.prototype.cacheComment = function (e) { cache.set(url, oldCache); return true; }; + + diff --git a/js/popup.js b/js/popup.js new file mode 100644 index 0000000..3ea57ac --- /dev/null +++ b/js/popup.js @@ -0,0 +1,16 @@ +var popup; + +popup = new Popup(); + +function initPopup() { + chrome.tabs.getSelected(null, function(currTab) { + if (cache.get(currTab.url) !== undefined && cache.get(currTab.url).count >= 1) { + document.getElementById('body').innerHTML = popup.createListHTML(currTab.url); + document.getElementById('body').style.width = settings.get('popupWidth') + 'px'; + } else { + document.getElementById('body').innerHTML = popup.createSubmitForm(currTab); + } + }); +} + +window.addEventListener('load', initPopup); diff --git a/manifest.json b/manifest.json index 42ae0f2..4f2b8d2 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,7 @@ { "name": "Mostly Harmless", "version": "1.5.1", + "manifest_version": 2, "description": "Find, vote on, save, hide, and report links on reddit; submit new links; These and more! http://kerrick.github.com/Mostly-Harmless", "browser_action": { "default_icon": "pix/alien.png", @@ -16,7 +17,7 @@ "48": "pix/icon48.png", "128": "pix/icon128.png" }, - "background_page": "html/background.html", + "background": {"page":"html/background.html","persistent": true}, "options_page": "fancy-settings/index.html", "default_locale": "en_US" }