Questions tagged [web-extension]

Web Extension is API for major browser extension(plugin) development. Use this tag together with browser specific tags google-chrome-extension firefox-addon-webextensions safari-web-extension when you target all browsers and care for compatibility.

Browser Web Extension becomes standard for browser extension/plugin/addon development. Originally developed in Chrome, it was later adopted by Firefox and Edge, and in 2021 by Safari.

However as of 2021 there is no vendor neutral spec, and every browser has its own documentation. W3C WebExtensions Community Group (WECG) https://github.com/w3c/webextensions/ is ongoing effort for standardization.

87 questions
0
votes
0 answers

How to avoid recording history for redirects made using WebExtension webRequest API

Below is source code for a simple web browser add-on that redirects all example.com requests to example.org using WebExtension's webRequest API. I have tested the extension in Mozilla Firefox. manifest.json: { "manifest_version": 2, "name":…
0
votes
0 answers

How do I add support for the 'chrome' namespace to my Vite config?

I'm using Vite and Svelte to develop a Chrome extension, and during build I received warnings like: 3:43:06 PM [vite-plugin-svelte] /home/mike/Code/myapp/components/Component.svelte:50:18 'chrome' is not defined I understand what these warnings…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
0
votes
0 answers

Parcel won't stop emitting Source Maps even when sourceMaps is false in tsconfig.json

I am building a Web Extension using ParcelJS v2.8.3 as the bundler and Parcel keeps emitting inline Source Maps even if tsconfig explicitly tells to not emit or to emit separately in .map.js files. tsconfig.json "sourceMap": false, …
0
votes
0 answers

How can I use Chrome Devtools to block certain network requests in my extension's background script?

I'm writing an extension for Chrome. This extension has a service worker (f.k.a. background script) that makes a network request to a third-party service. However, I'd like to see what happens when this network request fails. How can I block network…
0
votes
0 answers

Chrome DevTools fails to load a WebExtension's source map with ERR_BLOCKED_BY_CLIENT (but I'm not using an ad blocker)

I'm developing a browser extension, and for some reason Chrome will not load the source map for the extension's script. This is the specific error: DevTools failed to load source map: Could not load content for…
0
votes
0 answers

How can I redirect any request with matching URL except a specific exact string?

I'm trying to create a regex filter on mv3 declarativeNetRequest rule but it keep giving me this error Rule with id 1 specifies an incorrect value for the "regexFilter" key. This is the regex I…
0
votes
0 answers

Vite build in sub directory can't find the imported library

I'm building a Browser Extension. I created a Popup with Vue in a subfolder src/popup, and it contains the index.html file and src folder with the Vue app. The build is done by Vite in a gulpfile.js script: const popupRoot = path.join(srcDirPath,…
baruchiro
  • 5,088
  • 5
  • 44
  • 66
0
votes
0 answers

Using zxcvbn with chrome web extension

I am struggling to get the zxcvbn library to work while developing a chrome web extension. I am new to js and my current goal is to output the strength of the password entered into the password field of a website. I have tried implementing the…
0
votes
0 answers

Emulate "Open Link in New Tab" behavior

I don't know if this is the same in all browsers, Firefox has this feature where it cycles through your tabs in a "smart" way. Specifically, consider this sequence of events: You're on Tab1. You create a new tab via right click -> Open Link in New…
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
0
votes
1 answer

webRequest.filterResponseData() always gives error "Invalid request ID"

I am trying to get the response body from an API call made by a website in a Firefox extension. I am trying to do that with the webRequest API. Every time I try to do so, the resulting filter gives me an error that says "Invalid request ID". I know…
0
votes
1 answer

Should a MV3 extension use chrome.runtime.sendMessage() or serviceWorker.controller.postMessage() for messaging?

The Chrome docs mention chrome.runtime.sendMessage and chrome.runtime.onMessage: const response = await chrome.runtime.sendMessage({greeting: "hello"}); chrome.runtime.onMessage(messageHandler) To communicate between a service worker and a content…
0
votes
0 answers

Is it possible to override Ctrl+T in a web extension?

I'd like to be able to run my code in a web extension when the user presses Ctrl+T (or possibly other built-in keyboard shortcuts). Is that possible? MDN says If a key combination is already used by the browser (like "Ctrl+P") or by an existing…
mbork
  • 564
  • 3
  • 23
0
votes
0 answers

Access local profile identifier from web extension

I'm writing a native web extension, and I need to be able to distinguish between different local browser profiles from each other in the native portion of the extension. Is there a way to get some sort of unique identifier from the background script…
10101
  • 320
  • 2
  • 7
0
votes
0 answers

how to change an innerHTML on Whatsapp web?

I was working on a script to mention members on WhatsApp groups by JS. All the work stopped when I wanted to change the innerHTML using the .innerHTML property to place a mention HTML block in it instead of writing the names of the members then…
0
votes
0 answers

Webextension: how to wait for a specific element to appear in the page?

I want to develop a content-script webextension for a particular website, whose document's scripts insert elements into the DOM. I would like my content-script wait for the elements to appear in the DOM so that it can interact with the elements. I…