I have a use-case where I have an extension which helps my efficiency at work. I'd like to have my extension listen on certain pages and suspend them as soon as they open, so I can spawn the tabs without taking up much memory.
I want to have the content script send a message to the runtime when it's on a page which matches, however the issue is that currently, the background.js uses the following pattern:
//HANDLERS FOR MESSAGE REQUESTS
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (debug) {
console.log('listener fired:', request.action);
console.dir(sender);
}
switch (request.action) {
case 'prefs':
sendResponse({
...etc.
By extracting that function and simply doing both
chrome.runtime.onMessage.addListener
and
chrome.runtime.onMessageExternal.addListener
This would enable the extension to receive events from other extensions which want to use the suspend functionality in a more specific manner.
I have a use-case where I have an extension which helps my efficiency at work. I'd like to have my extension listen on certain pages and suspend them as soon as they open, so I can spawn the tabs without taking up much memory.
I want to have the content script send a message to the runtime when it's on a page which matches, however the issue is that currently, the background.js uses the following pattern:
...etc.
By extracting that function and simply doing both
and
This would enable the extension to receive events from other extensions which want to use the suspend functionality in a more specific manner.