Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🔀 Random GitHub Notification

**Firefox add-on which adds a toolbar button to open a random GitHub notification of yours!**
**Chrome extension which adds a toolbar button to open a random GitHub notification of yours!**

Very useful to catch up and work through notifications – with the excitement of randomness.

Expand Down
35 changes: 22 additions & 13 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
chrome.browserAction.onClicked.addListener(() => {
chrome.tabs.query({ url: "https://github.com/notifications*" }, (tabs) => {
chrome.action.onClicked.addListener(async (tab) => {
try {
const tabs = await chrome.tabs.query({ url: "https://github.com/notifications*" });

if (tabs.length > 0) {
const tab = tabs[0];
chrome.tabs.update(tab.id, { active: true });
chrome.tabs.executeScript(tab.id, { code: `(${startNotificationRandomizer.toString()})()` });
const notificationTab = tabs[0];
await chrome.tabs.update(notificationTab.id, { active: true });
await chrome.scripting.executeScript({
target: { tabId: notificationTab.id },
func: startNotificationRandomizer
});
} else {
chrome.tabs.create({ url: "https://github.com/notifications" }, (newTab) => {
chrome.tabs.onUpdated.addListener(function listener(tabId, changeInfo) {
if (tabId === newTab.id && changeInfo.status === 'complete') {
chrome.tabs.onUpdated.removeListener(listener);
chrome.tabs.executeScript(tabId, { code: `(${startNotificationRandomizer.toString()})()` });
}
});
const newTab = await chrome.tabs.create({ url: "https://github.com/notifications" });
chrome.tabs.onUpdated.addListener(function listener(tabId, changeInfo) {
if (tabId === newTab.id && changeInfo.status === 'complete') {
chrome.tabs.onUpdated.removeListener(listener);
chrome.scripting.executeScript({
target: { tabId: tabId },
func: startNotificationRandomizer
});
}
});
}
});
} catch (error) {
console.error('Error in extension:', error);
}
});

function startNotificationRandomizer() {
Expand Down
73 changes: 0 additions & 73 deletions icon.svg

This file was deleted.

Binary file added icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 12 additions & 11 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "Random GitHub Notification",
"version": "1.0",
"permissions": ["tabs", "activeTab", "https://github.com/*"],
"browser_action": {
"permissions": ["tabs", "activeTab", "scripting"],
"host_permissions": ["https://github.com/*"],
"action": {
"default_icon": {
"48": "icon.svg"
"16": "icon16.png",
"32": "icon32.png",
"48": "icon48.png"
}
},
"background": {
"scripts": ["background.js"]
"service_worker": "background.js"
},
"icons": {
"48": "icon.svg"
},
"browser_specific_settings": {
"gecko": {
"id": "random-github-notification@keeporsweep.net"
}
"16": "icon16.png",
"32": "icon32.png",
"48": "icon48.png",
"128": "icon128.png"
}
}