Skip to content

A way to get and block requests of other extensions in firefox #17

Description

@Landius

TLDR: use browser.proxy.onRequest.

MDN doc about the firefox's proxy API, it's quite different from chromium's chrome.proxy.

use browser.proxy.onRequest.addListener(listener, {urls:['<all_urls>']}) to get requestDetail.
usually, the requestDetail.documentUrl of extension request is in format like: moz-extension://${internalUUID}/path
listener returns an invalid proxy to block request 🤣

internalUUID is unique for each extension, but it's different from the extension id returned by browser.management.getAll(), and I can't find a way to get it in extension.
one way to get internalUUID is, open this page about:debugging#/runtime/this-firefox, run some snippet in devtool:

const idPairArr=[];
for(let card of document.querySelectorAll('.card')){
  const fields = card.querySelectorAll('dd.fieldpair__description');
  if(fields.length>=2){
    idPairArr.push({
      extensionId:fields[0].innerText,
      internalUUID:fields[1].innerText
    })
  }
}
console.log(idPairArr);

related issues: #8, #14

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions