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

"Cannot use import statement outside module" when registering service worker from script type=module

I've searched for existing answers regarding extensions and service workers, like Workbox service worker: Cannot use import statement outside a module and the answers are either vague "it should theoretically work now" hence asking here, with a…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
0
votes
0 answers

Safari web extension content script's runtime.Port won't post message after extension was re-enabled

I am developing an extension that lets web pages and extensions exchange data. And there's a user scenario like the one below. User opens a website that matches the content script list. The user can use the web page normally (The content script and…
0
votes
1 answer

Canceling request with browser.webRequest.onBeforeRequest also cancels previous pending tab requests

The following code is used in an add-on to cancel all main-frame requests and re-initiates them in a new tab: browser.webRequest.onBeforeRequest.addListener( filterRequest, {urls: [''], types: ['main_frame']}, …
Wizard
  • 2,961
  • 2
  • 13
  • 22
0
votes
0 answers

How can I intercept XHR requests to a specific URI and return my own response using a web extension?

I'm trying to implement a feature in an extension I'm building that consists of "manually" caching requests. It's for a website that has a search box that takes around 15 seconds (when it doesn't timeout) every time I search for something and never…
0
votes
0 answers

How to set title of web extension to the current tab's title? like Facebook e.t.c

I am trying to add the title of the current tab which is being loaded in the browser to my web extension which is locally hosted on my PC. I've attached an external script.js file with my extension which contains the following code: window.onload =…
0
votes
1 answer

"--silent-debugger-extension-api" flag not working as expected

I am getting this banner while using the chrome.debugger APIs. Earlier it was hidden if "--silent-debugger-extension-api" flag was used but from Chrome version 100 and above the flag is not working as expected. Is there any other workaround to hide…
0
votes
0 answers

How to create a one-time onBeforeSendHeaders listener?

I'm using the webRequest.onBeforeSendHeaders API to modify the headers of some HTTP requests. My problem is that each event listener should only be executed once, but for some reason the event listener can't modify the HTTP request and disconnect…
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
0
votes
0 answers

Can browser.tabs.query() return a Tab without an id?

browser.tabs.query returns Tab objects, which have an optional id attribute. So every time I access this id, my IDE "helpfully" warns me that the id might be undefined. Can I safely ignore this warning or can tabs.query() actually return a Tab with…
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
0
votes
1 answer

Why can't jQuery get a CSS file via browser.runtime.getURL?

I'm working on a browser addon for Firefox that is supposed to fetch the content of a CSS resource file (present in the addon's directory) and add it to every website visited. Loading an HTML file works…
0
votes
1 answer

CSS hover and cursor don't work in shadow DOM

I'm working on a browser addon that inserts a widget into any website as a shadow DOM, but for some reason I'm unable to make the CSS :hover selector and cursor property working. Here's the snippet of the content script that creates the shadow…
0
votes
1 answer

Web extension development in safari with JS framework

I'm looking for a way to develop a safari web extension with any JS frameworks like AngularJS / ReactJS. Can someone help me to understand if it's possible, or can it be done only with plain JS? Is there any official safari documentation on this…
user3440725
  • 59
  • 1
  • 6
0
votes
1 answer

Send data to thunderbird Add-on from chrome extension

Is there a way to send data/messages from the chrome extension to the thunderbird add-on? I didn't find any API.
0
votes
1 answer

How to Get Url/Title/Timestamp for browser navigation only with WebExtension API?

I want to get the URL, title for that url and timeStamp for whatever is being navigated by the browser. Using webNavigation.onCommitted, I can get the URL and timeStamp, but not the title (ie if url was stackoverflow.com, the title is Stackoverflow…
0
votes
0 answers

How to add tabId to header with modifyHeader rule in manifest v3?

With webRequest in was quite easy to do: chrome.webRequest.onBeforeSendHeaders.addListener(this.addTabIdToHeader({ tabId }), { urls: ['http://*/*'] }, ['blocking', 'requestHeaders']); Now in declarativeNetRequest there is no current tab id …
0
votes
2 answers

postal-mime library error "TypeError: PostalMime is not a constructor"

I'm trying to use the postal-mime JS library in a Chrome browser extension using Manifest V3. My extension spawns a service worker and I'm trying to use this library there. To import it, I tried both const { PostalMime } =…