Jump to content

Search the Community

Showing results for tags 'prefs.js'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hello ! Here is a small function which allows you to make changes in the Firefox configuration file (of the user running the script) Warning : to make changes into the configuration file, Firefox must be stopped Here you can find some settings in this webpage : http://kb.mozillazine.org/About:config_entries Examples : ; Changes the start page _FF_Config("browser.startup.homepage", "http://www.autoitscript.com/forum") ; Set a manual proxy _FF_Config("network.proxy.type", 1) ; Sets the proxy in manual mode _FF_Config("network.proxy.http", "192.168.1.10") ; Sets the http proxy name/IP _FF_Config("network.proxy.http_port", 3128) ; Sets the http proxy port _FF_Config("network. proxy. autoconfig_url") ; Remove the proxy url ; Allow popups _FF_Config("dom.disable_open_during_load", false) Also, you can use _FF_GetProfileList() to retrieve the list of Firefox profiles for the current user. Now, the two functions : #include <File.au3> ; needed for _PathFull ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FF_Config ; Description ...: Configures Mozilla Firefox ; Syntax ........: _FF_Config($sSettingName[, $sSettingValue = Null[, $sProfileName = ""]]) ; Parameters ....: $sSettingName - Name of the setting to add, change or delete. ; $sSettingValue - [optional] Value of the setting. Default is Null = deletes the line. ; $sProfileName - [optional] Name of the Firefox profile. Default is "" = all Firefox profiles ; Return values .: Success - Returns 1 ; Failure - Returns 0 and set @error to : ; 1 : Unable to list the Firefox profiles ; 2 : Unable to load the specified Firefox profile ; 3 : Firefox is running ; Author ........: jguinch ; =============================================================================================================================== Func _FF_Config($sSettingName, $sSettingValue = Null, $sProfileName = "") Local $sFFConfigFile = "prefs.js" Local $sContent, $aProfiles = _FF_GetProfileList(), $iError = 0, $hPrefs If @error Then Return SetError(@error, 0, 0) If ProcessExists("firefox.exe") Then Return SetError(3, 0, 0) If IsString($sSettingValue) Then $sSettingValue = '"' & $sSettingValue & '"' If IsBool($sSettingValue) Then $sSettingValue = StringLower($sSettingValue) For $i = 1 To $aProfiles[0][0] If $sProfileName <> "" AND $aProfiles[$i][0] <> $sProfileName Then ContinueLoop $sContent = FileRead($aProfiles[$i][1] & "\" & $sFFConfigFile) If @error Then Return SetError(2, 0, 0) If $sSettingValue = Null Then $sNewContent = StringRegExpReplace($sContent, '(?mi)^\Quser_pref("' & $sSettingName & '"\E\V+\R', '') Else $sNewContent = StringRegExpReplace($sContent, '(?mi)^\Quser_pref("' & $sSettingName & '", \E\K.+(?=\);$)', $sSettingValue) If NOT @extended Then $sNewContent = StringRegExpReplace($sContent, ";\K\v*$", @CRLF & 'user_pref("' & $sSettingName & '", ' & $sSettingValue & ');' & @CRLF) EndIf $hPrefs = FileOpen($aProfiles[$i][1] & "\" & $sFFConfigFile, 2) If $hPrefs = -1 Then Return SetError(2, 0, 0) FileWrite($hPrefs, $sNewContent) FileClose($hPrefs) Next Return 1 EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FF_GetProfileList ; Description ...: List the Firefox profiles in a 2D array ; Syntax ........: _FF_GetProfileList() ; Parameters ....: None ; Return values .: Success - Returns a 2D array (see remarks) ; Failure - Returns 0 and set @error to 1 (unable to list the Firefox profiles) ; Author ........: jguinch ; Remarks........: The array returned is two-dimensional and is made up as follows: ; $aArray[0][0] : Number of profiles ; $aArray[0][1] : Default profile index in the array ; $aArray[1][0] : 1st profile name ; $aArray[1][1] : 1st profile path ; ... ; $aArray[n][0] : nth profile name ; $aArray[n][1] : nth profile path ; =============================================================================================================================== Func _FF_GetProfileList() Local $sProfileName, $sIsRelative, $sProfilePath, $aResult[10][2] = [[0]] Local $sFFAppDataPah = @AppDataDir & "\Mozilla\Firefox" Local $sProfiles = $sFFAppDataPah & "\profiles.ini" Local $aSections = IniReadSectionNames($sProfiles) If @error OR NOT IsArray($aSections) Then Return SetError(1, 1, 0) For $i = 1 To $aSections[0] If $aSections[$i] <> "General" Then $sProfileName = IniRead($sProfiles, $aSections[$i], "Name", "") $sIsRelative = IniRead($sProfiles, $aSections[$i], "IsRelative", "") $sProfilePath = IniRead($sProfiles, $aSections[$i], "Path", "") If $sIsRelative = "" OR $sProfilePath = "" OR $sProfileName = "" Then ContinueLoop If Number($sIsRelative) = 1 Then $sProfilePath = _PathFull( @AppDataDir & "\Mozilla\Firefox\" & StringReplace($sProfilePath, "/", "\") ) If NOT FileExists($sProfilePath & "\prefs.js") Then ContinueLoop $aResult[0][0] += 1 If $aResult[0][0] = UBound($aResult) Then Redim $aResult[ UBound($aResult) * 2][2] If Number(IniRead($sProfiles, $aSections[$i], "Default", "error")) = 1 Then $aResult[0][1] = $aResult[0][0] $aResult[ $aResult[0][0] ][0] = $sProfileName $aResult[ $aResult[0][0] ][1] = $sProfilePath EndIf Next If NOT $aResult[0][1] AND $aResult[0][0] > 0 Then $aResult[0][1] = 1 Redim $aResult [ $aResult[0][0] + 1 ][2] Return $aResult EndFunc
×
×
  • Create New...