--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/397a4d3b-0205-40f5-b693-d9be1c78976bn%40chromium.org.
chrome.runtime.onInstalled.addListener(async () => {
const {id} = await chrome.windows.getCurrent();
const tabs = await chrome.tabs.query({windowId: id});
chrome.debugger.attach({ tabId: tabId }, "1.0",async () => {
await chrome.debugger.sendCommand({ tabId: tabId }, "Page.enable");
chrome.debugger.onEvent.addListener((debuggeeId, method, params) => {
if (method == "Page.javascriptDialogOpening") {
console.log("JavaScript dialog opening: " + JSON.stringify(params));
// Modify/prevent dialog behavior
chrome.debugger.sendCommand({ tabId: tabId }, "Page.handleJavaScriptDialog", {
accept: true
});
}
});
});
```
note you will need to include tabs and debugger to the permissions section of your manifest
Thank you Patrick,I am developing a Chrome extension for a test automation tool. By adding an event listener for each event type that can occur within a document, I can capture any user action on the active tabs page. This is working fine. But I have not found a way to capture when an alert window is generated within the page, that is, the application that is being tested executes an "alert(message)" or "confirm(message)" win a Javascript code inside it. But I have not been able to identify that this window opens and the user accepts or cancels on it.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/CAPAuxoCC%3Dd8iOUuQkNimd6u3d5CU%3D8zApk-%2B02Gu6ZwRdB6Jew%40mail.gmail.com.