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

feat: add context menu to open npubs #2648

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
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
17 changes: 16 additions & 1 deletion src/extension/background-script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ const handleInstalled = (details: { reason: string }) => {
console.info("Alby was recently updated");
isRecentlyUpdated = true;
}

browser.contextMenus.create({
id: "test",
title: "Open on nostr",
type: "normal",
contexts: ["selection"],
});
};

// listen to calls from the content script and calls the actions through the router
Expand Down Expand Up @@ -138,7 +145,15 @@ browser.tabs.onUpdated.addListener(extractLightningData);
// When we subscribe to that event asynchronously in the init() function it is too late and we miss the event.
browser.runtime.onInstalled.addListener(handleInstalled);

async function init() {
browser.contextMenus.onClicked.addListener(function (info) {
// TODO check if npub
browser.tabs.create({
active: true,
url: `https://snort.social/${info.selectionText}`,
});
});

async function init(): Promise<void> {
console.info("Loading background script");

await state.getState().init();
Expand Down
6 changes: 4 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"tabs",
"unlimitedStorage",
"*://*/*",
"identity"
"identity",
"contextMenus"
],
"__chrome__permissions": [
"activeTab",
Expand All @@ -49,7 +50,8 @@
"storage",
"tabs",
"unlimitedStorage",
"identity"
"identity",
"contextMenus"
],
"__chrome__host_permissions": ["*://*/*"],
"content_security_policy": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'",
Expand Down
Loading