N
N
NooBick2021-08-11 19:15:22
Google Chrome
NooBick, 2021-08-11 19:15:22

How to intercept packets sent by a site for google extension?

The bottom line is this: I have a VK, I need to intercept that a person is sending a message and send the same message with a different text. I still haven't figured out how to do it. I have a sketch, but it is not connected in any way with VK, and this sketch itself does not work from the word at all.

Manifest.json

{
  "description": "Demonstrating webRequests",
  "manifest_version": 2,
  "name": "webRequest-demo",
  "version": "1.0",

  "permissions": [
    "webRequest",
    "webRequestBlocking",
    "<all_urls>"
  ],

  "background": {
    "scripts": ["background.js"]
  }
}

BackGround.js
chrome.webRequest.onBeforeRequest.addListener(
    function(details) {
      if (details.url.indexOf("://white.listed.site")) console.log("this is a response constructed by VPN extension");
      return {cancel: details.url.indexOf("://www.evil.com/") !== -1}; // если нужно отменить запрос
    },
    {urls: ["<all_urls>"]},
    ["blocking"]
  );
  
  chrome.webRequest.onCompleted.addListener(
    function(details){
      console.log(`Catch ${details.method} response from ${details.url} ${details.fromCache ? '[ from cache ]' : ''} `)
    },
    {
      urls: ["<all_urls>"]
    }
  );

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question