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"
}
}
}