How to debug chrome extension service worker for manifest v3?

I guess you are looking for the internal ServiceWorker (backend page) of your extension and their connections. There are two URLs you should be aware of: chrome://inspect/#service-workers chrome://serviceworker-internals/?devtools You might also want to “debug the debugger” e.g. for breakpoints inside your extension page. 1. Registered ServiceWorker list (normal + internal) chrome://inspect/#service-workers 2. ServiceWorker activity (active … Read more

Is there any way to keep Developer Tools open when debugging a Chrome Extension?

There are two ways to accomplish this. Click on the Dev Tools popup so the window is focused and then press F5. This will reload the popup and Dev Tools, and will not cause the Dev Tools window to close. If that doesn’t work for you, go to chrome-extension://extensionid/path/to/popup.html on a separate tab on Chrome. … Read more

Chrome content scripts aren’t working: DOMContentLoaded listener does not execute

You are injecting your script after the event you are listening for fires (in this case, DOMContentLoaded). Thus, any code that you have in the listener will not be executed, because the event never fires after you have added your listener. In Chrome extensions and Firefox WebExtensions, when specifying a time for a content script … Read more

Clicking an element on a page through Chrome Extension

Quoting the official documentation: Content scripts are JavaScript files that run in the context of web pages. By using the standard Document Object Model (DOM), they can read details of the web pages the browser visits, or make changes to them. So, using your content_script.js in your popup.html doesn’t make much sense, and results in … Read more

How do you trigger an ‘isTrusted=true’ click event using JavaScript in a Chrome Extension?

You can inject trusted events using the debugger interface. chrome.debugger.attach(target, “1.2”, function() { chrome.debugger.sendCommand(target, “Input.dispatchMouseEvent”, arguments) }) https://developer.chrome.com/extensions/debugger https://chromedevtools.github.io/devtools-protocol/1-2/Input

Accessing console and devtools of extension’s `background` script

You’re looking at the wrong place. These console messages do not appear in the web page, but in the invisible background page (ManifestV2) or service worker (ManifestV3). To view the correct console open devtools for the background script’s context: Visit chrome://extensions/ or right-click the extension icon and select “Manage extensions”. Enable developer mode Click on … Read more