; -------------------------------SubScribeStar------------------------------- PostToSubscribeStar: CurrentSite := "SubScribeStar" IniRead, SubscribeStarProfileURL, %SettingsIniFilepath%, SocialMediaPoster, SubscribeStarProfileURL, %A_Space% if(SubscribeStarProfileURL = ""){ Message = SubscribeStarProfileURL is blank. Please update Settings.ini SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Return } SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") Status := NavigateFromBaseURLTo(SubscribeStarProfileURL) if(Status){ Message = Failed to Navigate to SubScribeStar Page SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") } Status := CheckCurrentTabForCurrentSite() if(Status){ Return } Message = Checking Login Status SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") ; check for Log In button text js = return document.querySelector(".top_bar-login.is-button").innerText; try LoginStatus := driver.executeScript(js) if(InStr(LoginStatus, "Log In")){ ; need to log in SaveOrPostProgress(Message:="Navigating to login page",PostType:="Tooltip,ErrorLoggingTextFile") try driver.Get("https://www.subscribestar.com/login") ; navigate to login page try driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding if(AutoLogin){ ; Check if email box contains text inputted by chrome js = return document.querySelector("input[placeholder='your email']").value; status := driver.executeScript(js) if(StrLen(Status) > 0){ ; click enter on the email input field Xpath = //input[@placeholder='your email'] driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.ENTER) driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding } } 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") ; 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){ Message = Failed to Click "Create Post" button with relative xpath SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") Xpath = //div[@class='new_post']//div[@class='new_post-create_button'] Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) if(Status){ Message = Failed to click "Create Post" button with Contains(Text) xpath and relative Xpath - Trying wtih ID SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") Status := Selenium_LoopToClickID(IDName:="cover_upload",NumOfLoops:=5,SleepLength:=1000) if(Status){ Message = Login Expired. Please log back in SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } } } ; sleep, 5000 ; msgbox ; Clear any previous content from the post box Message = Clearing if any text exists from an unposted post SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //trix-editor[@role='textbox'] Status := Selenium_LoopToClearXpath(Xpath,NumOfLoops:=5,SleepLength:=1000) if(Status){ } ; try driver.FindElementByXPath(Xpath).clear() ;Clears content from an element and sets ; 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 } ; msgbox, 3 } } ; Attach an image if a filepath was provided if(ImageAttachmentFilepath != ""){ SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") ; this works for both images and videos Xpath = //input[@multiple='multiple'] driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) /* Xpath = //span[@class='trix-button-group trix-upload-buttons']//button[2] Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) if(Status){ Message = Failed to click on Picture Upload button SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") } InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) if(InputStatus = "Failed") { Message = Upload Failed:`nUnable to Find "Open File" window to input filepath into SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging") Return } */ SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") sleep, 5000 } ; Click the post Button SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") Xpath = //button[contains(text(),'Post')] Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) if(Status){ Message = Failed to Submit Post SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveDriverURLOFErrorPage() Return } IniWrite, Successful, %StatusFileFilePath%, Status, SubScribeStar AddToTotalPostsPostedCount() PauseBetweenPosts() Message = Post Publish Successful SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") Return ; -------------------------------/SubScribeStar-------------------------------