Jump to content

replacing line in Firefox prefs.js


Recommended Posts

IBM's Access Connections client does not update the proxy information properly in FireFox. I want to write a script that will enter my companies proxy info. Found the setting in one line of the Fire Fox prefs.js and the below script can find the line that the setting is on, but I don't know how to replace the settings in the line.

Tks for the help,

Masonje

#include <file.au3>
Dim $aRecords
Dim $file = @UserProfileDir & "\Application Data\Mozilla\Firefox\Profiles\jwniuhfm.default\prefs.js"
Dim $proxyFind = 'user_pref("network.proxy.autoconfig_url", "'
Dim $proxyFindLen = StringLen($proxyFind)
Dim $proxy = "http://server.domain.com/proxy.pac"

Dim $proxyWrite = $proxyFind & $proxy & '");'

if FileExists($file) Then
    If Not _FileReadToArray($file ,$aRecords) Then
       MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
       Exit
    EndIf
    For $x = 1 to $aRecords[0]
        if StringLeft($aRecords[$x], $proxyFindLen) = $proxyFind Then
            ;udate file here w/ $proxyWrite
            MsgBox(0, "Found it", 'Record:' & $x & @cr & $aRecords[$x])
            
            ExitLoop
        EndIf
    Next
Else
    MsgBox(48, "Error", "Could not find:" & @CR & $file)
EndIf

Exit
Link to comment
Share on other sites

Here try this, but make sure you backup prefs.js. You must also fill out whatever you want the line to be equal to, i didn't do that because i don't know what the final configured line with the correct proxy server settings looks like.

#include <file.au3>
Dim $aRecords
Dim $file = @UserProfileDir & "\Application Data\Mozilla\Firefox\Profiles\jwniuhfm.default\prefs.js"
Dim $proxyFind = 'user_pref("network.proxy.autoconfig_url", "'
Dim $proxyFindLen = StringLen($proxyFind)
Dim $proxy = "http://server.domain.com/proxy.pac"

Dim $proxyWrite = $proxyFind & $proxy & '");'

;BACKUP prefs.js BEFORE RUNNING THIS AS IT WILL BE DELETED!!!!!!11111111111111111111111111111111

if FileExists($file) Then
    If Not _FileReadToArray($file ,$aRecords) Then
       MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
       Exit
    EndIf
    For $x = 1 to $aRecords[0]
        if StringLeft($aRecords[$x], $proxyFindLen) = $proxyFind Then
            ;udate file here w/ $proxyWrite
            MsgBox(0, "Found it", 'Record:' & $x & @cr & $aRecords[$x])
            $aRecords[$x] = ;Set whatever you want the line equal to here
            FileDelete($file) ;BACKUP prefs.js, IT IS DELETED HERE
            _FileWriteFromArray ( $file, $aRecords , 1 ); New prefs.js is written here, should have the new correct value for the proxy.
            ExitLoop
        EndIf
    Next
Else
    MsgBox(48, "Error", "Could not find:" & @CR & $file)
EndIf

Exit

-The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Here try this, but make sure you backup prefs.js. You must also fill out whatever you want the line to be equal to, i didn't do that because i don't know what the final configured line with the correct proxy server settings looks like.

#include <file.au3>
Dim $aRecords
Dim $file = @UserProfileDir & "\Application Data\Mozilla\Firefox\Profiles\jwniuhfm.default\prefs.js"
Dim $proxyFind = 'user_pref("network.proxy.autoconfig_url", "'
Dim $proxyFindLen = StringLen($proxyFind)
Dim $proxy = "http://server.domain.com/proxy.pac"

Dim $proxyWrite = $proxyFind & $proxy & '");'

;BACKUP prefs.js BEFORE RUNNING THIS AS IT WILL BE DELETED!!!!!!11111111111111111111111111111111

if FileExists($file) Then
    If Not _FileReadToArray($file ,$aRecords) Then
       MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
       Exit
    EndIf
    For $x = 1 to $aRecords[0]
        if StringLeft($aRecords[$x], $proxyFindLen) = $proxyFind Then
            ;udate file here w/ $proxyWrite
            MsgBox(0, "Found it", 'Record:' & $x & @cr & $aRecords[$x])
            $aRecords[$x] = ;Set whatever you want the line equal to here
            FileDelete($file) ;BACKUP prefs.js, IT IS DELETED HERE
            _FileWriteFromArray ( $file, $aRecords , 1 ); New prefs.js is written here, should have the new correct value for the proxy.
            ExitLoop
        EndIf
    Next
Else
    MsgBox(48, "Error", "Could not find:" & @CR & $file)
EndIf

Exit

Thanks!

Edited by masonje
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...