formatting and cleanup
This commit is contained in:
@@ -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()
|
if(CurrentInstalledChromeVersion < CurrentChromeStableVersion){
|
||||||
CurrentChromeStableVersion := GetLatestChromeStableVersion()
|
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(){
|
if(InStr(InstalledChromeVersion, "`r"))
|
||||||
; ChromeFilepath is global variable
|
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
|
||||||
|
|
||||||
if(ChromeFilepath = ""){
|
return InstalledChromeVersion
|
||||||
|
}
|
||||||
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%
|
|
||||||
|
|
||||||
|
|
||||||
; Leave this in for now, but i don't think we will be going to using the system Chrome in the future.
|
GetLatestChromeStableVersion(){
|
||||||
; 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"))
|
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
|
||||||
; ChromeFilepath = C:\Program Files\Google\Chrome\Application\chrome.exe
|
json_str := urldownloadtovar("https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json")
|
||||||
}
|
|
||||||
}
|
|
||||||
ToolTip
|
|
||||||
|
|
||||||
|
|
||||||
|
; 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
|
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
|
||||||
InstalledChromeVersion := RunCMD(GetInstalledChromeVersionCommand)
|
; Will return the download URL of Chrome for Testing and Chrome Driver, seperated by a ||
|
||||||
|
|
||||||
if(InStr(InstalledChromeVersion, "`r"))
|
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
|
||||||
InstalledChromeVersion := StrReplace(InstalledChromeVersion, "`r") ; replace any newline characters that powershell returns
|
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(){
|
if(A_index = ChromelabsJsonEntriesCount){
|
||||||
|
Message = "Failed to find %InstalledChromeVersion% in the ChromeLabs Json"
|
||||||
; https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints
|
return Message
|
||||||
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. "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
URLS = %chromeDLURL64%||%chromedriverDLURL64%
|
||||||
GetDownloadURLOfChromeAndDriver(InstalledChromeVersion){
|
return URLS
|
||||||
; 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
|
|
||||||
}
|
|
||||||
@@ -44,12 +44,10 @@ if(!status){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Status := DownloadLatestChromium()
|
Status := DownloadLatestChromium()
|
||||||
if(Status)
|
if(Status)
|
||||||
GuiControl,,ChromeUpdateAvailable, Chrome Up-to-Date
|
GuiControl,,ChromeUpdateAvailable, Chrome Up-to-Date
|
||||||
|
|
||||||
|
|
||||||
Return
|
Return
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
@@ -65,7 +63,17 @@ if(A_GuiControl = "PasteClipboardToSMPTitle"){
|
|||||||
GuiControl,,PostTitle, %Clipboard%
|
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
|
Return
|
||||||
Reference in New Issue
Block a user