replaced Shared Functions and Automation Functions files with Freedomain-Posters-Shared-Functions submodule

main
Yuriy 2 years ago
parent ad4565bdc7
commit bcb74a71cb

@ -30,9 +30,10 @@ global UpdateVersionNumber
;---Notes/Extra Info/#Includes------------------------------------------------------
#Include %A_ScriptDir%\Lib\SharedFunctions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Freedomain-Posters-Shared-Functions.ahk
; #Include %A_ScriptDir%\Lib\SharedFunctions.ahk
#Include %A_ScriptDir%\Lib\Json.ahk
#Include %A_ScriptDir%\Lib\ChromeAutomationFunctions.ahk
; #Include %A_ScriptDir%\Lib\ChromeAutomationFunctions.ahk
#Include %A_ScriptDir%\Lib\RunCMD.ahk
@ -874,8 +875,8 @@ Gosub, PostToFacebook
*/
if(Steemit)
Gosub, PostToSteemit
if(Pintrest)
Gosub, PostToPintrest
; if(Pintrest)Z
; Gosub, PostToPintrest
if(Pocketnet)
Gosub, PostToPocketNet
if(Gettr)
@ -899,7 +900,7 @@ if(URLOfLastErrorPage != ""){
; DevModeMsgBox("pause")
; message = URLOfLastErrorPage: %URLOfLastErrorPage%
; DevModeMsgBox(URLOfLastErrorPage)
FindAndActivateTab(URLOfLastErrorPage)
; FindAndActivateTab(URLOfLastErrorPage)
}
@ -1028,7 +1029,7 @@ Return
ActivateParlerTab:
DevModeMsgBox("activating")
DevModeMsgBox(ParlerTabURL)
FindAndActivateTab(ParlerTabURL)
; FindAndActivateTab(ParlerTabURL)
Return
@ -1137,7 +1138,7 @@ if(Status){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
}
Status := CheckCurrentTabForCurrentSite()
; Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}

@ -1,216 +0,0 @@
; Various functions used to control Selenium, Chrome and Chrome.AHK
;---Javascript---
;------------------------------------------------
JS_TryToExecute(JsToExecute,NumberofAttempts := 1,SleepLength:=1000){
loop, %NumberofAttempts% {
try driver.executeScript(JsToExecute)
catch e {
Continue
}
Return
}
Return "Failed"
}
; ValueToCheckOptions = innertext,textContent,InnerHTML,outerHTML,value,href,option value
js_SendAndCheckWithClassName(ClassName:="",ClassIndexNum:=0,ValueToCheck:="textContent",SleepLength:=1000,JSStringText:="TEXT"){
jsSend = document.getElementsByClassName('%ClassName%')[%ClassIndexNum%].value = "%JSStringText%";
try driver.executeScript(jsSend)
sleep, %SleepLength%
jsCheck = return document.getElementsByClassName('%ClassName%')[%ClassIndexNum%].%ValueToCheck%;
try Status := driver.executeScript(jsCheck)
; Msgbox % "Status: " Status
if(Status = "")
return "Failed"
else,
return ""
}
; ValueToCheckOptions = innertext,textContent,InnerHTML,outerHTML,value,href,option value
js_SendAndCheckWithNAME(Element:="",IndexNum:=0,ValueToCheck:="textContent",SleepLength:=1000,JSStringText:=""){
jsSend = document.getElementsByName('%Element%')[%IndexNum%].value = "%JSStringText%";
/*Clipboard := jsSend
Msgbox % "jsSend: " jsSend
*/
; document.getElementsByClassName('%ClassName%')[%ClassIndexNum%].value = "%JSStringText%";
try driver.executeScript(jsSend)
sleep, %SleepLength%
jsCheck = return document.getElementsByName('%Element%')[%IndexNum%].%ValueToCheck%;
; Clipboard := jscheck
; Msgbox % "jsCheck: " jsCheck
try Status := driver.executeScript(jsCheck)
; Msgbox % "Status: " Status
if(Status = "")
return "Failed"
else,
return ""
}
; ValueToCheckOptions = innertext,textContent,InnerHTML,outerHTML,value,href,option value
js_SendAndCheckWithID(Element:="",ValueToCheck:="textContent",SleepLength:=1000,JSStringText:=""){
; Msgbox % "Element: " Element
; Msgbox % "JSStringText: " JSStringText
jsSend = document.getElementById('%Element%').value = "%JSStringText%";
; Clipboard := jsSend
; Msgbox % "jsSend: " jsSend
try driver.executeScript(jsSend)
; Msgbox % "JSStringText: " JSStringText
sleep, %SleepLength%
jsCheck = return document.getElementById('%Element%').%ValueToCheck%;
try Status := driver.executeScript(jsCheck)
if(Status = "")
return "Failed"
else,
return ""
}
;---\Javascript---
;------------------------------------------------
;---Selenium---
;------------------------------------------------
; When called these will try multiple times to click/input into a web element
Selenium_LoopToClickID(IDName,NumOfLoops:=1,SleepLength:=1000){
loop, %NumOfLoops% {
try driver.findElementsByID(IDName).item[1].click() ; Click on "upload image" button
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
sleep, %SleepLength%
Continue
}
Return
}
}
Selenium_LoopToClickName(ElementName,NumOfLoops:=1,SleepLength:=1000){
loop, %NumOfLoops% {
try driver.findElementsByName(ElementName).item[1].click()
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
sleep, %SleepLength%
Continue
}
Return
}
}
Selenium_LoopToSendValueToID(IDName,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=""){
loop, %NumOfLoops% {
try driver.findElementsByID(IDName).item[1].sendKeys(StringTextContent) ; Click on "upload image" button
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
sleep, %SleepLength%
Continue
}
Return
}
}
; Selenium_LoopToSendValueByName(ElementName:="NAME",NumOfLoops:=2,SleepLength:=1000,StringTextContent:="TEXT")
Selenium_LoopToSendValueByName(ElementName,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=""){
loop, %NumOfLoops% {
try driver.findElementsByName(ElementName).item[1].SendKeys(StringTextContent)
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
sleep, %SleepLength%
Continue
}
Return
}
}
Selenium_LoopToSendValueToXpath(Xpath,NumOfLoops:=1,SleepLength:=1000,StringTextContent:=""){
loop, %NumOfLoops% {
; ToolTip, Loop attempt: %A_index%
try driver.FindElementByXPath(Xpath).sendKeys(StringTextContent) ; Click on "upload image" button
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
sleep, %SleepLength%
Continue
}
Return
}
}
Selenium_LoopToClickXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){
loop, %NumOfLoops% {
try driver.FindElementByXPath(Xpath).click()
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
sleep, %SleepLength%
Continue
}
Return
}
}
Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath,NumOfLoops:=1,SleepLength:=1000,WindowName:="Open"){
loop, %NumOfLoops% {
; TooltipThis("Clicking xpath")
try driver.FindElementByXPath(Xpath).click()
catch e {
if(A_index = NumOfLoops){
Return "Failed to Click Xpath or Open File window did not show up on click"
}
sleep, %SleepLength%
Continue
}
; tooltipthis("Checking if window exists")
sleep, 1000
; Msgbox % "WindowName: " WindowName
if(!WinExist(WindowName)){
Message = %WindowName% not found on %A_index% attempt.
; tooltipthis("Window not found")
sleep, %SleepLength%
Continue
}
Return
}
}
Selenium_LoopToClearXpath(Xpath,NumOfLoops:=1,SleepLength:=1000){
loop, %NumOfLoops% {
try driver.FindElementByXPath(Xpath).clear()
catch e {
if(A_index = NumOfLoops){
Return "Failed"
}
sleep, %SleepLength%
Continue
}
Return
}
}
;---\Selenium---
;------------------------------------------------

@ -1 +1 @@
Subproject commit 694c440a6a89b0b84fee0c49370d95150667c7a9
Subproject commit 6f3065c5f3cb449d98fbf4084543cc2d4fd63c63

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save