formatting and cleanup
This commit is contained in:
@@ -310,144 +310,147 @@ DownloadLatestChromium(){
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
MsgBox 0x40,, %Message%
|
||||
|
||||
ChromeFilepath := ; clear out chromefilepath variable in case the path changed
|
||||
|
||||
ToolTip
|
||||
return
|
||||
}
|
||||
/*
|
||||
*/
|
||||
|
||||
|
||||
CheckForChromeUpdates(ChromeFilepath := ""){
|
||||
if(ChromeFilepath = "")
|
||||
ChromeFilepath := GetInstalledChromeFilepath()
|
||||
|
||||
CheckForChromeUpdates(ChromeFilepath := ""){
|
||||
if(ChromeFilepath = "")
|
||||
ChromeFilepath := GetInstalledChromeFilepath()
|
||||
CurrentInstalledChromeVersion := GetInstalledChromeVersion()
|
||||
CurrentChromeStableVersion := GetLatestChromeStableVersion()
|
||||
|
||||
CurrentInstalledChromeVersion := GetInstalledChromeVersion()
|
||||
CurrentChromeStableVersion := GetLatestChromeStableVersion()
|
||||
if(CurrentInstalledChromeVersion < CurrentChromeStableVersion){
|
||||
ChromeUpdateAvailable := 1
|
||||
return ChromeUpdateAvailable
|
||||
}
|
||||
else, Return 0
|
||||
|
||||
if(CurrentInstalledChromeVersion < CurrentChromeStableVersion){
|
||||
ChromeUpdateAvailable := 1
|
||||
return ChromeUpdateAvailable
|
||||
|
||||
}
|
||||
|
||||
|
||||
GetInstalledChromeFilepath(){
|
||||
; ChromeFilepath is global variable
|
||||
|
||||
if(ChromeFilepath = ""){
|
||||
|
||||
ChromePortableFilepath = %A_ScriptDir%\Lib\chrome-win64\chrome.exe
|
||||
ChromePortableFilepath2 = %A_ScriptDir%\Lib\chrome-win64\chrome-win64\chrome.exe ; filepath of chrome.exe that was downloaded automatically using this uploader
|
||||
|
||||
if(FileExist(ChromePortableFilepath) or FileExist(ChromePortableFilepath2)){
|
||||
if(FileExist(ChromePortableFilepath2))
|
||||
ChromeFilepath := ChromePortableFilepath2
|
||||
|
||||
if(FileExist(ChromePortableFilepath))
|
||||
ChromeFilepath := ChromePortableFilepath
|
||||
|
||||
Message = Using Chromium Portable for Upload
|
||||
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
}
|
||||
else, Return 0
|
||||
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%
|
||||
|
||||
|
||||
; 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(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe"))
|
||||
; ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe
|
||||
}
|
||||
}
|
||||
ToolTip
|
||||
|
||||
}
|
||||
|
||||
GetInstalledChromeVersion(){
|
||||
|
||||
if(ChromeFilepath = ""){
|
||||
GetInstalledChromeFilepath()
|
||||
}
|
||||
|
||||
GetInstalledChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
|
||||
InstalledChromeVersion := RunCMD(GetInstalledChromeVersionCommand)
|
||||
|
||||
GetInstalledChromeFilepath(){
|
||||
; ChromeFilepath is global variable
|
||||
if(InStr(InstalledChromeVersion, "`r"))
|
||||
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
|
||||
|
||||
if(ChromeFilepath = ""){
|
||||
|
||||
ChromePortableFilepath = %A_ScriptDir%\Lib\chrome-win64\chrome.exe
|
||||
ChromePortableFilepath2 = %A_ScriptDir%\Lib\chrome-win64\chrome-win64\chrome.exe ; filepath of chrome.exe that was downloaded automatically using this uploader
|
||||
|
||||
if(FileExist(ChromePortableFilepath) or FileExist(ChromePortableFilepath2)){
|
||||
if(FileExist(ChromePortableFilepath2))
|
||||
ChromeFilepath := ChromePortableFilepath2
|
||||
|
||||
if(FileExist(ChromePortableFilepath))
|
||||
ChromeFilepath := ChromePortableFilepath
|
||||
|
||||
Message = Using Chromium Portable for Upload
|
||||
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
}
|
||||
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%
|
||||
return InstalledChromeVersion
|
||||
}
|
||||
|
||||
|
||||
; 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
|
||||
GetLatestChromeStableVersion(){
|
||||
|
||||
; if(FileExist("C:\Program Files\Google\Chrome\Application\chrome.exe"))
|
||||
; ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe
|
||||
}
|
||||
}
|
||||
ToolTip
|
||||
; 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")
|
||||
|
||||
|
||||
; converts json data variable into object
|
||||
parsed := JSON.Load(json_str)
|
||||
|
||||
|
||||
try ChromeStableLatestVersion := parsed.channels.stable.version
|
||||
|
||||
if(ChromeStableLatestVersion = ""){
|
||||
return "Failed to parse json. "
|
||||
}
|
||||
|
||||
GetInstalledChromeVersion(){
|
||||
return ChromeStableLatestVersion
|
||||
}
|
||||
|
||||
if(ChromeFilepath = ""){
|
||||
GetInstalledChromeFilepath()
|
||||
}
|
||||
|
||||
GetInstalledChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
|
||||
InstalledChromeVersion := RunCMD(GetInstalledChromeVersionCommand)
|
||||
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
|
||||
; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a ||
|
||||
|
||||
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
|
||||
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json")
|
||||
|
||||
return InstalledChromeVersion
|
||||
; requires #include of json.ahk in parent script
|
||||
parsed := JSON.Load(json_str)
|
||||
|
||||
ChromelabsJsonEntriesCount := parsed.versions.count()
|
||||
|
||||
if(ChromelabsJsonEntriesCount = ""){
|
||||
return "Failed to parse chromedriver json. "
|
||||
}
|
||||
|
||||
loop % ChromelabsJsonEntriesCount {
|
||||
|
||||
GetLatestChromeStableVersion(){
|
||||
|
||||
; 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")
|
||||
|
||||
|
||||
; converts json data variable into object
|
||||
parsed := JSON.Load(json_str)
|
||||
|
||||
|
||||
try ChromeStableLatestVersion := parsed.channels.stable.version
|
||||
|
||||
if(ChromeStableLatestVersion = ""){
|
||||
return "Failed to parse json. "
|
||||
if(A_index = ChromelabsJsonEntriesCount){
|
||||
Message = "Failed to find %InstalledChromeVersion% in the ChromeLabs Json"
|
||||
return Message
|
||||
}
|
||||
|
||||
return ChromeStableLatestVersion
|
||||
if(InstalledChromeVersion = parsed.versions[A_Index].version){
|
||||
|
||||
VersionIndex := A_Index
|
||||
|
||||
; loop through the platforms to get download URL for Chrome
|
||||
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")
|
||||
chromedriverDLURL64 := parsed.versions[VersionIndex].downloads.chromedriver[A_Index].url
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json")
|
||||
|
||||
; requires #include of json.ahk in parent script
|
||||
parsed := JSON.Load(json_str)
|
||||
|
||||
ChromelabsJsonEntriesCount := parsed.versions.count()
|
||||
|
||||
if(ChromelabsJsonEntriesCount = ""){
|
||||
return "Failed to parse chromedriver json. "
|
||||
}
|
||||
|
||||
loop % ChromelabsJsonEntriesCount {
|
||||
|
||||
if(A_index = ChromelabsJsonEntriesCount){
|
||||
Message = "Failed to find %InstalledChromeVersion% in the ChromeLabs Json"
|
||||
return Message
|
||||
}
|
||||
|
||||
if(InstalledChromeVersion = parsed.versions[A_Index].version){
|
||||
|
||||
VersionIndex := A_Index
|
||||
|
||||
; loop through the platforms to get download URL for Chrome
|
||||
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")
|
||||
chromedriverDLURL64 := parsed.versions[VersionIndex].downloads.chromedriver[A_Index].url
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
URLS = %chromeDLURL64%||%chromedriverDLURL64%
|
||||
return URLS
|
||||
}
|
||||
URLS = %chromeDLURL64%||%chromedriverDLURL64%
|
||||
return URLS
|
||||
}
|
||||
@@ -44,12 +44,10 @@ if(!status){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Status := DownloadLatestChromium()
|
||||
if(Status)
|
||||
GuiControl,,ChromeUpdateAvailable, Chrome Up-to-Date
|
||||
|
||||
|
||||
Return
|
||||
/*
|
||||
*/
|
||||
@@ -65,7 +63,17 @@ if(A_GuiControl = "PasteClipboardToSMPTitle"){
|
||||
GuiControl,,PostTitle, %Clipboard%
|
||||
}
|
||||
|
||||
if(A_GuiControl = "PasteClipboardToFLSTitle"){
|
||||
GuiControl,,LivestreamTitle, %Clipboard%
|
||||
}
|
||||
|
||||
if(A_GuiControl = "PasteClipboardToFLSDescription"){
|
||||
GuiControl,,LivestreamDescription, %Clipboard%
|
||||
}
|
||||
|
||||
if(A_GuiControl = "PasteClipboardToFLSTags"){
|
||||
GuiControl,,LivestreamTags, %Clipboard%
|
||||
}
|
||||
|
||||
|
||||
Return
|
||||
Reference in New Issue
Block a user