Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show the number of unseen threads in the browser icon #5

Open
j127 opened this issue Jan 4, 2020 · 2 comments
Open

Show the number of unseen threads in the browser icon #5

j127 opened this issue Jan 4, 2020 · 2 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@j127
Copy link
Member

j127 commented Jan 4, 2020

It might be nice to show unread post count on the browser icon. Here are examples from other extensions.

browser action icons

The extension has CORS access to the forum, so a snippet like this should work for getting the number of unread threads/topics.

fetch('https://forum.codeselfstudy.com/notifications.json?recent=true')
    .then(res => res.json())
    .then(json => {
        const numUnseenTopics = json['notifications']
            .filter(n => n.read == false)
            .length;
        console.log('number of unseen topics', numUnseenTopics);
    });
@j127 j127 added good first issue Good for newcomers help wanted Extra attention is needed labels Jan 4, 2020
@j127 j127 self-assigned this Jan 5, 2020
@j127
Copy link
Member Author

j127 commented Jan 5, 2020

This works.

browser.browserAction.setBadgeText({ text: "4" });
browser.browserAction.setBadgeBackgroundColor({ color: "blue" });

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction/setBadgeBackgroundColor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant