1

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.

Cosmin Staicu
  • 1,809
  • 2
  • 20
  • 27
Rohit Kumar
  • 65
  • 1
  • 8
  • *"This is the code which I have seen on StackOverflow..."* Where? Link it in the question. – T.J. Crowder Aug 20 '19 at 10:24
  • And now you want to cheat these pages who're trying protect their content from spam attacks ..? – Teemu Aug 20 '19 at 10:24
  • Possible duplicate of [How to trigger an ‘isTrusted=true’ click event using JavaScript?](https://stackoverflow.com/questions/34853588/how-to-trigger-an-istrusted-true-click-event-using-javascript) – wOxxOm Aug 20 '19 at 10:30
  • Hi, T.J link to the stack overflow questions is https://stackoverflow.com/questions/34853588/how-to-trigger-an-istrusted-true-click-event-using-javascript?noredirect=1&lq=1 – Rohit Kumar Aug 20 '19 at 10:32
  • Hi teemu, I am not trying to cheat its like I want to skip a part of clicks on thier website since they ask a lot of inputs while going to next pages but, I am mainly concerned to read their content. – Rohit Kumar Aug 20 '19 at 10:33
  • Hi @wOxxOm Please if you can explain a bit how to use it. Please I am really suffering. I want to workaround soon. – Rohit Kumar Aug 20 '19 at 10:35
  • You can use chrome.debugger API in your background script or in browserAction popup script. You can't use it in an injected script or in content script. However I don't know what's the actual problem you're facing. Make sure you know how to use devtools to debug your code. – wOxxOm Aug 20 '19 at 10:40
  • Hi @wOxxOm first of all thank you so much. I am pretty new to extension devlopment. I am working hard to learn to my best but, I would really appreciate if you could share some link to video or resources which will depict about using the debugger scripts API in background. – Rohit Kumar Aug 20 '19 at 10:46
  • I don't have any examples. It should be possible to find them in google search. – wOxxOm Aug 20 '19 at 10:58

0 Answers0