Skip to content

Commit

Permalink
fix: Move the context menu listener to the root level to avoid the te…
Browse files Browse the repository at this point in the history
…rminated issue
  • Loading branch information
siygle committed May 10, 2024
1 parent 7f53050 commit 8d7b64c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@ chrome.runtime.onInstalled.addListener(function () {
id: context
});
}
// Intentionally create an invalid item, to show off error checking in the
// create callback.
chrome.contextMenus.create(
{ title: 'Oops', parentId: 999, id: 'errorItem' },
function () {
if (chrome.runtime.lastError) {
console.log('Got expected error: ' + chrome.runtime.lastError.message);
}
}
);
chrome.contextMenus.onClicked.addListener(genericOnClick);
});

// Move the context menu listener to the root level to avoid the terminated issue
// src: https://stackoverflow.com/a/69012673
chrome.contextMenus.onClicked.addListener(genericOnClick);

function genericOnClick(data, tab) {
if ('page' === data.menuItemId) skeet(data.pageUrl, tab.title);
if ('link' === data.menuItemId) skeet(data.linkUrl);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 3,
"version": "0.0.1",
"version": "0.0.3",
"name": "Share on BlueSky",
"description": "Share the current page on BlueSky",
"icons": {
Expand Down

0 comments on commit 8d7b64c

Please sign in to comment.