@ -310,144 +310,147 @@ DownloadLatestChromium(){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
MsgBox 0x40,, %Message%
MsgBox 0x40,, %Message%
ChromeFilepath := ; clear out chromefilepath variable in case the path changed
ToolTip
ToolTip
return
return
}
}
/*
*/
CheckForChromeUpdates(ChromeFilepath := ""){
if(ChromeFilepath = "")
ChromeFilepath := GetInstalledChromeFilepath()
CheckForChromeUpdates(ChromeFilepath := ""){
CurrentInstalledChromeVersion := GetInstalledChromeVersion()
if(ChromeFilepath = "")
CurrentChromeStableVersion := GetLatestChromeStableVersion()
ChromeFilepath := GetInstalledChromeFilepath()
CurrentInstalledChromeVersion := GetInstalledChromeVersion()
CurrentChromeStableVersion := GetLatestChromeStableVersion()
if(CurrentInstalledChromeVersion < CurrentChromeStableVersion){
ChromeUpdateAvailable := 1
return ChromeUpdateAvailable
}
else, Return 0
if(CurrentInstalledChromeVersion < CurrentChromeStableVersion){
ChromeUpdateAvailable := 1
return ChromeUpdateAvailable
}
}
else, Return 0
GetInstalledChromeFilepath(){
}
; ChromeFilepath is global variable
if(ChromeFilepath = ""){
ChromePortableFilepath = %A_ScriptDir%\Lib\chrome-win64\chrome.exe
GetInstalledChromeFilepath(){
ChromePortableFilepath2 = %A_ScriptDir%\Lib\chrome-win64\chrome-win64\chrome.exe ; filepath of chrome.exe that was downloaded automatically using this uploader
; ChromeFilepath is global variable
if(FileExist(ChromePortableFilepath) or FileExist(ChromePortableFilepath2)){
if(ChromeFilepath = ""){
if(FileExist(ChromePortableFilepath2))
ChromeFilepath := ChromePortableFilepath2
if(FileExist(ChromePortableFilepath))
ChromePortableFilepath = %A_ScriptDir%\Lib\chrome-win64\chrome.exe
ChromeFilepath := ChromePortableFilepath
ChromePortableFilepath2 = %A_ScriptDir%\Lib\chrome-win64\chrome-win64\chrome.exe ; filepath of chrome.exe that was downloaded automatically using this uploader
Message = Using Chromium Portable for Upload
if(FileExist(ChromePortableFilepath) or FileExist(ChromePortableFilepath2)){
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
if(FileExist(ChromePortableFilepath2))
}
ChromeFilepath := ChromePortableFilepath2
else {
MsgBox 0x10, Chromium Portable not Found, Chromium Portable not found. `nPlease make sure it's located at one of the following paths and then try again.`n`n%ChromePortableFilepath% `nOR`n%ChromePortableFilepath2%
if(FileExist(ChromePortableFilepath))
ChromeFilepath := ChromePortableFilepath
; Leave this in for now, but i don't think we will be going to using the system Chrome in the future.
Message = Using Chromium Portable for Upload
; if(FileExist("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"))
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
; ChromeFilepath = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
; if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe"))
; ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe
}
}
}
ToolTip
else {
MsgBox 0x10, Chromium Portable not Found, Chromium Portable not found. `nPlease make sure it's located at one of the following paths and then try again.`n`n%ChromePortableFilepath% `nOR`n%ChromePortableFilepath2%
}
GetInstalledChromeVersion(){
; Leave this in for now, but i don't think we will be going to using the system Chrome in the future.
; if(FileExist("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"))
; ChromeFilepath = C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
if(ChromeFilepath = ""){
; if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe"))
GetInstalledChromeFilepath()
; ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe
}
}
}
ToolTip
GetInstalledChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
}
InstalledChromeVersion := RunCMD(GetInstalledChromeVersionCommand)
if(InStr(InstalledChromeVersion, "`r"))
GetInstalledChromeVersion(){
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
return InstalledChromeVersion
if(ChromeFilepath = ""){
GetInstalledChromeFilepath()
}
}
GetInstalledChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
InstalledChromeVersion := RunCMD(GetInstalledChromeVersionCommand)
GetLatestChromeStableVersion(){
if(InStr(InstalledChromeVersion, "`r"))
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
return InstalledChromeVersion
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
}
; converts json data variable into object
GetLatestChromeStableVersion(){
parsed := JSON.Load(json_str)
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
try ChromeStableLatestVersion := parsed.channels.stable.version
if(ChromeStableLatestVersion = ""){
; converts json data variable into object
return "Failed to parse json. "
parsed := JSON.Load(json_str)
}
return ChromeStableLatestVersion
try ChromeStableLatestVersion := parsed.channels.stable.version
if(ChromeStableLatestVersion = ""){
return "Failed to parse json. "
}
}
return ChromeStableLatestVersion
}
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a ||
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json")
; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a ||
; requires #include of json.ahk in parent script
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
parsed := JSON.Load(json_str )
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json" )
ChromelabsJsonEntriesCount := parsed.versions.count()
; requires #include of json.ahk in parent script
parsed := JSON.Load(json_str)
if(ChromelabsJsonEntriesCount = ""){
ChromelabsJsonEntriesCount := parsed.versions.count()
return "Failed to parse chromedriver json. "
}
loop % ChromelabsJsonEntriesCount {
if(ChromelabsJsonEntriesCount = ""){
return "Failed to parse chromedriver json. "
}
if(A_index = ChromelabsJsonEntriesCount){
loop % ChromelabsJsonEntriesCount {
Message = "Failed to find %InstalledChromeVersion% in the ChromeLabs Json"
return Message
}
if(InstalledChromeVersion = parsed.versions[A_Index].version){
if(A_index = ChromelabsJsonEntriesCount){
Message = "Failed to find %InstalledChromeVersion% in the ChromeLabs Json"
return Message
}
VersionIndex := A_Index
if(InstalledChromeVersion = parsed.versions[A_Index].version){
; loop through the platforms to get download URL for Chrome
VersionIndex := A_Index
loop % parsed.versions[VersionIndex].downloads.chrome.count() {
if(parsed.versions[VersionIndex].downloads.chrome[A_Index].platform = "win64")
; loop through the platforms to get download URL for Chrome
chromeDLURL64 := parsed.versions[VersionIndex].downloads.chrome[A_Index].url
loop % parsed.versions[VersionIndex].downloads.chrome.count() {
}
if(parsed.versions[VersionIndex].downloads.chrome[A_Index].platform = "win64")
chromeDLURL64 := parsed.versions[VersionIndex].downloads.chrome[A_Index].url
}
; loop through the platforms to get download URL for Chromedriver
loop % parsed.versions[VersionIndex].downloads.chromedriver.count() {
if(parsed.versions[VersionIndex].downloads.chromedriver[A_Index].platform = "win64")
; loop through the platforms to get download URL for Chromedriver
chromedriverDLURL64 := parsed.versions[VersionIndex].downloads.chromedriver[A_Index].url
loop % parsed.versions[VersionIndex].downloads.chromedriver.count() {
}
break
if(parsed.versions[VersionIndex].downloads.chromedriver[A_Index].platform = "win64")
chromedriverDLURL64 := parsed.versions[VersionIndex].downloads.chromedriver[A_Index].url
}
}
break
}
}
}
URLS = %chromeDLURL64%||%chromedriverDLURL64%
URLS = %chromeDLURL64%||%chromedriverDLURL64%
return URLS
return URLS
}
}