Chrome Extension: how to show messages in event page console? - google-chrome-extension

When I display a message from the Chrome extension in the console, I need to open the background page and see the console in it.
Is it possible to somehow make it more convenient - so that these messages are displayed in the console of the event page, without opening additional windows and consoles?

Related

Send message to native host when user click on close button of Firefox browser

I need to send the message to the native host from the Firefox extension when user click on close button.
I have handled the browser.tabs.onRemoved event and sending the message to the native host when this event occurs. It is working fine when user close the tab.
But if user keep open the tab and close Firefox browser window directly then native host does not receive the message.
For Chrome browser it is working fine. We are receiving the message when user close the browser directly. For chrome I have handled the chrome.tabs.onRemoved event.
Does any one have any idea how to handle this scenario?
Thanks.

Why am I not able to view event listeners added by a Chrome extension in DevTools' Event Listeners tab?

I am using Chrome 101 in Windows 10 and have a Chrome extension installed which does an addEventListener("mouseover"..) on every element on the page. I am unable to view these events in the Event Listeners tab in DevTools. This seems to be a bug according to this question. The page shows a workaround. However, the workaround doesn't show the event listener for me.
I switched the console to the extension's context. For several selected different elements and doing a getEventListeners($0), I always get an empty object as shown. I am not sure if this option got broken or what.
Are there any other ways to display these types of event listeners? The mouseover does work on the page and if I put a breakpoint on this event, the debugger stops in the extension's code (along with code from the page).

is it possible to show toast in google chrome extension v3

I want to show some message when use use the google chrome extension plugin, I am using alert to show message like this:
alert("success");
this work fine but need to click close by the user. I want to show some message like some notification and tell use success, but the user did not need do any operate. I have know the chrome notification but it need user to allow the notification. any other way to do some toast in google chrome extension v3?

How to open a chrome extension programatically from a website?

I want to trigger the popup/opening of a chrome extension programatically from a website. Metamask (browser wallet) is doing exactly this when you navigate to a website and press the button "connect to metamask". In fact it's not actually opening the extension like when pressing the extension icon, but it opens a new browser window with the same size loading the extension...
Any idea how to achieve this?
Here's the way I found meanwhile:
post a message from the website to itself via window.postMessage()
content script has an event listener and catches this message
content script sends another message to the service worker (aka background script)
background script has a message listener and creates a new window via chrome.windows.create(<url-to-extension-html>, <height-and-with-same-as-extension>)

Chrome Extension - Open popup from contentScript file

I'm trying to open a popup page from DOM event in content script js file.
I Tried to send message to background page and in the background listener to use:
chrome.browserAction.openPopup() but apparently it's not the way cause browserAction not defined in that context.
The extension is for audio streaming, so while browsing that the audio will keep playing in background.
I managed to make the audio playing work in the simple way: when clicking the extension icon => open's the popup => some event in the popup interact with the from the background and play's the music.
I want to make it work in the following way:
Content script will add button to the user web page(any page).
done
Clicking this button will open the popup, and from there, same logic.
The issue is that I don't know how to open the popup from the content script.
It's actually to trigger to extension icon click from code.
Any ideas?

Resources