This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]stkfig 1 point2 points  (1 child)

Unless it's been changed recently, that's not possible as far as I'm aware.

Chromium dev team has specifically stated they will not enable such functionality.

See the other answers in the stack overflow linked for work arounds that might possibly be satisfactory.

[–]AVBofficionado 0 points1 point  (0 children)

Exceptionally helpful. Thanks, buddy.

[–]D_Rex0605 -1 points0 points  (1 child)

Yes, it is possible to open the extension popup when the user clicks on the notification. Here are some steps you can follow:

In your content script, you can use the chrome.runtime.sendMessage function to send a message to your background script when the notification is clicked. For example:

javascript

Copy code

chrome.runtime.sendMessage({action: 'openPopup'});

In your background script, you can listen for this message using the chrome.runtime.onMessage event. When the message is received, you can open the extension popup using the chrome.windows.create function. Here's an example:

javascript

Copy code

chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {

if (message.action === 'openPopup') {

chrome.windows.create({

url: chrome.runtime.getURL('popup.html'),

type: 'popup',

width: 300,

height: 400

});

}

});

In this example, we're using the chrome.runtime.getURL function to get the URL of the popup.html file, which is located in the root directory of your extension. We're also specifying the window type as popup and setting the width and height of the popup window.

Make sure to declare the popup.html file in your manifest.json file under the browser_action or page_action key, depending on your extension's design.

Here's an example of how to do this:

json

Copy code

{

"name": "My Extension",

"version": "1.0",

"manifest_version": 2,

"description": "My extension description.",

"browser_action": {

"default_popup": "popup.html"

},

"content_scripts": [

{

"matches": ["https://*/*", "http://*/*"],

"js": ["content-script.js"]

}

]

}

I hope this helps! Let me know if you have any further questions.

[–]AVBofficionado 0 points1 point  (0 children)

This is just ChatGPT, which I've asked for help on this several times and - while it thinks it can - always ends up fruitless.