I am facing issues to make click event trusted in chrome extension. I have already seen a stack overflow answer which depicts that we can do with the help of chrome.debugger.attach but, I am not sure how to include that to my code. Sorry I am pretty new to extensions and I have already made js code to click on buttons but, it sends istrusted=false
.
I have a manifest file an alert.js
file and a code.js
file which contains the code to click on a button.
This is the code which I have seen on StackOverflow but I was unable to implement it:
chrome.debugger.attach(target, "1.2", function()
{
chrome.debugger.sendCommand(target, "Input.dispatchMouseEvent", arguments)
})
My alert.js file
injectScript( chrome.extension.getURL('code.js'), 'body');
function injectScript(file, node)
{
var th = document.getElementsByTagName(node)[0];
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', file);
th.appendChild(s);
}
My code.js file is a small code to click a button which I need to send a trusted event.
My only need to send istrusted
to true since many websites could track the user is clicking through script using this.