diff --git a/Freedomain Social Media Poster.ahk b/Freedomain Social Media Poster.ahk index b4d36e5..9835c4d 100644 --- a/Freedomain Social Media Poster.ahk +++ b/Freedomain Social Media Poster.ahk @@ -42,7 +42,7 @@ global UpdateVersionNumber ScriptName = Freedomain Social Media Poster -ScriptVersion = 2.83 +ScriptVersion = 2.84 FullScriptName := ScriptName . " " . ScriptVersion ;---ToDo--- diff --git a/Modules/Post-To-Subscribestar.ahk b/Modules/Post-To-Subscribestar.ahk index b717811..cc05b6d 100644 --- a/Modules/Post-To-Subscribestar.ahk +++ b/Modules/Post-To-Subscribestar.ahk @@ -61,7 +61,29 @@ if(InStr(LoginStatus, "Log In")){ ; need to log in Message = Inputting Post SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -; Click on "Start your post by clicking here" +; click the "Create Post" button +js = document.querySelector("div[class='new_post'] div[class='flat_button for-new_post']").click(); ; Send content through javascript (Great for getting around emoji chrome limitaitons) +try, driver.executeScript(js) + +sleep, 1000 + + +; post button at bottom right corner +Selector = ".flat_button.for-post_form" + +; check if post button exists +js = return document.querySelector(%Selector%).innerText +try, Status := driver.executeScript(js) +if(!Status){ + Message = Post Failed. Failed to click on "Create Post" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + + +/*; Click on "Start your post by clicking here" Xpath = //div[contains(text(),'Create Post')] Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) if(Status){ @@ -84,6 +106,7 @@ if(Status){ } } } +*/ ; sleep, 5000 ; msgbox @@ -102,33 +125,31 @@ if(Status){ ; Input Text into pop-up edit box SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") -Xpath = //trix-editor[@role='textbox'] -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody) -if(Status){ - Message = Failed to Input Post using Direct Xpath. Trying with Relative - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - Xpath = /html/body/div/div[3]/div[2]/div[2]/div/div[1]/form/div[2]/div[1]/trix-editor - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody) - if(Status){ - Message = Failed to Input Post using Relative Xpath. Trying with Javascript - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - +SubscribeStarJSDescription := FormatTextToJSText(PostTitleAndBody) +js = document.querySelector("trix-editor[role='textbox']").value = "%SubscribeStarJSDescription%"; +try driver.executeScript(js) ;Executes a Javascript on the webpage, mostly used for buttons. +catch e { + Message = Failed to Input Post Contents (E#8281) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} - SubscribeStarJSDescription := FormatTextToJSText(PostTitleAndBody) - js = document.querySelector("trix-editor[role='textbox']").value = "%SubscribeStarJSDescription%"; - try driver.executeScript(js) ;Executes a Javascript on the webpage, mostly used for buttons. - catch e { - Message = Failed to Input Post Contents (E#8281) - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - ; msgbox, 3 - } +; check if value was input +js = return document.querySelector("trix-editor[role='textbox']").innerText +try, Status := driver.executeScript(js) +if(!Status){ + Message = Failed to input Post Content (E#8282) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} +else, { ; if input successfully, post to error log + String := SubStr(Status, 1, 30) + Message = Post Content that got input: %String% ... + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +} -} ; Attach an image if a filepath was provided if(ImageAttachmentFilepath != ""){ @@ -163,7 +184,42 @@ if(ImageAttachmentFilepath != ""){ ; Click the post Button SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") - Xpath = //button[contains(text(),'Post')] + + ; post button at bottom right corner + Selector = ".flat_button.for-post_form" + + ; check if post button exists + js = return document.querySelector(%Selector%).innerText + try, Status := driver.executeScript(js) + if(!Status){ + Message = Post Failed. Unable to find Post button using usual method. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; Msgbox % "Status: " Status + + js = document.querySelector(%Selector%).click() + try, Status := driver.executeScript(js) + ; Msgbox % "Status: " Status + + sleep, 2000 + + ; check if post button still exists + js = return document.querySelector(%Selector%).innerText + try, Status := driver.executeScript(js) + if(Status){ + Message = Post Failed. Failed to click Post button using usual method. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + + +/* Xpath = //button[contains(text(),'Post')] Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) if(Status){ Message = Failed to Submit Post @@ -172,6 +228,7 @@ if(ImageAttachmentFilepath != ""){ Return } + */ IniWrite, Successful, %StatusFileFilePath%, Status, SubScribeStar AddToTotalPostsPostedCount()