Skip to content

Commit

Permalink
Merge pull request #98 from shgysk8zer0/patch/misc-fixes
Browse files Browse the repository at this point in the history
Fix various issues
  • Loading branch information
shgysk8zer0 authored Aug 4, 2018
2 parents e2619ea + fb2c71b commit afa3dbb
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
2,
"always"
],
"no-console": 0,
"no-console": 1,
"async-await/space-after-async": 2,
"async-await/space-after-await": 2
},
Expand Down
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"message": "New Tab",
"description": "Text to display for new tab `<option>`"
},
"option_feedOpenAdjacentTab": {
"message": "Adjacent Tab",
"description": "Text to display for new tab `<option>`"
},
"option_feedOpenNewWindow": {
"message": "New window",
"description": "Text to display for new window `<option>`"
Expand Down
5 changes: 5 additions & 0 deletions css/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ form svg.icon {
svg.icon {
color: inherit;
fill: currentColor !important;
vertical-align: middle;
}

input {
vertical-align: middle;
}

footer {
Expand Down
10 changes: 9 additions & 1 deletion css/popup.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
* {
box-sizing: inherit;
max-width: 100%;
}

body {
background-color: var(--feed-bg-color, none);
background-image: var(--feed-bg-image, none);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
box-sizing: border-box;
}

a, [data-link], a:hover, [data-link]:hover {
box-sizing: border-box;
font-family: var(--feed-font, inherit);
font-size: var(--feed-size, inherit);
text-decoration: inherit;
Expand All @@ -20,5 +25,8 @@ a, [data-link], a:hover, [data-link]:hover {
}

a, [data-link] {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: var(--feed-color, inherit);
}
2 changes: 1 addition & 1 deletion icons/subscribe-64.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 31 additions & 6 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const ICONS = {
disabled: 'icons/subscribe-disabled.svg',
};

function openFeed({feed, target = 'current', service = 'rss'} = {}) {
function openFeed({feed, target = 'current', service = 'rss', index = undefined} = {}) {
let url = null;
switch (service) {
case 'feedly':
Expand All @@ -44,7 +44,16 @@ function openFeed({feed, target = 'current', service = 'rss'} = {}) {
break;

case 'tab':
browser.tabs.create({url: url.toString()});
browser.tabs.create({
url: url.toString(),
});
break;

case 'next':
browser.tabs.create({
url: url.toString(),
index,
});
break;

case 'current':
Expand All @@ -58,13 +67,17 @@ function openFeed({feed, target = 'current', service = 'rss'} = {}) {

async function clickHandler(tab) {
const opts = await storage.get(['openFeed', 'service']);
const index = opts.openFeed === 'next' ? tab.index + 1 : null;

try {
openFeed({
feed: TABS[tab.id][0].href,
target: opts.openFeed,
service: opts.service,
index,
});
} catch (err) {
/* eslint no-console: 0 */
console.error(err);
}
}
Expand All @@ -76,7 +89,10 @@ function removeHandler(tabId) {
async function updatePageAction(tab, links) {
if (links.length > 0) {
const opts = await storage.get('icon');
TABS[tab.id] = links;
TABS[tab.id] = links.map(link => {
link.tabId = tab.id;
return link;
});

if (! ICONS.hasOwnProperty(opts.icon)) {
opts.icon = defaultOpts.icon;
Expand Down Expand Up @@ -108,13 +124,20 @@ async function updatePageAction(tab, links) {
}
}

function messageHandler(msg, sender) {
async function messageHandler(msg, sender) {
switch (msg.type) {
case 'feeds':
updatePageAction(sender.tab, msg.links);
break;

case 'openFeed':
if (msg.params.target === 'next') {
const tabs = await browser.tabs.query({active: true, currentWindow: true});
if (tabs.length === 1) {
const tab = tabs[0];
msg.params.index = tab.index + 1;
}
}
openFeed(msg.params);
break;

Expand All @@ -136,7 +159,7 @@ function scanPage(tab) {
title: browser.i18n.getMessage('extensionNA'),
});

browser.tabs.sendMessage(tabId, {type: 'scan'});
browser.tabs.sendMessage(tabId, {type: 'scan'}).catch(() => {});
}

async function refreshAllTabsPageAction() {
Expand Down Expand Up @@ -176,7 +199,9 @@ async function optChange(opts) {

async function updateHandler(update) {
if (update.temporary) {
storage.get().then(opts => console.log({update, opts}));
/* eslint no-console: 0 */
const opts = await storage.get();
console.log({update, opts});
}

if (update.reason === 'install') {
Expand Down
9 changes: 3 additions & 6 deletions js/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ function filterLink(link) {
}

function mapLink(link) {
return {
type: link.type,
href: link.href,
title: link.title || link.href
};
const {type, href, title = link.href} = link;
return {type, href, title};
}

function scanThisPage() {
Expand All @@ -20,7 +17,7 @@ function scanThisPage() {
browser.runtime.sendMessage({
type: 'feeds',
links: feedLinks,
});
}).catch(() => {});
}
}

Expand Down
4 changes: 3 additions & 1 deletion js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const types = {
function $(query, base = document) {
return [...base.querySelectorAll(query)];
}

async function init() {
const opts = await storage.get([
'template',
Expand Down Expand Up @@ -42,7 +43,6 @@ async function init() {
if (opts.hasOwnProperty('bgImage')) {
document.documentElement.style.setProperty('--feed-bg-image', `url(${opts.bgImage})`);
}
console.log(document.documentElement.style);

try {
links.forEach(link => {
Expand All @@ -59,6 +59,7 @@ async function init() {
container.appendChild(feed);
});
} catch (error) {
/* eslint no-console: 0 */
console.error(error);
}
}
Expand All @@ -67,6 +68,7 @@ async function openFeed(click) {
click.preventDefault();

const opts = await storage.get(['openFeed', 'service']);

browser.runtime.sendMessage({
type: 'openFeed',
params: {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Chris Zuber",
"url": "https://shgysk8zer0.github.io"
},
"version": "1.2.7",
"version": "1.3.0",
"description": "__MSG_extensionDescription__",
"homepage_url": "https://github.com/shgysk8zer0/awesome-rss",
"icons": {
Expand Down
7 changes: 4 additions & 3 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@
</fieldset>
<fieldset>
<legend data-locale-text="subscriptionLegend">Subscribe Using</legend>
<input type="radio" name="service" id="subscribe-rss" value="rss" checked="" />
<label for="subscribe-rss" class="browser-style-label" title="Subscribe using RSS (default)" data-locale-title="rssSubscribe">
<svg class="icon" width="32" height="32">
<use xlink:href="icons.svg#rss" />
</svg>
<span>RSS</span>
</label>
<input type="radio" name="service" id="subscribe-rss" value="rss" checked="" />
<input type="radio" name="service" value="feedly" id="subscribe-feedly" />
<label for="subscribe-feedly" class="browser-style-label" title="Subscribe using Feedly" data-locale-title="feedlySubscribe">
<svg class="icon" width="32" height="32">
<use xlink:href="icons.svg#feedly" />
</svg>
<span>Feedly</span>
</label>
<input type="radio" name="service" value="feedly" id="subscribe-feedly" />
<input type="radio" name="service" id="subscribe-inoreader" value="inoreader" />
<label for="subscribe-inoreader" class="browser-style-label" title="Subscribe using Inoreader" data-locale-title="inoreaderSubscribe">
<svg class="icon" width="32" height="32">
<use xlink:href="icons.svg#inoreader" />
</svg>
<span>Inoreader</span>
</label>
<input type="radio" name="service" id="subscribe-inoreader" value="inoreader" />
</fieldset>
<fieldset>
<legend data-locale-text="popupOptionsLegend">Popup Options</legend>
Expand All @@ -56,6 +56,7 @@
</label>
<select name="openFeed" id="openFeed" class="browser-style" required="">
<option value="current" selected="" data-locale-text="option_feedOpenCurrentTab">Current tab</option>
<option value="next" data-locale-text="option_feedOpenAdjacentTab">Adjacent tab</option>
<option value="tab" data-locale-text="option_feedOpenNewTab">New tab</option>
<option value="window" data-locale-text="option_feedOpenNewWindow">New window</option>
</select>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "awesome-rss",
"version": "1.2.7",
"version": "1.3.0",
"description": "Puts an RSS/Atom subscribe button back in URL bar",
"keywords": [
"WebExtension",
Expand Down
1 change: 1 addition & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<script src="js/popup.js" async=""></script>
<link rel="stylesheet" href="css/popup.css" />
</head>
Expand Down

0 comments on commit afa3dbb

Please sign in to comment.