Skip to content

Commit

Permalink
fix: match tabs by pattern
Browse files Browse the repository at this point in the history
Using the tabs query API[1], we can match the notification URL by pattern[2] which adds support for the beta program.

[1]: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/query
[2]: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns
  • Loading branch information
austince committed Apr 2, 2020
1 parent 28b50b0 commit 59aa62c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion background.js
@@ -1,4 +1,6 @@
const notificationsUrl = "https://github.com/notifications";
// see: https://wiki.developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns
const notificationsUrlPattern = "https://github.com/notifications/*";
var count = 0;

function update() {
Expand Down Expand Up @@ -97,7 +99,7 @@ setInterval(update, 1000 * 60);

browser.browserAction.onClicked.addListener((e) => {
browser.tabs.query({
'url': notificationsUrl
'url': notificationsUrlPattern
}, (tabs) => {
if (!tabs.length) {
browser.tabs.create({
Expand Down

0 comments on commit 59aa62c

Please sign in to comment.