Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right click menu disappears after restarting the browser

I am developing a chrome extension. I have added a new menu item in the right click menu for the extension. It works fine after installed.Then when I restart the browser, the new right click menu item disappears!But the extension work well, only the new menu item is gone! I have compared the chrome official sample for contextMenu, seems the same. I just put the create menu code in chrome.runtime.onInstalled.addListener(function() {}) like the sample does..... Any idea why this happens?

Many thanks!

updated: Add the property in the manifest file: "background": { "persistent": false, "scripts": ["background.js"] }

like image 678
kyoraku Avatar asked Dec 06 '25 03:12

kyoraku


1 Answers

I would suggest moving the code to a separate function and then calling that function from both onInstalled and chrome.runtime.onStartup. The first one is invoked when you install or update, while the second one is when you reopen the browser.

like image 92
BeardFist Avatar answered Dec 08 '25 23:12

BeardFist