Skip to content

Commit

Permalink
v.2.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
philpw99 committed Dec 18, 2022
1 parent ef5da13 commit 72c7374
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions source/Stash_Helper.au3
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ DllCall("User32.dll","bool","SetProcessDPIAware")


; This version only compatible with Stash v17 and above.
Global Const $currentVersion = "v2.4.2"
Global Const $currentVersion = "v2.4.3"

Global Const $gsRegBase = "HKEY_CURRENT_USER\Software\Stash_Helper"

Expand Down Expand Up @@ -940,12 +940,12 @@ Func JsonEscape( $str )
EndFunc

Func StartBrowser()
Switch $stashBrowser
Case "Firefox"
Switch StringLower($stashBrowser)
Case "firefox"
SetupFirefox()
Case "Chrome"
Case "chrome"
SetupChrome()
Case "Edge"
Case "edge"
SetupEdge()
Case Else
$stashBrowser = "Edge"
Expand Down Expand Up @@ -2321,14 +2321,19 @@ Func SetupChrome()
If $gsBrowserLocation <> "" Then
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, ' _
& '"binary":"' & StringReplace($gsBrowserLocation, "\", "\\") & '", ' _
& '"excludeSwitches": [ "enable-automation"], "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
& '"excludeSwitches": [ "enable-automation"], "args":["--user-data-dir=' & GetDefaultChromeProfile() & '", "--profile-directory=Default"]}}}}'
Else
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "args":["--user-data-dir=' & GetDefaultChromeProfile() & '", "--profile-directory=Default"]}}}}'
EndIf

EndSwitch
EndFunc ;==>SetupChrome

Func GetDefaultChromeProfile()
; return like "C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data\\"
return StringReplace( StringReplace( @AppDataDir, "\Roaming", "\Local") , "\", "\\" ) & "\\Google\\Chrome\\User Data\\"
EndFunc

Func SetupEdge()
If Not FileExists(@AppDataDir & "\Webdriver\" & "msedgedriver.exe") Then
Local $b64 = ( @CPUArch = "X64" )
Expand All @@ -2346,14 +2351,20 @@ Func SetupEdge()
_WD_Option('DriverClose', True)
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--verbose --log-path="' & @AppDataDir & "\Webdriver\msedge.log")
; Edge cannot specified an exe location.
Switch $stashBrowserProfile
Case "Private"
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"excludeSwitches": [ "enable-automation"]}}}}'
Case "Default"
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"excludeSwitches": [ "enable-automation"], "args": ["user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Microsoft\\Edge\\User Data\\", "profile-directory=Default"]}}}}'
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"excludeSwitches": [ "enable-automation"], "args": ["user-data-dir='& GetDefaultEdgeProfile() & '", "profile-directory=Default"]}}}}'
EndSwitch
EndFunc ;==>SetupEdge

Func GetDefaultEdgeProfile()
; C:\\Users\\user\\AppData\\Local\\Microsoft\\Edge\\User Data\\
Return StringReplace( StringReplace( @AppDataDir, "\Roaming", "\Local") , "\", "\\" ) & "\\Microsoft\\Edge\\User Data\\"
EndFunc

Func BrowserError($code, $sLine)
MsgBox(48,"Oops !","Something wrong with the browser's driver. Cannot continue." _
& @CRLF & "WinHTTP status code:" & $code & @CRLF & "Script Line:" & $sLine)
Expand Down
Binary file modified source/Stash_Helper.isn
Binary file not shown.
Binary file modified source/release/Stash_Helper.a3x
Binary file not shown.
Binary file not shown.

0 comments on commit 72c7374

Please sign in to comment.