Skip to content

Commit 01ef786

Browse files
committed
Context menu ok!!!
1 parent c97b307 commit 01ef786

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// This service worker does all Config stuff with sync storage, it handles storage exclusively, other files request data from it and don't care how it is stored.
55
// There is also welcome page handling, it opens a welcome page on install, has to be there cause it's service worker.
66
'use strict';
7+
import './context-menu.js';
78
// Dependencies: default-config.json
89

910
// Ensure the service worker is registered

context-menu.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
chrome.runtime.onInstalled.addListener(() => {
2+
// Create a context menu item for the extension icon.
3+
chrome.contextMenus.create({
4+
id: "open-welcome-page",
5+
title: "Welcome Page", // The text that appears in the menu
6+
contexts: ["action"], // Show only when right-clicking the extension's icon
7+
});
8+
});
9+
10+
// Listen for a click on the context menu item.
11+
chrome.contextMenus.onClicked.addListener((info, tab) => {
12+
if (info.menuItemId === "open-welcome-page") {
13+
// Open your options page (Welcome.html) in a new tab.
14+
chrome.tabs.create({ url: "Welcome.html" });
15+
}
16+
});

manifest.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
},
2424
"options_page": "popup.html",
2525

26-
"permissions": ["storage"],
26+
"permissions": ["storage", "contextMenus"],
2727

2828
"background": {
2929
"service_worker": "config.js",
@@ -65,7 +65,8 @@
6565
"floating-panel-settings.js",
6666
"buttons-injection.js",
6767
"init.js",
68-
"tests.js"
68+
"tests.js",
69+
"context-menu.js"
6970
]
7071
}
7172
],

0 commit comments

Comments
 (0)