Jump to content

Recommended Posts

Posted

I was able to run a basic command and get a response --

{
   "id": "1",
   "method": "Browser.getVersion"
}   

{
   "id": "1",
   "result": {
      "protocolVersion": "1.3",
      "product": "Firefox",
      "revision": "1",
      "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0",
      "jsVersion": "1.8.5"
   }
}

Now just need to figure out which commands are supported by Firefox. FWIW, it doesn't appear to recognize Page.addScriptToEvaluateOnNewDocument as a valid method.

Posted (edited)

This spreadsheet shows that that Page.addScriptToEvaluateOnNewDocument is supposed to be working. 🤔

Edit: I was able to get it partially working by using the websocket for an individual tab instead of the main browser websocket. I say partially because it runs without errors, but it doesn't seem to work when I open a new tab.

Spoiler

{
   "id": "1",
   "method": "Page.addScriptToEvaluateOnNewDocument",
   "source": "Object.defineProperty(Navigator.prototype, 'webdriver', {get: Function.prototype.bind()})"
}    

{
   "id": "1",
   "result": {
      "identifier": "937ff430-acc1-4898-a131-f03f0b3979c4"
   }
}   

 

Edited by Danp2
Posted (edited)

@TheDcoder

Thank you so much. Your code snippet workes like a charm.

On 6/16/2021 at 11:56 AM, TheDcoder said:

You can use this code by injecting it into every page on start like so:

; Inject Navigator Shim
Local $sNavShim = 'Object.defineProperty(Navigator.prototype, "webdriver", {get: Function.prototype.bind()})'
Local $oParams = Json_ObjCreate()
Json_ObjPut($oParams, 'source', $sNavShim)
_WD_ExecuteCdpCommand($g_sSession, 'Page.addScriptToEvaluateOnNewDocument', $oParams)

It is just a little annoying that the snippet needs to be inserted every time I want to load up a new site, but I'll take it as long as it works.

Thank you too @Danp2. You guys are great.
I can now continue with my stuff. I am sure that I will be back with more questions (in another thread)

Edited by Sanja

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...