0

I am trying to make a Chrome extension that detects when the user makes a post. I am trying to use webRequest to do this but nothing is showing up in console. Does anyone know how to fix this? Also is there a way to retrieve the tweet content? Thank you! I am a complete newbie so I would appreciate any help.

background.js

chrome.webRequest.onBeforeRequest.addListener((details) => {
    console.log("Works")

    if (details.method == "POST" && details.url.includes("https://api.twitter.com/2/tweets")){
        console.log("Tweet posted");
    }
},
{urls: ["https://twitter.com/*"]},
["requestBody"]);

manifest.json

{
    "manifest_version": 3,
    "name":"",
    "version":"1.0",
    "description":"",
    "permissions":["storage","webRequest"],
    "host_permissions":["https://twitter.com/*"],
    "background":{
        "service_worker":"background.js"
    },
    "content_scripts":[
        {
            "matches":["https://twitter.com/*"],
            "js":["contentScript.js"]
        }
    ],
    "action":{
        "default_popup":"popup.html",
        "default_icon":{
            "16":"gradient_icon.png",
            "24":"gradient_icon.png",
            "32":"gradient_icon.png"
        }
    }
}
  • 1) [How to see background.js console?](/a/10258029), 2) Your `urls` and `host_permissions` doesn't include api.twitter.com - fix it by using `https://api.twitter.com/2/tweets`. – wOxxOm May 06 '23 at 04:23

0 Answers0