Geograph

Simple way to change Firefox Useragent

1 post in this topic

Simple changing Firefox User-Agent using "FF.au3" without manual edit "prefs.js"

#Include <FF.au3>

If _FFConnect() Then
   ;Default User-Agent
   _FFOpenURL("http://useragentstring.com/")
   Sleep(5000)
   
   ;Set new User-Agent
   FFSetUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36")
   _FFOpenURL("http://useragentstring.com/")
   Sleep(5000)
   
   ;Reset to default User-Agent
   FFResetUserAgent()
   _FFOpenURL("http://useragentstring.com/")
   Sleep(5000)
   
   _FFDisConnect()
Else
   MsgBox(0, "", "Can't connect to FireFox!")
EndIf

Func FFResetUserAgent()
   _FFCmd("Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService).getBranch('general.useragent.').clearUserPref('override');")
EndFunc

Func FFSetUserAgent($useragent)
   FFResetUserAgent()
   _FFCmd("Ci=Components.interfaces;Cc=Components.classes;string=Cc['@mozilla.org/supports-string;1'].createInstance(Ci.nsISupportsString);string.data='" & $useragent & "';Cc['@mozilla.org/preferences-service;1'].getService(Ci.nsIPrefService).getBranch('general.useragent.').setComplexValue('override',Ci.nsISupportsString,string);")
EndFunc

 

Share this post


Link to post
Share on other sites



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