addons/firefox-addons/feed-preview

changeset 11:a4590add4901

Add preset with common web-based feed readers
author Guido Berhoerster <guido+feed-preview@berhoerster.name>
date Sat Dec 08 12:01:32 2018 +0100 (18 months ago)
parents ff5e5e3eba32
children 1e9aa12d7306
files js/background.js
line diff
     1.1 --- a/js/background.js	Fri Dec 07 23:00:41 2018 +0100
     1.2 +++ b/js/background.js	Sat Dec 08 12:01:32 2018 +0100
     1.3 @@ -11,6 +11,40 @@
     1.4  import * as feedParser from './feed-parser.js';
     1.5  import {renderFeedPreview} from './feed-preview.js';
     1.6  
     1.7 +const FEED_READERS_PRESET = [
     1.8 +    {
     1.9 +        title: 'Feedly',
    1.10 +        urlTemplate: 'https://feedly.com/#subscription/feed/%s'
    1.11 +    },
    1.12 +    {
    1.13 +        title: 'FlowReader',
    1.14 +        urlTemplate: 'https://www.flowreader.com/subscribe?url=%s'
    1.15 +    },
    1.16 +    {
    1.17 +        title: 'InoReader',
    1.18 +        urlTemplate: 'https://www.inoreader.com/feed/%s'
    1.19 +    },
    1.20 +    {
    1.21 +        title: 'Kouio',
    1.22 +        urlTemplate: 'https://kouio.com/subscribe?url=%s'
    1.23 +    },
    1.24 +    {
    1.25 +        title: 'My Yahoo',
    1.26 +        urlTemplate: 'https://add.my.yahoo.com/rss?url=%s'
    1.27 +    },
    1.28 +    {
    1.29 +        title: 'Netvibes',
    1.30 +        urlTemplate: 'https://www.netvibes.com/subscribe.php?url=%s'
    1.31 +    },
    1.32 +    {
    1.33 +        title: 'NewsBlur',
    1.34 +        urlTemplate: 'https://www.newsblur.com/?url=%s'
    1.35 +    },
    1.36 +    {
    1.37 +        title: 'The Old Reader',
    1.38 +        urlTemplate: 'https://theoldreader.com/feeds/subscribe?url=%s'
    1.39 +    }
    1.40 +];
    1.41  const FEED_MAGIC = [
    1.42      '<rss',
    1.43      '<feed',
    1.44 @@ -172,3 +206,19 @@
    1.45      tabsFeeds.delete(tabId);
    1.46      tabsFeedPreviews.delete(tabId);
    1.47  });
    1.48 +
    1.49 +browser.runtime.onInstalled.addListener(async details => {
    1.50 +    if (details.reason === 'install' ||
    1.51 +            (details.reason === 'update' && details.previousVersion < 2)) {
    1.52 +        let {feedReaders = []} = await browser.storage.sync.get('feedReaders');
    1.53 +        let feedReadersSet =
    1.54 +                new Set(feedReaders.map(feedReader => feedReader.urlTemplate));
    1.55 +        for (let feedReader of FEED_READERS_PRESET) {
    1.56 +            if (!feedReadersSet.has(feedReader.urlTemplate)) {
    1.57 +                feedReaders.push(feedReader);
    1.58 +            }
    1.59 +        }
    1.60 +        console.log('set feedReaders to', feedReaders);
    1.61 +        browser.storage.sync.set({feedReaders});
    1.62 +    }
    1.63 +});