added selenium and ntfy API libs
This commit is contained in:
parent
d882f43854
commit
6fecd442b8
42
NTFY-API.ahk
Normal file
42
NTFY-API.ahk
Normal file
@ -0,0 +1,42 @@
|
||||
; Notes/Extra Info/#Includes
|
||||
;------------------------------------------------
|
||||
; Post to ntfy.sh from your autohotkey scripts
|
||||
|
||||
; Original code grabbed copied from:
|
||||
; https://www.ahkscript.org/boards/viewtopic.php?t=112869
|
||||
|
||||
|
||||
; Functions
|
||||
;------------------------------------------------
|
||||
SendNTFYMessage(title := "", message := "", topicUrl := "", priority := "", tags := "", click := "", token := ""){
|
||||
|
||||
if(topicUrl = ""){
|
||||
Return "Post Failed. No topicUrl passed."
|
||||
}
|
||||
|
||||
ntfy := ComObjCreate("WinHttp.WinHttpRequest.5.1")
|
||||
ntfy.Open("POST", topicUrl, false)
|
||||
|
||||
if(title)
|
||||
ntfy.SetRequestHeader("Title", title)
|
||||
|
||||
if(priority)
|
||||
ntfy.SetRequestHeader("Priority", priority)
|
||||
|
||||
if(tags)
|
||||
ntfy.SetRequestHeader("Tags", tags)
|
||||
|
||||
if(Click)
|
||||
ntfy.SetRequestHeader("Click", click)
|
||||
|
||||
if(Token){
|
||||
Token := "Bearer " . Token
|
||||
ntfy.SetRequestHeader("Authorization", Token)
|
||||
}
|
||||
|
||||
try ntfy.Send(message)
|
||||
try ntfy.WaitForResponse()
|
||||
|
||||
try status := ntfy.ResponseText
|
||||
Return status
|
||||
}
|
132
Selenium-ChromeDriver-API.ahk
Normal file
132
Selenium-ChromeDriver-API.ahk
Normal file
@ -0,0 +1,132 @@
|
||||
; Notes/Extra Info/#Includes
|
||||
;------------------------------------------------
|
||||
|
||||
|
||||
|
||||
; Chrome Global Variables
|
||||
;------------------------------------------------
|
||||
; Chrome/Selenium
|
||||
global ChromeFilepath
|
||||
; Declare global variables here so they don't have to be declared in each script
|
||||
global ChromeTabsURLArray
|
||||
global DriverTitleArray
|
||||
global LastWebsitePostURL
|
||||
global CurrentTabURL
|
||||
global URLOfLastErrorPage
|
||||
|
||||
|
||||
|
||||
|
||||
; Chrome Related Functions
|
||||
;------------------------------------------------
|
||||
GetChromeFilepath(){
|
||||
; ChromeFilepath is global variable
|
||||
; Establish Variable with Filepath to be used throughout the script
|
||||
|
||||
if(ChromeFilepath = ""){
|
||||
|
||||
ChromePortableFilepath = %A_ScriptDir%\Lib\chrome-win64\chrome.exe
|
||||
|
||||
if(FileExist(ChromePortableFilepath)){
|
||||
ChromeFilepath := ChromePortableFilepath
|
||||
|
||||
Message = Using Chromium Portable for Upload
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
}
|
||||
else {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GetChromeVersion(){
|
||||
; https://stackoverflow.com/questions/52457766/how-can-i-get-google-chromes-version-number
|
||||
; Command = powershell `$ChromePath = 'C:\Program Files\Google\Chrome\Application\chrome.exe' `; [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ChromePath).ProductVersion
|
||||
|
||||
; command = powershell $(Get-Package -Name 'Google Chrome').Version
|
||||
; ChromeVersion := RunCMD(command)
|
||||
; ChromeVersion := StrSplit(ChromeVersion, "`r")[1] ; remove newline character if it exists
|
||||
|
||||
if(ChromeFilepath = ""){
|
||||
GetChromeFilepath()
|
||||
}
|
||||
|
||||
GetChromeVersionCommand = powershell (Get-Item '%ChromeFilepath%').VersionInfo.ProductVersion
|
||||
Chromeversion := RunCMD(GetChromeVersionCommand)
|
||||
ChromeVersion := StrReplace(ChromeVersion, "`r")[1] ; replace any newline characters that powershell returns
|
||||
return ChromeVersion
|
||||
}
|
||||
|
||||
|
||||
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 CurrentChromeStableVersion := parsed.channels.stable.version
|
||||
|
||||
if(CurrentChromeStableVersion = ""){
|
||||
return "Failed to parse json. "
|
||||
}
|
||||
|
||||
return CurrentChromeStableVersion
|
||||
}
|
||||
|
||||
|
||||
GetDownloadURLOfChromeAndDriver(ChromeVersion){
|
||||
; 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 %ChromeVersion% in the ChromeLabs Json"
|
||||
return Message
|
||||
}
|
||||
|
||||
if(ChromeVersion = 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.chromedriver[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
|
||||
}
|
Loading…
Reference in New Issue
Block a user