greduan / chrome-ext-tabulator

Tabulator is a free Google Chrome extension that helps reduce tab clutter and memory usage by saving all your open tabs into lists which can be restored at another time
ISC License
134 stars 42 forks source link

Only register contextMenus when installing the extension #7

Closed jchaffraix closed 5 years ago

jchaffraix commented 5 years ago

Because the background page is not persistent, it is opened multiples times (e.g. when clicking on the page action and opening the saved tabs).

Instead of making the backgroupd page persistent, which would increase the baseline footprint of the extension, this CL moves the context menu initialization to chrome.runtime.onInstalled as shown in the Context Menu examples: https://developer.chrome.com/extensions/samples#search:contextmenus

This removes the following runtime errors seen in the developer console:

Unchecked runtime.lastError while running contextMenus.create: Cannot create item with duplicate id <...>