diff options
author | fox <[email protected]> | 2017-11-30 13:45:31 +0000 |
---|---|---|
committer | Gogs <[email protected]> | 2017-11-30 13:45:31 +0000 |
commit | c7a457988dbf942152e113a97df69c31da702aac (patch) | |
tree | d782cab29913b1dd7029eef21607efe6e864ddb2 | |
parent | 0a61d4407ec17ccdceb80c1331de46152426ce34 (diff) | |
parent | f993d228878f21ec369c76e83a555f9d626897d8 (diff) |
Merge branch 'standard-webextension' of will/tt-rss-notifier into master
-rw-r--r-- | js/background.js | 30 | ||||
-rw-r--r-- | manifest.json | 7 |
2 files changed, 21 insertions, 16 deletions
diff --git a/js/background.js b/js/background.js index dec4290..2645058 100644 --- a/js/background.js +++ b/js/background.js @@ -3,6 +3,12 @@ var last_updated = 0; var feeds_last_updated = 0; var prefs_last_updated = 0; +var test = browser; + +if (!test){ + var browser; + browser = chrome; +} function param_escape(arg) { if (typeof encodeURIComponent != 'undefined') @@ -108,10 +114,10 @@ function update() { if (!show_badge) badge.text = ''; - chrome.browserAction.setBadgeBackgroundColor(badge_color); - chrome.browserAction.setBadgeText(badge); - chrome.browserAction.setTitle(title); - chrome.browserAction.setIcon(icon); + browser.browserAction.setBadgeBackgroundColor(badge_color); + browser.browserAction.setBadgeText(badge); + browser.browserAction.setTitle(title); + browser.browserAction.setIcon(icon); } }; } @@ -168,18 +174,18 @@ function is_site_url(url) { } function init() { - chrome.browserAction.onClicked.addListener(function() { + browser.browserAction.onClicked.addListener(function() { var site_url = localStorage['site_url']; if (site_url) { // try to find already opened tab - chrome.tabs.query({currentWindow: true}, function(tabs) { + browser.tabs.query({currentWindow: true}, function(tabs) { var found_existing = false; for (var i = 0, tab; tab = tabs[i]; i++) { if (tab.url && is_site_url(tab.url)) { - chrome.tabs.update(tab.id, {highlighted: true}); + browser.tabs.update(tab.id, {highlighted: true}); update(); found_existing = true; return; @@ -188,11 +194,11 @@ function init() { // check if current tab is newtab (only if not updated yet) if (!found_existing) { - chrome.tabs.query({currentWindow: true, active: true}, function(tabs) { + browser.tabs.query({currentWindow: true, active: true}, function(tabs) { if (tabs[0].url && is_newtab(tabs[0].url)) { - chrome.tabs.update(tabs[0].id, {url: site_url}); + browser.tabs.update(tabs[0].id, {url: site_url}); } else { - chrome.tabs.create({url: site_url}); + browser.tabs.create({url: site_url}); } }); } // (if (!found_existing)) @@ -206,8 +212,8 @@ function init() { // `feeds_update_interval` and updates the `alarm` object when extension // preferences are saved. timeout(); - chrome.alarms.create({periodInMinutes: 1}); - chrome.alarms.onAlarm.addListener(function() {timeout();}); + browser.alarms.create({periodInMinutes: 1}); + browser.alarms.onAlarm.addListener(function() {timeout();}); } init(); diff --git a/manifest.json b/manifest.json index 75b6f39..221230d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,13 +1,12 @@ { "name": "Tiny Tiny RSS Notifier", "background": { - "scripts": ["js/background.js"], - "persistent": false + "scripts": ["js/background.js"] }, - "version": "0.5.2", + "version": "0.6", "manifest_version": 2, "description": "This extension displays the number of unread articles in your Tiny Tiny RSS installation", - "options_page": "options.html", + "options_ui": {"page" : "options.html"}, "icons": { "48": "images/icon_48.png", "128": "images/icon_128.png" }, "browser_action": { "default_icon": "images/normal.png", |