From 8d7b64c6979d46327f117ad4a096f6bbb7a28f56 Mon Sep 17 00:00:00 2001 From: sy Date: Fri, 10 May 2024 09:22:48 +0800 Subject: [PATCH] fix: Move the context menu listener to the root level to avoid the terminated issue --- background.js | 15 ++++----------- manifest.json | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/background.js b/background.js index e192824..897c9f2 100644 --- a/background.js +++ b/background.js @@ -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); diff --git a/manifest.json b/manifest.json index a5370c4..765415b 100644 --- a/manifest.json +++ b/manifest.json @@ -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": {