Skip to content

Commit 5ad5fe9

Browse files
committed
- Pass on necessary non-global variables to ReplacePaths() (GitHub #10)
- Move previous addonStartup.json from %Temp% to %ProfilePath%
1 parent f093359 commit 5ad5fe9

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

LibreWolf-Portable.ahk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; LibreWolf Portable - https://codeberg.org/ltguillaume/librewolf-portable
2-
;@Ahk2Exe-SetFileVersion 1.4.4
2+
;@Ahk2Exe-SetFileVersion 1.4.5
33

44
;@Ahk2Exe-Bin Unicode 64*
55
;@Ahk2Exe-SetCompanyName LibreWolf Community
@@ -172,20 +172,20 @@ UpdateProfile() {
172172
FileCopy, %ProfilePath%\addonStartup.json.lz4, %A_WorkingDir%
173173

174174
RunWait, dejsonlz4.exe addonStartup.json.lz4 addonStartup.json,, Hide
175-
If (ReplacePaths("addonStartup.json")) {
175+
If (ReplacePaths("addonStartup.json", LibreWolfPathUri, ProfilePathUri)) {
176176
RunWait, jsonlz4.exe addonStartup.json addonStartup.json.lz4,, Hide
177177
FileMove, addonStartup.json.lz4, %ProfilePath%, 1
178178
}
179179
FileDelete, addonStartup.json
180180
}
181181

182182
If (FileExist(ProfilePath "\extensions.json"))
183-
ReplacePaths(ProfilePath "\extensions.json")
183+
ReplacePaths(ProfilePath "\extensions.json", LibreWolfPathUri, ProfilePathUri)
184184

185-
ReplacePaths(ProfilePath "\prefs.js")
185+
ReplacePaths(ProfilePath "\prefs.js", LibreWolfPathUri, ProfilePathUri)
186186
}
187187

188-
ReplacePaths(FilePath) {
188+
ReplacePaths(FilePath, LibreWolfPathUri, ProfilePathUri) {
189189
If (!FileExist(FilePath) And FilePath = ProfilePath "\prefs.js") {
190190
FileAppend, %OverridesPath%, %FilePath%
191191
Return
@@ -199,7 +199,7 @@ ReplacePaths(FilePath) {
199199
FileOrg := File
200200

201201
If (FilePath = ProfilePath "\prefs.js") {
202-
File := RegExReplace(File, "i)(, "")[^""]+?(\Qlibrewolf.overrides.cfg""\E)", "$1" ProfilePathUri "/$2", Count)
202+
File := RegExReplace(File, "i)(,\s*"")[^""]+?(\Qlibrewolf.overrides.cfg""\E)", "$1" ProfilePathUri "/$2", Count)
203203
;MsgBox, librewolf.overrides.cfg path was replaced %Count% times
204204
If (Count = 0)
205205
File .= OverridesPath
@@ -212,7 +212,7 @@ ReplacePaths(FilePath) {
212212
If (File = FileOrg)
213213
Return False
214214
Else {
215-
FileMove, %FilePath%, %FilePath%.pbak, 1
215+
FileMove, %FilePath%, %ProfilePath%\%FilePath%.pbak, 1
216216
FileAppend, %File%, %FilePath%
217217
Return True
218218
}

0 commit comments

Comments
 (0)