Added a couple more error checks to Chrome Tab switching function
This commit is contained in:
@@ -40,7 +40,7 @@ global UpdateVersionNumber
|
|||||||
|
|
||||||
|
|
||||||
ScriptName = Freedomain Social Media Poster
|
ScriptName = Freedomain Social Media Poster
|
||||||
ScriptVersion = 2.75
|
ScriptVersion = 2.76
|
||||||
FullScriptName := ScriptName . " " . ScriptVersion
|
FullScriptName := ScriptName . " " . ScriptVersion
|
||||||
|
|
||||||
;---ToDo---
|
;---ToDo---
|
||||||
@@ -1561,6 +1561,8 @@ Return
|
|||||||
;---------------/Facebook----------------------------------
|
;---------------/Facebook----------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
|
||||||
; -------------------------------Parler-------------------------------
|
; -------------------------------Parler-------------------------------
|
||||||
PostToParler:
|
PostToParler:
|
||||||
@@ -1887,52 +1889,53 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
Return
|
Return
|
||||||
; -------------------------------/SubScribeStar-------------------------------
|
; -------------------------------/SubScribeStar-------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
|
||||||
|
; -------------------------------LinkedIn-------------------------------
|
||||||
|
PostToLinkedIN:
|
||||||
|
CurrentSite := "LinkedIn"
|
||||||
|
|
||||||
; -------------------------------LinkedIn-------------------------------
|
if(StrLen(PostTitleAndBody) > 1300){
|
||||||
PostToLinkedIN:
|
|
||||||
CurrentSite := "LinkedIn"
|
|
||||||
|
|
||||||
if(StrLen(PostTitleAndBody) > 1300){
|
|
||||||
Message = Post longer than LinkedIn's 1300 character limit. Posting Skipped.
|
Message = Post longer than LinkedIn's 1300 character limit. Posting Skipped.
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, LinkedIn
|
IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, LinkedIn
|
||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
URLAttempt := NavigateFromBaseURLTo("https://www.linkedin.com/login")
|
URLAttempt := NavigateFromBaseURLTo("https://www.linkedin.com/login")
|
||||||
if(URLAttempt = "Failed")
|
if(URLAttempt = "Failed")
|
||||||
|
Return
|
||||||
|
|
||||||
|
Status := CheckCurrentTabForCurrentSite()
|
||||||
|
if(Status){
|
||||||
Return
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
Status := CheckCurrentTabForCurrentSite()
|
Message = Checking Login Status
|
||||||
if(Status){
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
Return
|
|
||||||
}
|
|
||||||
|
|
||||||
Message = Checking Login Status
|
sleep, 1000
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
try CurrentTabURL := driver.Url
|
||||||
|
if(InStr(CurrentTabURL, "login")){
|
||||||
sleep, 1000
|
|
||||||
try CurrentTabURL := driver.Url
|
|
||||||
if(InStr(CurrentTabURL, "login")){
|
|
||||||
Message = Login Expired. Please log back in
|
Message = Login Expired. Please log back in
|
||||||
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
SaveDriverURLOFErrorPage()
|
SaveDriverURLOFErrorPage()
|
||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Message = Clicking "Start a Post" button
|
Message = Clicking "Start a Post" button
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
|
|
||||||
loop, 3 {
|
loop, 3 {
|
||||||
Xpath = (//span[normalize-space()='Start a post'])[1] ; start a post button
|
Xpath = (//span[normalize-space()='Start a post'])[1] ; start a post button
|
||||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||||
if(!Status)
|
if(!Status)
|
||||||
@@ -1974,15 +1977,15 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
Message = Failed to click into Create Post popup to input post
|
Message = Failed to click into Create Post popup to input post
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Status){
|
if(Status){
|
||||||
Message = Login Expired. Please log back in
|
Message = Login Expired. Please log back in
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ImageAttachmentFilepath != ""){
|
if(ImageAttachmentFilepath != ""){
|
||||||
; Click the upload image button
|
; Click the upload image button
|
||||||
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
@@ -2030,13 +2033,13 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
sleep, 5000
|
sleep, 5000
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Message = Inputting Post
|
Message = Inputting Post
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
; Input Post text contents
|
; Input Post text contents
|
||||||
loop, 3 {
|
loop, 3 {
|
||||||
Xpath = //div[@aria-label='Text editor for creating content'] ; Input text of post
|
Xpath = //div[@aria-label='Text editor for creating content'] ; Input text of post
|
||||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
|
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
|
||||||
if(Status){
|
if(Status){
|
||||||
@@ -2058,7 +2061,7 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
; Continue
|
; Continue
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if(!Status){ ; if BLANK
|
/* if(!Status){ ; if BLANK
|
||||||
Message = Post Failed: Failed to input Post for some reason
|
Message = Post Failed: Failed to input Post for some reason
|
||||||
@@ -2118,43 +2121,45 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
Return
|
Return
|
||||||
; -------------------------------/LinkedIn-------------------------------
|
; -------------------------------/LinkedIn-------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
|
||||||
; -------------------------------Minds-------------------------------
|
; -------------------------------Minds-------------------------------
|
||||||
PostToMinds:
|
PostToMinds:
|
||||||
CurrentSite := "Minds"
|
CurrentSite := "Minds"
|
||||||
|
|
||||||
|
|
||||||
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
|
|
||||||
URLAttempt := NavigateFromBaseURLTo("https://www.minds.com/newsfeed/subscriptions")
|
URLAttempt := NavigateFromBaseURLTo("https://www.minds.com/newsfeed/subscriptions")
|
||||||
if(URLAttempt = "Failed")
|
if(URLAttempt = "Failed")
|
||||||
|
Return
|
||||||
|
|
||||||
|
Status := CheckCurrentTabForCurrentSite()
|
||||||
|
if(Status){
|
||||||
Return
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
Status := CheckCurrentTabForCurrentSite()
|
sleep, 1000
|
||||||
if(Status){
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
|
|
||||||
sleep, 1000
|
try CurrentTabURL := driver.Url
|
||||||
|
; Msgbox % "CurrentTabURL: " CurrentTabURL
|
||||||
try CurrentTabURL := driver.Url
|
if(InStr(CurrentTabURL, "login")){
|
||||||
; Msgbox % "CurrentTabURL: " CurrentTabURL
|
|
||||||
if(InStr(CurrentTabURL, "login")){
|
|
||||||
Message = Login Cookies Expired. Trying to Re-Login
|
Message = Login Cookies Expired. Trying to Re-Login
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
sleep, 2000
|
sleep, 2000
|
||||||
Xpath = //div[contains(text(),'Login')]
|
Xpath = //div[contains(text(),'Login')]
|
||||||
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||||
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
|
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
|
||||||
}
|
}
|
||||||
|
|
||||||
Message = Clicking into Speak your mind.. Box
|
Message = Clicking into Speak your mind.. Box
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
|
|
||||||
loop, 3 {
|
loop, 3 {
|
||||||
if(A_index = 3){
|
if(A_index = 3){
|
||||||
SaveOrPostProgress(Message:="Failed to click into -speak your mind..- input box.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
SaveOrPostProgress(Message:="Failed to click into -speak your mind..- input box.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
SaveDriverURLOFErrorPage()
|
SaveDriverURLOFErrorPage()
|
||||||
@@ -2186,10 +2191,10 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
; Attach Image
|
; Attach Image
|
||||||
if(ImageAttachmentFilepath != ""){
|
if(ImageAttachmentFilepath != ""){
|
||||||
; Click the upload image button
|
; Click the upload image button
|
||||||
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
@@ -2261,13 +2266,14 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else, { ; otherwise, input just text
|
}
|
||||||
|
else, { ; otherwise, input just text
|
||||||
SaveOrPostProgress(Message:="Inputting Text Post",PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:="Inputting Text Post",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
; DevModeMsgBox("Inputting Text Post")
|
; DevModeMsgBox("Inputting Text Post")
|
||||||
Xpath = //textarea[@id='minds-m-composer__textarea--1003']
|
Xpath = //textarea[@id='minds-m-composer__textarea--1003']
|
||||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
|
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
|
||||||
|
|
||||||
DevModeMsgBox("done")
|
|
||||||
if(Status){
|
if(Status){
|
||||||
Message = Failed to post with Xpath, trying with ID
|
Message = Failed to post with Xpath, trying with ID
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
@@ -2288,13 +2294,13 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
sleep, 5000
|
sleep, 5000
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
; sleep, 2000
|
; sleep, 2000
|
||||||
SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile")
|
SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
|
|
||||||
loop, 3 {
|
loop, 3 {
|
||||||
if(A_index = 3){
|
if(A_index = 3){
|
||||||
SaveOrPostProgress(Message:="Failed to submit post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
SaveOrPostProgress(Message:="Failed to submit post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
SaveDriverURLOFErrorPage()
|
SaveDriverURLOFErrorPage()
|
||||||
@@ -2305,7 +2311,8 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
js = document.querySelector("button[class='m-button m-button--blue m-button--small m-button--dropdown'] span[class='ng-star-inserted']").click();
|
js = document.querySelector("button[class='m-button m-button--blue m-button--small m-button--dropdown'] span[class='ng-star-inserted']").click();
|
||||||
try status := driver.executeScript(js)
|
try status := driver.executeScript(js)
|
||||||
catch e {
|
catch e {
|
||||||
Msgbox % "status: " status
|
Message = Clicking submit button with JS resulted in status: %status%
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2323,7 +2330,7 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* if(!TestingMode){
|
/* if(!TestingMode){
|
||||||
@@ -2361,46 +2368,55 @@ if(ImageAttachmentFilepath != ""){
|
|||||||
Return
|
Return
|
||||||
; -------------------------------/Minds-------------------------------
|
; -------------------------------/Minds-------------------------------
|
||||||
|
|
||||||
; -------------------------------Locals-------------------------------
|
/*
|
||||||
PostToLocals:
|
*/
|
||||||
CurrentSite := "Locals"
|
|
||||||
; DevModeMsgBox("clik ok to continue")
|
|
||||||
; @todo: Add auto-login to locals
|
|
||||||
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
|
||||||
|
|
||||||
IniRead, LocalsURL, %SettingsIniFilepath%, %ScriptSettingsSection%, LocalsURL
|
; -------------------------------Locals-------------------------------
|
||||||
Message = LocalsURL from Ini File: %LocalsURL%
|
PostToLocals:
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
CurrentSite := "Locals"
|
||||||
|
; DevModeMsgBox("clik ok to continue")
|
||||||
|
; @todo: Add auto-login to locals
|
||||||
|
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
; LocalsURL := StrReplace(Localsurl, "/share/post", "")
|
IniRead, LocalsURL, %SettingsIniFilepath%, %ScriptSettingsSection%, LocalsURL, %A_Space%
|
||||||
; LocalsURL := Localsurl . "/login"
|
if(LocalsURL = ""){
|
||||||
; Message = Localsurl: %LocalsURL%
|
Message = Please add your Locals Profile URL to the settings.ini file under`n`n[General]`nLocalsURL=
|
||||||
; SaveOrPostProgress(Message:=Message,PostType:=",DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
|
||||||
Status := NavigateFromBaseURLTo(LocalsURL)
|
|
||||||
if(Status = "Failed")
|
|
||||||
Return
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
Status := CheckCurrentTabForCurrentSite()
|
; Message = LocalsURL from Ini File: %LocalsURL%
|
||||||
if(Status){
|
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
; LocalsURL := StrReplace(Localsurl, "/share/post", "")
|
||||||
|
; LocalsURL := Localsurl . "/login"
|
||||||
|
; Message = Localsurl: %LocalsURL%
|
||||||
|
; SaveOrPostProgress(Message:=Message,PostType:=",DiscordErrorLogging")
|
||||||
|
|
||||||
|
Status := NavigateFromBaseURLTo(LocalsURL)
|
||||||
|
if(Status = "Failed")
|
||||||
|
Return
|
||||||
|
|
||||||
|
Status := CheckCurrentTabForCurrentSite()
|
||||||
|
if(Status){
|
||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
sleep, 1000
|
sleep, 1000
|
||||||
|
|
||||||
Message = Checking Login Status
|
Message = Checking Login Status
|
||||||
|
|
||||||
try CurrentTabURL := driver.Url
|
try CurrentTabURL := driver.Url
|
||||||
if(InStr(CurrentTabURL, "/login") OR InStr(CurrentTabURL, "/register")){
|
if(InStr(CurrentTabURL, "/login") OR InStr(CurrentTabURL, "/register")){
|
||||||
Message = Login Expired. Please log back in
|
Message = Login Expired. Please log back in
|
||||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
SaveDriverURLOFErrorPage()
|
SaveDriverURLOFErrorPage()
|
||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
|
|
||||||
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
; Xpath = //textarea[@id='body']
|
; Xpath = //textarea[@id='body']
|
||||||
; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=2000)
|
; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=2000)
|
||||||
; if(Status){
|
; if(Status){
|
||||||
; Message = Trying to Log Back In
|
; Message = Trying to Log Back In
|
||||||
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user