From 5307b438461b01dc2c0f25d8d7d155c18b163335 Mon Sep 17 00:00:00 2001 From: Aurelien David Date: Fri, 3 May 2024 14:40:05 +0200 Subject: [PATCH] fix default options for android --- manifest.json | 2 +- popup/popup.js | 37 +++++++++++++++---------------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/manifest.json b/manifest.json index 8332797..92a12a5 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "RSSPreview", - "version": "3.30", + "version": "3.31", "author": "Aurelien David", "homepage_url": "https://github.com/aureliendavid/rsspreview", diff --git a/popup/popup.js b/popup/popup.js index 09c6b2b..3bb7f5c 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -1,8 +1,4 @@ -var options = { - newTab: true, -}; - var android = false; browser.runtime.getPlatformInfo().then((info) => { @@ -10,16 +6,6 @@ browser.runtime.getPlatformInfo().then((info) => { }); -function onOptions(opts) { - options = opts; -} - -function onError(error) { - console.log(`Error on get options: ${error}`); -} - -browser.storage.sync.get(options).then(onOptions, onError); - document.addEventListener("DOMContentLoaded", function(event) { @@ -30,6 +16,9 @@ document.addEventListener("DOMContentLoaded", function(event) { const tabId = +url.searchParams.get('tabId'); const feeds = JSON.parse(url.searchParams.get('feeds')); + browser.runtime.getPlatformInfo().then((info) => { + android = info.os == "android"; + for (feed_url in feeds) { if (feeds.hasOwnProperty(feed_url)) { @@ -43,18 +32,18 @@ document.addEventListener("DOMContentLoaded", function(event) { li.appendChild(a); - browser.runtime.getPlatformInfo().then((info) => { - android = info.os == "android" - - if (android) - li.classList.add("android-feed-btn"); - }); - + if (android) + li.classList.add("android-feed-btn"); feedList.appendChild(li); } } + + + + browser.storage.sync.get({newTab: !android}).then(function(options) { + document.querySelectorAll(".panel-list-item").forEach( (elem) => { function onUpdated(tab) { @@ -82,6 +71,10 @@ document.addEventListener("DOMContentLoaded", function(event) { }); - }); + }); // end forall + + }); // end options + + }); // and getplatform });