I’m creating my first web extension, the ideia is to mute all the farming bots in the Twitter/X’s replies.
I’m currently trying to come up with a solution where I can know if the user clicked on a tweet. My ideia was to add a Proxy
history’s pushState function, using the code I found in the “How to get notified about changes of the history via history.pushState?” question
window.history.pushState = new Proxy(window.history.pushState, {
apply: (target, thisArg, argArray) => {
console.log({ target, thisArg, argArray });
return target.apply(thisArg, argArray);
},
});
But it does not add the Proxy into the page.
Here’s some details that my be useful
- I do have access to the history object, since I can use
history.pushState
function; - The script is being ran, I can log things before and after the code;
- When I paste the code above into the console it does work.
Here’s my manifest file
{
"manifest_version": 3,
"name": "Mute Farm Bot Twitter/X",
"permissions": ["scripting", "tabs"],
"host_permissions": ["https://x.com/*"],
"content_scripts": [
{
"matches": ["https://x.com/*"],
"js": ["script.js"],
"run_at": "document_idle"
}
],
"version": "0.1"
}
Things I tried
- wrap the code inside a function and call it;
- set a timer to run the function after some time;
- find a permission that I might not have.
What I expect
- Proxy being created when I load the page
PedroLzOliveira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.