You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
social-media-poster/Modules/Post-To-Gab.ahk

121 lines
4.2 KiB
Plaintext

; -------------------------------Gab-------------------------------
PostToGab:
CurrentSite := "Gab"
SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
GabPostURL = https://gab.com/compose
URLAttempt := NavigateFromBaseURLTo(GabPostURL)
if(URLAttempt = "Failed")
Return
Status := CheckCurrentTabForCurrentSite()
if(Status){
Return
}
sleep, 1000
Message = Checking Login Status
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
; Message = Inputting Post
; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
SaveOrPostProgress(Message:="Checking Login Status",PostType:="Tooltip,ErrorLoggingTextFile")
; New post input box
Xpath = //div[@data-block='true']//div
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
SaveOrPostProgress(Message:="Login Expired",PostType:="Tooltip,ErrorLoggingTextFile")
driver.Get("https://gab.com/auth/sign_in") ;go to login page
driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding
if(AutoLogin){
SaveOrPostProgress(Message:="Checking if chrome input email address",PostType:="Tooltip,ErrorLoggingTextFile")
js = return document.querySelector("#user_email").value;
status := driver.executeScript(js)
if(StrLen(Status) > 0){
SaveOrPostProgress(Message:="Clicking Login Button",PostType:="Tooltip,ErrorLoggingTextFile")
js = document.querySelector("button[name='button']").click()
status := driver.executeScript(js)
return
}
}
else, {
SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
}
Message = Inputting Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
if(ImageAttachmentFilepath != ""){
; Click the upload image button
SaveOrPostProgress(Message:="Attaching Image First",PostType:="Tooltip,ErrorLoggingTextFile")
Xpath = //input[@type='file']
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath)
if(Status){
Message = Failed to attach Image
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
SaveOrPostProgress(Message:="Waiting 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile")
sleep, 10000
}
Xpath = //div[@data-block='true']//div
Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000)
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostTitleAndBody)
if(Status){
SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
; Click the final "post" button
SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile")
if (ConfirmBeforeSubmit && ConfirmBeforeSubmitMsgboxFunc() != true) {
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
SaveOrPostProgress(Message:=Message, PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
return
}
Xpath = //*[@id="gabsocial"]/div/div[2]/div[2]/main/div/div[3]/div/div
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000)
if(Status){
Message = Failed to Submit Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
Return
}
IniWrite, Successful, %StatusFileFilePath%, Status, Gab
AddToTotalPostsPostedCount()
SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
PauseBetweenPosts()
DevModeMsgBox("done!")
Message = Post Publish Successful
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return
; -------------------------------/Gab-------------------------------