Page 2 of 2
Re: TWebView() and Google Group Account
Posted: Fri Jul 01, 2022 10:36 pm
by Antonio Linares
Re: TWebView() and Google Group Account
Posted: Fri Jul 01, 2022 10:57 pm
by Antonio Linares
I am trying this with no success yet:
oWebView:Eval( "navigator.__defineGetter__('userAgent', function () { return 'Chrome' } );" )
In fact, from the inspector console you can try this javacript:
console.log( navigator.userAgent );
navigator.__defineGetter__('userAgent', function () { return 'Chrome' } );
console.log( navigator.userAgent ); // we get Chrome here
I think we are quite close to get it...

Re: TWebView() and Google Group Account
Posted: Sat Jul 02, 2022 6:40 am
by Antonio Linares
New answer from Steffen and our answer to him. Meanwhile we don't find a way to programmatically uncheck the default userAgent from the inspector, I guess that there is no other way except doing it by "hand"
https://github.com/webview/webview/issues/792this code should do the "magic" and in fact it changes the navigator.userAgent but still forces us to manually uncheck the default userAgent from the inspector:
Code: Select all | Expand
function Main()
local oWebView := TWebView():New()
oWebView:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
oWebView:Bind( "SendToFWH" )
oWebView:Navigate( "http://www.google.com" ) // Html() )
Sleep( 200 )
oWebView:Eval( "navigator.__defineGetter__('userAgent', function () { return 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36' } )" )
oWebView:Eval( "SendToFWH( navigator.userAgent )" )
oWebView:Run()
oWebView:Destroy()
return nil
Re: TWebView() and Google Group Account
Posted: Sat Jul 02, 2022 7:40 am
by Antonio Linares
Miracle exists... Steffen has included a new function into webview.dll thanks to our requests:
Code: Select all | Expand
https://github.com/webview/webview/issues/792#issuecomment-1172852232
While your approach may work, I suspect that it is not going to be sufficient because the user agent is sent to the server with every HTTP request, and I doubt that you can successfully intercept them all using only JavaScript. The sure way to make this work is to integrate it properly with the underlying browser engine (e.g. WebView2 as you are using Windows).
Here it is the commit he did this morning:
https://github.com/webview/webview/compare/master...SteffenL:webview:up/set-user-agentwhere he is adding a new function:
Code: Select all | Expand
WEBVIEW_API void webview_set_user_agent(webview_t w, const char *agent);
Now we just need to rebuild the DLL and test it...

It feels simply great when you find people like Steffen...
Re: TWebView() and Google Group Account
Posted: Sat Jul 02, 2022 8:24 am
by Antonio Linares
c:\>git clone --branch up/set-user-agent
https://github.com/SteffenL/webview webview_useragent
Then open a "Developer command prompt for VS2022" as administrator and go to c:\webview_useragent\script\
and run build.bat
We got webview.dll properly built and it is working fine and the problem is solved !!!!!!!!!!!!!!!!

Here it is the FWH code to access google.com and identify yourself with no issues at all

Code: Select all | Expand
#include "FiveWin.ch"
//----------------------------------------------------------------------------//
function Main()
local oWebView := TWebView():New()
oWebView:Navigate( "http://www.google.com" )
Sleep( 200 )
oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )
oWebView:Run()
oWebView:Destroy()
return nil
Working as expected !!! Great!

Re: TWebView() and Google Group Account
Posted: Sat Jul 02, 2022 9:04 am
by Antonio Linares
Dear Jimmy,
We have published a revised FWH 22.06 including this new method and updated DLLs and we are emailing it to you.
To all FWH users, please download FWH 22.06 again.
Please notice that both webview.dll and WebView2Loader.dll have been updated !!!
many thanks!
Re: TWebView() and Google Group Account
Posted: Sat Jul 02, 2022 3:43 pm
by Jimmy
hi Antonio,
Antonio Linares wrote:We have published a revised FWH 22.06 including this new method and updated DLLs and we are emailing it to you.
i have download new Version, install it and build your new Sample and it WORK, GREATE
now i can login to harbour Group at Google, YouTube and all Website where i can use Google Account.
Thx for you fast response to fix the Problem