1

My code is like this, but can't intercept requests from other extensions (e.g. Postman):

chrome.webRequest.onBeforeRequest.addListener(
  function(details){
    console.log(details.method + " ====== "+ details.url + " ====== " + details.timeStamp);
    console.log("---requestbody----: " + details.requestBody);
  },
  {urls: ["<all_urls>"]},
  ["blocking"]
);
Xan
  • 74,770
  • 16
  • 179
  • 206
  • 2
    FWIW, you can probably use chrome.debugger API and --silent-debugger-extension-api command line switch to attach to that other extension's background page and intercept pretty much everything. – wOxxOm Sep 14 '17 at 15:18

2 Answers2

1

Indeed, this code won't.

This is a security feature: webRequest cannot intercept any requests from other extensions or Chrome Apps. Otherwise, it would be possible to inject your code if another extension was loading a third-party library.

It used to be able to, but it was deemed a security bug and fixed.

There is no way to override this.

Generally, extensions are not allowed to interfere with each other (except for external messaging, but both parties have to actively participate) because of privilege escalation concerns.

Xan
  • 74,770
  • 16
  • 179
  • 206
0

You cannot intercept other extension requests but what you can do is get and then change the extension that you want to intercept and add external messaging between those two extensions.

Getting the source and modifying it

  1. Install the Chrome extension source viewer.
  2. Go to the page in the Chrome Web Store of the extension you want to modify.
  3. Click on the yellow CRX button, and choose Download (screenshot).
  4. Extract the zip file.
  5. Read the source code, and change what needs to be changed (in your particular case, I had quickly identified that you wanted to change edit config.js and change the "channel" property). Save the changes.

Or Copy the folder of the extension you wish to modify. ( Named according to the extension ID, to find the ID of the extension, go to chrome://extensions/). Once copied, you have to remove the _metadata folder.

Using the modified version of the extension.

  1. Visit the Chrome extension page (chrome://extensions/).
  2. Enable Developer mode, by putting a check on the checkbox in the upper-right corner.
  3. Click on the "Load unpacked extension" button.
  4. Select the folder of your extension (to know which folder is correct, check whether the folder contains a file called manifest.json).
  5. Confirm. You're done.

Unless you've made a mistake in either of these steps (including the modification of the source code), the modified extension should work as intended.

Source: How to modify an extension from the Chrome Web Store?

Luka Čelebić
  • 1,083
  • 11
  • 21