diff --git a/Freedomain Social Media Poster.ahk b/Freedomain Social Media Poster.ahk index 4c7d652..2026f28 100644 --- a/Freedomain Social Media Poster.ahk +++ b/Freedomain Social Media Poster.ahk @@ -41,7 +41,7 @@ global UpdateVersionNumber ScriptName = Freedomain Social Media Poster -ScriptVersion = 2.82 +ScriptVersion = 2.80 FullScriptName := ScriptName . " " . ScriptVersion ;---ToDo--- @@ -171,21 +171,9 @@ if(PauseBetweenPosts){ IniRead, TotalPostsPosted, %SettingsIniFilepath%, %ScriptSettingsSection%, TotalPostsPosted,0 IniRead, TotalRunTime, %SettingsIniFilepath%, %ScriptSettingsSection%, TotalRunTime, 0 + ;---Auto Updater Settings--- ;------------------------------------------------ -; Misc Auto Update settings -/*global FreedomainProgramUpdaterFilepath -FreedomainProgramUpdaterFilepath := A_ScriptDir . "\Freedomain Program Updater.exe" - -global FreedomainProgramUpdaterURL -FreedomainProgramUpdaterURL = https://freedomainplaylists.com/wp-content/FreedomainScripts/Freedomain`%20Program`%20Updater.exe - -global FreedomScriptsChangelogURL -FreedomScriptsChangelogURL = https://freedomainplaylists.com/wp-content/FreedomainScripts/FreedomScriptsChangelogINI - -global UpdateURL -UpdateURL = https://freedomainplaylists.com/wp-content/FreedomainScripts/Freedomain`%20Social`%20Media`%20Poster.exe -*/ global GitReleasesAPIURL GitReleasesAPIURL =https://git.freedomainplaylists.com/api/v1/repos/yuriy/Freedomain-Social-Media-Poster/releases @@ -334,20 +322,7 @@ if(TestingMode){ ; Easy testing for Yuriy MeWeCheckStatus := 0 TwetchCheckStatus := 0 ThinkSpotCheckStatus := 0 - ; FloteCheckStatus := 0 - ; PintrestCheckStatus := 0 - ; ParlerCheckStatus := 0 PocketNetCheckStatus := 0 - ; TumblrCheckStatus := 0 - ; PocketNetCheckStatus := 0 - -} - - - -; check for updates if the setting is enabled -if(AutoUpdateCheck AND !SkipUpdateCheckThisRun){ - CheckForUpdates(GitReleasesAPIURL) } @@ -441,13 +416,20 @@ Gui, Font, Normal Gui, Add, Button,xp+%Marginspace% yp+35 w%EditBoxThirdsWidth% h30 gSaveAsTemplate, Save As Template Gui, Add, Button,x+%MarginSpace% w%EditBoxThirdsWidth% h30 gLoadTemplate, Load Template Gui, Add, Button, x+%MarginSpace% w%EditBoxThirdsWidth% h30 gLoadLastPost, Load Last Post + if(UpdateAvailable) Gui, Add, Button, x%MarginSpaceDoubled% y+%MarginSpace% w%EditBoxHalfWidths% h30 gUpdateScript vUpdateAvailable, Update Available: %UpdateVersionNumber% else, -Gui, Add, Button, x%MarginSpaceDoubled% y+%MarginSpace% w%EditBoxHalfWidths% h30 gUpdateScript vUpdateAvailable, Up-to-Date +Gui, Add, Button, x%MarginSpaceDoubled% y+%MarginSpace% w%EditBoxHalfWidths% h30 gUpdateScript vUpdateAvailable, Poster Up-to-Date + + + +if(ChromeUpdateAvailable) +Gui, Add, Button,x+%MarginSpace% yp+0 w%EditBoxHalfWidths% h30 gCancelPost, Chrome Update Available +else, +Gui, Add, Button,x+%MarginSpace% yp+0 w%EditBoxHalfWidths% h30 gCancelPost, Chrome Up-to-Date -Gui, Add, Button,x+%MarginSpace% yp+0 w%EditBoxHalfWidths% h30 gCancelPost, Close Window if(DevMode){ Gui, Add, Button, x%MarginSpace% y+10 w%EditBoxThirdsWidth% h30 gToggleTestingMode, TestingModeToggle ; Gui, Add, Button, x+%marginspace% w%EditBoxThirdsWidth% h30 gToggleTestingMode, TestingModeToggle @@ -496,7 +478,7 @@ Gui, Font, s%GUINormalFontSize% Gui, Font, Bold -Gui, Add, GroupBox,r7 x%PlatformsGroupBoxXLocation% y185 w300, Platforms +Gui, Add, GroupBox,r6.4 x%PlatformsGroupBoxXLocation% y185 w300, Platforms Gui, Font, Normal Gui, Add, Checkbox, xp+10 yp+30 vDiscord Checked%DiscordCheckStatus% gUpdateVars, Discord Gui, Add, Checkbox, y+7 vTelegram Checked%TelegramCheckStatus% gUpdateVars, Telegram @@ -526,12 +508,12 @@ Gui, Font, Bold gui, Font, s15 ; : Gui, Add, Text, , My Text. ; Gui, Font, Color, Red -Gui, Add, Button, x%PlatformsGroupBoxXLocation% y+90 w300 h110 gPostPost, Publish +Gui, Add, Button, x%PlatformsGroupBoxXLocation% y+57 w300 h117 gPostPost, Publish ; Gui, Add, Button, x%PlatformsGroupBoxXLocation% y+20 w300 h30 gSchedulePost, Schedule Post -; Gui, Font, s%GUINormalFontSize% +; Gui, Font, s%GUINormalFontSize%g gui, font, s6 gui, font, normal Gui, Add, StatusBar,, Total Posts Posted: %TotalPostsPosted% | Total Run Time: %TotalRunTime% Seconds | @@ -540,6 +522,15 @@ Gui, Add, StatusBar,, Total Posts Posted: %TotalPostsPosted% | Total Run Time: % Gui, Show,,%FullScriptName% ; , w%GuiWidth%, %ScriptName% ControlFocus, Edit1, %FullScriptName% + +; check for updates if the setting is enabled +if(AutoUpdateCheck AND !SkipUpdateCheckThisRun){ + CheckForUpdates(GitReleasesAPIURL) + GuiControl,,UpdateAvailable, Uploader Update Available + +} + + ;---Check for Update--- ;------------------------------------------------ Return @@ -860,44 +851,42 @@ StartTime := A_TickCount if(Discord) Gosub, PostToDiscord + if(Telegram) Gosub, PostToTelegram -; if(Parler) -; Gosub, PostToParler + if(SubscribeStar) Gosub, PostToSubscribeStar + if(Minds) Gosub, PostToMinds + if(Gab) Gosub, PostToGab + if(LinkedIN) Gosub, PostToLinkedIN + if(MeWe) Gosub, PostToMeWe + if(Twetch) Gosub, PostToTwetch + if(Thinkspot) Gosub, PostToThinkSpot -; if(Flote) -; Gosub, PostToFlote + if(Locals) Gosub, PostToLocals -/*if(Parler) -Gosub, PostToParler -if(Facebook) -Gosub, PostToFacebook -*/ + if(Steemit) Gosub, PostToSteemit -; if(Pintrest)Z -; Gosub, PostToPintrest + if(Pocketnet) Gosub, PostToPocketNet + if(Gettr) Gosub, PostToGettr -; if(Tumblr) -; Gosub, PostToTumblr - CurrentSite := Message = Social Media Posting Complete @@ -1123,2866 +1112,59 @@ OpenScreenshotsFolder: run, %ErrorLoggingDirectory% Return -/* -PostScreenshotsToUploadStatus: -SaveOrPostProgress(Message:="Uploading screenshots of Errors:",PostType:=",ErrorLoggingTextFile,DiscordParler") - - -Loop, %NumOfScreenshots% { - Filepath := ScreenshotFilepaths[A_index] ; find value from position in array - UploadImageToDiscord(DiscordParlerWebhookURL,, Filepath) - -} - -Tooltip -Return - -*/ - - - - -; -------------------------------Discord------------------------------- -PostToDiscord: -CurrentSite := "Discord" - -; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile") -Message = Posting Through API -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -if(DiscordParlerWebhookURL = ""){ - Message = Webhook Link not found. Please set "DiscordParlerWebhookURL" in %SettingsIniFilepath%. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - - -if(BoldTitleWAPI){ - if(NewLineBetweenTitle) - Message = **%PostTitle%**`n`n%PostBody% - else, - Message = **%PostTitle%**`n%PostBody% -} -else, { ; NOT bold title - if(NewLineBetweenTitle) - Message = %PostTitle%`n`n%PostBody% - else, - Message = %PostTitle%`n%PostBody% -} - - - -if(ImageAttachmentFilepath != ""){ - SingleQuotationMark = " - ; remove any single quotes from filepath - ImageAttachmentFilepath := StrReplace(ImageAttachmentFilepath, SingleQuotationMark, "") - - if(StrLen(Message) > 1999){ ; split message into two parts if longer than this - loop % StrLen(Message) { - - if(A_index < 1900) - Continue - - SplitCharNumber := A_index - ; IndexMinusOne := A_index - 1 - - SplitLocationText := SubStr(Message, SplitCharNumber, 1) - if(SplitLocationText = " "){ - Break - ; Msgbox % "SplitLocation: " SplitLocation - } - } - - - - DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber) - SplitCharNumber := SplitCharNumber + 1 - DiscordMessagePartTwo := SubStr(Message, SplitCharNumber) - ; Msgbox % "DiscordMessagePartOne: " DiscordMessagePartOne - ; Msgbox % "DiscordMessagePartTwo: " DiscordMessagePartTwo - - Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler") - Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler") - Status := UploadImageToDiscord(DiscordParlerWebhookURL, "", ImageAttachmentFilepath) - - ; Msgbox % "StatusOne: " StatusOne - ; Msgbox % "StatusTwo: " StatusTwo - -/* if(!InStr(StatusOne, "id")){ ; if error for each of the messages, post its - parsed := JSON.Load(StatusOne) - StatusOneFailure := parsed.content[1] - - parsed := JSON.Load(StatusTwo) - StatusTwoFailure := parsed.content[1] - - Message = Partial Failure for the following reason: %StatusOneFailure% OR %StatusTwoFailure% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - } - */ - } ; end of strlen > 1999 - else, { - Status := UploadImageToDiscord(DiscordParlerWebhookURL, Message, ImageAttachmentFilepath) - SaveOrPostProgress(Message:="Status",PostType:="ErrorLoggingTextFile") - - if(!InStr(Status, "id")){ - parsed := JSON.Load(Status) - Error := parsed.content[1] - ; Msgbox % "error: " error - Message = Discord Post Failed due to API Issue. Error was saved to errorlog; please forward to Yuriy - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - } - } - else { - if(StrLen(Message) > 1999){ ; split message into two parts if longer than this - loop % StrLen(Message) { - - if(A_index < 1900) - Continue - - SplitCharNumber := A_index - - SplitLocationText := SubStr(Message, SplitCharNumber, 1) - if(SplitLocationText = " "){ - Break - } - } - - DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber) - SplitCharNumber := SplitCharNumber + 1 - DiscordMessagePartTwo := SubStr(Message, SplitCharNumber) - - Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler") - Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler") - } - else, - SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordParler") - } - - IniWrite, Successful, %StatusFileFilePath%, Status, Discord - AddToTotalPostsPostedCount() - - Message = Post Publish Successful - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - - Return - ; -------------------------------/Discord------------------------------- - -/* -*/ - -; -------------------------------Telegram------------------------------- -; API documentation -; https://core.telegram.org/bots/api#sendmessage -PostToTelegram: -CurrentSite := "Telegram" - -; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile") -Message = Posting Through API -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -if(TelegramBotToken = "" Or TelegramBotChatID =""){ - Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - ; Msgbox, 4096, Error!, TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script. - Return -} - - -LineBreakChar = `%0A ; Used for API - - -TelegramTitle := ASCIISTRReplace(PostTitle) -TelegramBody := ASCIISTRReplace(PostBody) - - -/* TelegramTitle := PostTitle - TelegramBody := PostBody - - */ - - ; Msgbox % "TelegramBody: " TelegramBody - - if(PostBody = ""){ - if(BoldTitleWAPI) - Message := "*" . TelegramTitle . "*" - else, - Message := TelegramTitle - } - else, { ; if postbody is not blank - ; MsgBox, we in post body - if(BoldTitleWAPI){ - if(NewLineBetweenTitle) - Message := "*" . TelegramTitle . "*" . "`n`n" . TelegramBody - else, - Message := "*" . TelegramTitle . "*" . "`n" . TelegramBody - } - else, { ; NOT Bold Title - if(NewLineBetweenTitle) - Message := TelegramTitle . "`n`n" . TelegramBody - else, - Message := TelegramTitle . "`n" . TelegramBody - - } - } - - ; Msgbox % "Message: " Message - ; REMOVE - ; Message := PostTitle . "`n" . PostBody - - ; Msgbox % "TelegramTitle: " TelegramTitle - ; Msgbox % "TelegramBody: " TelegramBody - - ; Msgbox % "Message: " Message - - - if(ImageAttachmentFilepath != "" AND StrLen(Message) > 1020){ ; utilize function that converts image to MIME/multi form - ; Telegram API character limit of 4096 for a basic message. - ; @todo: add functionality to split messages longer than 4096 characters - ; msgbox, 2 - - if(BoldTitleWAPI) - TelegramTitle := "*" . TelegramTitle . "*" - else, - TelegramTitle := TelegramTitle - - Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := TelegramTitle ) ; you could add more options; compare the Telegram API docs - Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBody ) - } - else if(ImageAttachmentFilepath != "" AND StrLen(Message) <= 1020){ - Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := Message ) ; you could add more options; compare the Telegram API docs - - } - else, - { ; send just the text - ; Msgbox % "Message: " Message - Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Message ) - } - - if(Status){ - Message = Upload Failed due to API issue. Telegram API Returned Value:`n %Status% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordParler") - IniWrite, Successful, %StatusFileFilePath%, Status, Telegram - AddToTotalPostsPostedCount() - - Message = Post Publish Successful - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - - Return - ; -------------------------------/Telegram------------------------------- - -/* -*/ - - -;---------------Facebook---------------------------------- -PostToFacebook: -CurrentSite := "Facebook" - -Message = Navigating to Post Creation Page -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -Status := NavigateFromBaseURLTo("https://www.facebook.com/") -if(Status){ - Message = Failed to Navigate to Feed Page - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -} - -; Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} - -sleep, 2000 -js = document.querySelector("div[class='m9osqain a5q79mjw gy2v8mqq jm1wdb64 k4urcfbm qv66sw1b'] span[class='a8c37x1j ni8dbmo4 stjgntxs l9j0dhe7']").click() - -; js = document.querySelector('a[aria-label$="Timeline"] + div > div:nth-child(1)').click() -try driver.executeScript(js) - -IniWrite, Incomplete, %StatusFileFilePath%, Status, Facebook -try Clipboard := PostTitleAndBody -SaveDriverURLOFErrorPage() - -Return - - - - - - - -; try html := driver.pagesource ; save page's entire HTML to a variable -; Clipboard := html -; Msgbox % "html: " html - -; Pull out greeting message -/*GreetingMessage := StrSplit(HTML, "What's on your mind,") -GreetingMessage := GreetingMessage[2] -GreetingMessage := StrSplit(GreetingMessage, "") -GreetingMessage := GreetingMessage[1] -GreetingMessage := "What's on your mind," . GreetingMessage -*/ -; Msgbox % "GreetingMessage: " GreetingMessage - -; //span[normalize-space()="What's on your mind, Yuriy?"] -; - -Message = Inputting Post -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -; Msgbox % "Status: " Status -if(ImageAttachmentFilepath = "" AND Status){ ; upload a temporary file and then remove it and input psot - Message = Inputting post using temporary image attachment workaround - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - - Xpath = //div[@aria-label='Create a post']//div//input[@type='file'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=TemporaryImageFilepath) - if(Status){ - Message = Post Failed: Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - ; driver.FindElementByXPath(Xpath).SendKeys(TemporaryImageFilepath) - - sleep, 2000 - ; remove attachment - Xpath = //div[@aria-label='Remove post attachment'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=3000) - if(Status){ - Message = Upload Failed: Failed to remove temporary image. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - ; driver.FindElementByXPath(Xpath).click() - - - Xpath = //span[normalize-space()="What's on your mind, Stefan?"] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Failed to click with Relative Xpath - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - ; click on "what's on your mind text box" - Xpath = //div[@aria-label='Create a post']//div[1]//div[1]//div[1]//span[1] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Failed to click "What's on your mind" box to input post with relative and direct xpath - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Return - } - } - -} -if(ImageAttachmentFilepath != "") { ; otherwise send image straight to upload input box. The post box will open up automatically - Message = Attaching Image - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - - Xpath = //div[@aria-label='Create a post']//div//input[@type='file'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) - if(Status){ - Message = Post Failed: Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } -/* ; Attach image button - Xpath = //div[@aria-label='Photo/Video']//div//div//div//div//div//i[@data-visualcompletion='css-img'] - Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) - if(Status){ - Message = Failed to click "Attach Image" button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - ; Input filepath of image/video - Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) - if(Status) - { - Message = Upload Failed: Unable to Find "Open File" window to input Video filepath into - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - */ - - Message = Waiting 5 Seconds For Thumbnail Preview to Load - SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - ; Wait for thumbnail to load - sleep, 5000 - -} - -Message = Posting Exited Early for Testing -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") -Return - -; Xpath = //div[@data-block='true']//div -Xpath = //div[@data-block='true']//div -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) -if(Status){ - Message = Failed to input Text Post message with Relative and direct Xpath - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - - - -IniWrite, Input - NOT Submitted, %StatusFileFilePath%, Status, Facebook -Message = Post Button Click Skipped. Please Double Check and Submit Post Manually -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar") -SaveDriverURLOFErrorPage() -Return - - - -Message = Submitting Post -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - -; Click Post Button -xpath = //div[@aria-label='Post']//div//div//div//span[contains(text(),'Post')] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) -if(Status){ - Message = Failed to click "Post" button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - -IniWrite, Successful, %StatusFileFilePath%, Status, Facebook -AddToTotalPostsPostedCount() - -Message = Post Publish Successful -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -PauseBetweenPosts() -DevModeMsgBox("done!") - -Return -;---------------/Facebook---------------------------------- - - -/* -*/ - -; -------------------------------Parler------------------------------- -PostToParler: -CurrentSite := "Parler" - -Message = Navigating to Post Creation Page -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - -Status := NavigateFromBaseURLTo("https://parler.com") -if(Status){ - Message = Failed to Navigate to Feed Page - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -} - -Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} - -; Check login status by checking the header of the page for "Feed" text -loop, 5 { - SaveOrPostProgress(Message:="Checking Login Status",PostType:="Tooltip,ErrorLoggingTextFile") - js = return document.querySelector(".header__contain").innerText - try status := driver.executeScript(js) - - if(Status) - continue - - sleep, 1000 -} - -; DevModeMsgBox(status) -; Msgbox % "status: " status -if(!InStr(status, "Feed")){ - ; SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - ; ParlerTabURL := - try ParlerTabURL := driver.URL - SaveDriverURLOFErrorPage() - Return -} - - - -Message = Inputting Post -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -/* ; click into popup box - xpath = //div[@placeholder='Parley...'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=3,SleepLength:=1000) - if(Status){ - Message = Failed to click into Parler Post Box. Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - */ - - ; Input post contents - Xpath = //textarea[@placeholder='Write something...'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) - if(Status){ - Message = Failed to input post contents - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - +; Discord +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Discord.ahk - ; Do a double check that post got input - - ; js = return document.querySelector("textarea[placeholder='Write something...']").textContent; - ; try ParlerTextStatus := driver.executeScript(js) ;navigate using javascript - - Xpath = //textarea[@placeholder='Write something...'] - try ParlerTextStatus := driver.findelementbyxpath(Xpath).Attribute("value") ;XPath: ID=site-title & span tag - +; Telegram +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Telegram.ahk - if(StrLen(ParlerTextStatus) < 5){ - Message = Failed to input post contents. Post that got input: %ParlerTextStatus% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } +; Subscribestar +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Subscribestar.ahk - if(ImageAttachmentFilepath != ""){ - Message = Attaching Image - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") +; LinkedIn +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-LinkedIn.ahk - Xpath = //input[@type='file'] - try driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) - catch e { - Message = Failed to Attach Image - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - Message = Waiting 5 seconds for image to upload - SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - sleep, 5000 - } - else, { - SaveOrPostProgress(Message:="Waiting 2 seconds for Everything to Finish Loading",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 2000 - } +; Minds +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Minds.ahk - ; SaveOrPostProgress(Message:="Waiting 2 seconds for Everything to Finish Loading",PostType:="Tooltip,ErrorLoggingTextFile") - ; sleep, 2000 +; Locals +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Locals.ahk +; Bastyon +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Bastyon.ahk - ; sleep, 5000 - Xpath = //button[normalize-space()='Parley'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Failed to Submit Post (#4064) - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } +; Steemit +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Steemit.ahk +; Gab +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Gab.ahk - IniWrite, Successful, %StatusFileFilePath%, Status, Parler +; Gettr +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Gettr.ahk - AddToTotalPostsPostedCount() - - Message = Submitted Successfully - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - - PauseBetweenPosts() - DevModeMsgBox("done!") - - Return - ; -------------------------------/Parler------------------------------- - -/* -*/ - -; -------------------------------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------------------------------- - -/* -*/ - -; -------------------------------LinkedIn------------------------------- -PostToLinkedIN: -CurrentSite := "LinkedIn" - -if(StrLen(PostTitleAndBody) > 1300){ - Message = Post longer than LinkedIn's 1300 character limit. Posting Skipped. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, LinkedIn - Return -} - -SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - - -URLAttempt := NavigateFromBaseURLTo("https://www.linkedin.com/login") -if(URLAttempt = "Failed") -Return - -Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} - -Message = Checking Login Status -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -sleep, 1000 -try CurrentTabURL := driver.Url -if(InStr(CurrentTabURL, "login")){ - Message = Login Expired. Please log back in - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - - -Message = Clicking "Start a Post" button -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - -loop, 3 { - Xpath = (//span[normalize-space()='Start a post'])[1] ; start a post button - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(!Status) - Break - ; Msgbox % "Status: " Status - if(Status AND A_index = 1){ - try CurrentURL := driver.url - Message = Failed to click on "Start a post" button`nChecking Login Status`nCurrent URL: %CurrentURL% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - try html := driver.pagesource ; save page's entire HTML to a variable - if(InStr(HTML, "Sign In") AND InStr(HTML, "Forgot password")){ - Xpath = //button[normalize-space()='Sign in'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding - sleep, 2000 - driver.Get("https://www.linkedin.com/feed/") ;Open selected URL - ; driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding - continue - } - else, ; otherwise check and toggle the chat popup on the side - { - Message = Checking if Chat Sidebar is in the way - SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - try html := driver.pagesource ; save page's entire HTML to a variable - if(InStr(HTML,"You are on the messaging overlay. Press enter to minimize it.")){ ; if sidebar is open - Xpath = //body//div//aside//button[2] ; click to minimize it - try driver.FindElementByXPath(Xpath).click() - Message = Chat sidebar was minimized - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Continue ; continue to next loop - } - } - } - ; DevModeMsgBox("test") - ; Check if linked in post popup appeared - Xpath = //div[@aria-label='Text editor for creating content'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Failed to click into Create Post popup to input post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - } -} - -if(Status){ - Message = Login Expired. Please log back in - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - -if(ImageAttachmentFilepath != ""){ - ; Click the upload image button - SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") - - ; click attach image button - Xpath = //li-icon[@type='image']//*[name()='svg'] - Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) - if(Status){ - Message = Failed to click "Attach Image" button with Selenium - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - Xpath = //input[@id='image-sharing-detour-container__file-input'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) - if(Status){ - Message = Failed to Attach photo with both attempts. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - if(WinExist("Open")) ; if open image popup still exists, close it - WinClose, Open - ; Return - } - else, { - Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) - if(Status) - { - Message = Failed to input filepath into "Open File" window. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - } - ; sleep, 10000 - - Xpath = //span[normalize-space()='Done'] ; click done button - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) - if(Status){ - Message = Failed to click "Done" button on image upload - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 5000 - -} - -Message = Inputting Post -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -; Input Post text contents -loop, 3 { - Xpath = //div[@aria-label='Text editor for creating content'] ; Input text of post - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody) - if(Status){ - Message = Failed to input post content - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - } - - ; Double check that post got input - Jscheck = return document.querySelector("div[aria-label='Text editor for creating content']").innerText - try Status := driver.executeScript(Jscheck) - ; DevModeMsgBox(Status) - if(StrLen(Status) > 5) - Break - - if(A_index = 3){ - Message = Post Failed: Failed to input Post for some reason - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - ; Continue -} - -/* if(!Status){ ; if BLANK - Message = Post Failed: Failed to input Post for some reason - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - */ - ; sleep, 2000 - - if(InStr(PostTitleAndBody, "http") OR InStr(PostTitleAndBody, "www")){ - Message = Waiting 10 seconds for Preview to Get Fetched - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 10000 - } - else, { - sleep, 2000 - } - - - SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") - - - Xpath = //span[normalize-space()='Post'] ; Click the final "post" button - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) - if(Status){ - Jscheck = return document.querySelector("div[aria-label='Text editor for creating content']").textContent ; Grabb innertext - try TextContent := driver.executeScript(Jscheck) - - Message = Failed to Submit Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - - Message = Failed to Submit Post: Text Content that got input: %TextContent% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - -/* ; Keep trying to click the home button until able to and then move on to next site because sometimes it takes a while for a post to upload - Xpath = //span[normalize-space()='Home'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=30,SleepLength:=1000) - - */ - - IniWrite, Successful, %StatusFileFilePath%, Status, LinkedIn - AddToTotalPostsPostedCount() - - ; DevModeMsgBox("done!") - - PauseBetweenPosts() - DevModeMsgBox("done!") - - Message = Post Publish Successful - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - - Return - ; -------------------------------/LinkedIn------------------------------- - -/* -*/ - -; -------------------------------Minds------------------------------- -PostToMinds: -CurrentSite := "Minds" - - -SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - -URLAttempt := NavigateFromBaseURLTo("https://www.minds.com/newsfeed/subscriptions") -if(URLAttempt = "Failed") -Return - -Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} - -sleep, 1000 - -try CurrentTabURL := driver.Url -; Msgbox % "CurrentTabURL: " CurrentTabURL -if(InStr(CurrentTabURL, "login")){ - Message = Login Cookies Expired. Trying to Re-Login - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 2000 - Xpath = //div[contains(text(),'Login')] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding -} - -Message = Clicking into Speak your mind.. Box -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - -loop, 3 { - if(A_index = 3){ - SaveOrPostProgress(Message:="Failed to click into -speak your mind..- input box.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - - ; Click the Big Compose Box at the top of the page - Xpath = //div[@class='m-composer__triggerOverlay'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) - ; Status := Selenium_LoopToClickXpath(Xpath,5,1000) - if(Status){ - SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - ; check that popup appears by checking for "Create Blog" button in popup - js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText - try status := driver.executeScript(js) - if(InStr(Status, "Create Blog")){ - break - } - else, { - continue - } - - ; Msgbox % "status: " status - - - -} - -; Attach Image -if(ImageAttachmentFilepath != ""){ - ; Click the upload image button - SaveOrPostProgress(Message:="Attaching Image",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 (E#1203) - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - SaveOrPostProgress(Message:="Waiting 2 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") - - sleep, 2000 - - - SaveOrPostProgress(Message:="Inputting Post Content`nMight take 5-15 seconds to get input",PostType:="Tooltip,ErrorLoggingTextFile") - - ; Click the plus button to make the title box show up - Xpath = //div[@class='m-composer__base m-composer__base--withPreview']//i[@class='material-icons ng-star-inserted'][normalize-space()='add_circle_outline'] - try driver.FindElementByXPath(Xpath).click() - catch e { ; if failed to plus button, then input the post body and text into the same box - ; msgbox, failed to click Plus - ; goto, InputMindsPostCombined - } - - ; if plus button was clicked successfully, input title and body individually - ; Input title - ; Msgbox % "PostTitle: " PostTitle - Xpath = //textarea[@placeholder='Title'] - ; driver.FindElementByXPath(Xpath).SendKeys("heleeoeoe") - - ; CLick into title box - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - - ; Input text itno title box - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitle) - if(Status){ ; if failed to input title then skip to inputting both combined - ; msgbox, failed to input title - Message = Failed to input Title - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - MindsTitleStatus := "Failed" - ; Return - - ; goto, InputMindsPostCombined - } - - ; msgbox, title input? - ; Input body - if(MindsTitleStatus) - MindsPost := PostTitleAndBody - else, MindsPost := PostBody - - ; Msgbox % "PostBody: " PostBody - Xpath = //textarea[@id='minds-m-composer__textarea--1003'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=MindsPost) - if(Status){ - ; msgbox, failed to input body - Message = Failed to post with Xpath, trying with ID - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,MindsPost) - if(Status){ - Message = Failed to input Post Content into Page - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - } -} -else, { ; otherwise, input just text - SaveOrPostProgress(Message:="Inputting Text Post",PostType:="Tooltip,ErrorLoggingTextFile") - ; DevModeMsgBox("Inputting Text Post") - Xpath = //textarea[@id='minds-m-composer__textarea--1003'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) - - - if(Status){ - Message = Failed to post with Xpath, trying with ID - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,PostTitleAndBody) - if(Status){ - Message = Failed to input Post Content into Page - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - } - - - if(InStr(PostBody,"http")) - { - Message = Sleeping 5 seconds for preview to load - SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 5000 - } - -} - -; sleep, 2000 -SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") - - -loop, 3 { - if(A_index = 3){ - SaveOrPostProgress(Message:="Failed to submit post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - ; click submit button - 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) - catch e { - Message = Clicking submit button with JS resulted in status: %status% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - } - - SaveOrPostProgress(Message:="Waiting 5 seconds to confirm post got submitted",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - sleep, 5000 - - ; check that popup appears by checking for "Create Blog" button in popup - js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText - try status := driver.executeScript(js) - if(InStr(Status, "Create Blog")){ - continue - } - else, { - break - } - - -} - - -/* if(!TestingMode){ - SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") - - Xpath = Xpath = (//span[@class='ng-star-inserted'][normalize-space()='Post'])[2] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=5000) - sleep, 1000 - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=5000) - if(Status){ - Message = Failed to Submit Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - } - - */ - - ; Click the post button - - - IniWrite, Successful, %StatusFileFilePath%, Status, Minds - AddToTotalPostsPostedCount() - - - - PauseBetweenPosts() - DevModeMsgBox("done!") - - Message = Post Publish Successful - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - - Return - ; -------------------------------/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, %A_Space% -if(LocalsURL = ""){ - Message = Please add your Locals Profile URL to the settings.ini file under`n`n[General]`nLocalsURL= - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - - -Message = LocalsURL from Ini File: %LocalsURL% -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -if(!InStr(LocalsURL, "/share/post")){ - LocalsURL = https://freedomain.locals.com/share/post - - Message = LocalsURL from ini file was incorrect. New URL set to %LocalsURL% and saved to settings.ini - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - IniWrite, %LocalsURL%, %SettingsIniFilepath%, %ScriptSettingsSection%, LocalsURL -} - -; 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 -} -sleep, 1000 - -Message = Checking Login Status - -try CurrentTabURL := driver.Url -if(InStr(CurrentTabURL, "/login") OR InStr(CurrentTabURL, "/register")){ - Message = Login Expired. Please log back in - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - - - - -Message = Inputting Post Content -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - -Xpath = //*[@id="body"] -try driver.FindElementByXPath(Xpath).click() -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) -if(Status){ - Message = Failed to input Title - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - - - - -if(ImageAttachmentFilepath != ""){ - ; Click the upload image button - SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") - - - Xpath = //input[@multiple='multiple'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) - if(Status){ - Message = Failed to Upload Image - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - ; driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) - ; driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) - - - SaveOrPostProgress(Message:="Waiting 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") - - sleep, 10000 -} -Message = Submitting Post -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - - - -/* ; Click the final "post" button - SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") - Status := Selenium_LoopToClickName(ElementName:="submitPost",NumOfLoops:=5,SleepLength:=1000) - if(Status){ - Message = Failed to Submit Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - */ - - ; msgbox - - ; @todo: add error check into here to check the current page url and after page url - ; Click Publish post - js = document.getElementsByName('submitPost')[0].click(); ; Send content through javascript (Great for getting around emoji chrome limitaitons) - try driver.executeScript(js) - - Message = Double checking that post got submitted - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 5000 - - - try CurrentTabURL := driver.Url - if(InStr(CurrentTabURL, "share/post")) { ; post failed to submit if it's still on the create new post page - Message = Error: Post Was Input but Failed to Submit. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - -} - -/* ; Double check that post got submitted - js = return document.querySelector("#body").value - Status := driver.executeScript(js) - if(Status != ""){ - Message = Error: Post Failed to Submit for some reason - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - */ - - IniWrite, Successful, %StatusFileFilePath%, Status, Locals - AddToTotalPostsPostedCount() - - - - SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - PauseBetweenPosts() - DevModeMsgBox("done!") - - Message = Post Publish Successful - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - - - Return - ; -------------------------------/Locals------------------------------- - -/* -*/ - -; -------------------------------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") - -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------------------------------- - - -; -------------------------------Bastyon------------------------------- -PostToPocketNet: -CurrentSite := "Bastyon" - - -SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -URLAttempt := NavigateFromBaseURLTo("https://bastyon.com/index") -if(URLAttempt = "Failed") -Return - -Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} -; Loop a bunch of times for page to load -SaveOrPostProgress(Message:="Waiting for Page to Load Fully",PostType:="Tooltip,ErrorLoggingTextFile") -loop, 12 { - - ; click into input box - js = document.querySelector(".emojionearea-editor.pastable").click() - try driver.executeScript(js) - - Xpath = //div[@class='emojionearea-editor pastable'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=5000) - if(!Status) - break - - Xpath = //b[normalize-space()='Sign in'] - try Status := driver.findelementbyxpath(Xpath).Attribute("textContent") ;XPath: ID=site-title & span tag - if(InStr(Status, "Sign in")){ - break - } - - ; Msgbox % "Status: " Status -} -if(Status){ ; if failed to click into entry box - Message = Login Expired. Please log back in - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - - - - -Message = Clearing Previous Post Content -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -js = document.querySelector("div[title='Clear post'] i[class='fas fa-times-circle']").click() -try driver.executeScript(js) - -sleep, 1000 - -js = document.querySelector(".btn1.medium").click() -try driver.executeScript(js) - -sleep, 1000 - -; msgbox - -; input post text content -Message = Inputting Post Content -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -JsToExecute = document.getElementsByClassName('emojionearea-editor pastable')[0].innerText = '%JSPostTitleAndBody%' -Status := JS_TryToExecute(JsToExecute) -if(Status){ - Message = Post Failed: Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - -JsToExecute = return document.getElementsByClassName('emojionearea-editor pastable')[0].textContent; -try Status := driver.executeScript(JsToExecute) -if(Status = ""){ - Message = Post Failed: Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} -; Message = Post that got input: %Status% -; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging") -; DevModeMsgBox(Message) -; msgbox % "textContent: " . textContent - - - -; Doesn't work for some reason -; JsToExecute = return document.querySelector("div.txt div.emojionearea.message div.emojionearea-editor.pastable").innerText -; Status := JS_TryToExecute(JsToExecute) -; if(Status){ - ; Message = Check Login Status: Failed to Input Post - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - ; Return - ; } - - - sleep, 2000 - - if(ImageAttachmentFilepath != ""){ - ; Message = Attaching Image - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - - ; Click the "Image" button - SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") -/* Xpath = //div[@title='Add Images to Post'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Failed to Click "Attach Image" Button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - */ - - - - ; sleep, 5000 - - Xpath = //input[@type='file'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=3,SleepLength:=5000,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 Upload",PostType:="Tooltip,ErrorLoggingTextFile") - - sleep, 10000 - - - } - - ; Input Tags - Xpath = //div[@class='search fastSearchShow']//input[@id='text'] - TagsArray := StrSplit(PostTags, ",") - TagsArrayLength := TagsArray.Length() ; Save total number of items in the array - loop, %TagsArrayLength% { - Tag := TagsArray[A_Index] - Tag := StrReplace(Tag, " ", "") - DevModeMsgBox(Tag) - ; Tag = %Tag% - Xpath = //input[@placeholder='Categories and tags'] - driver.FindElementByXPath(Xpath).SendKeys(Tag) - driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.ENTER) - - ; driver.findElementsByClass("sminput").item[2].click() - - ; JsToExecute = document.querySelector("#text[placeholder='Add Categories/Tags']").value = "#%Tag%" - ; Status := JS_TryToExecute(JsToExecute) - ; - ; driver.SendKeys(driver.Keys.SPACE) - ; - ; JsToExecute = return document.querySelector("#text[placeholder='Add Categories/Tags']").value - ; Status := JS_TryToExecute(JsToExecute) - - if(A_index = 5) - Break - - - /*Tag := TagsArray[A_Index] - Tag := StrReplace(Tag, " ", "") - ; Tag = %Tag% - Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag) - try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Space) - - */ - ; if(A_index = 8) ; Steemit only allows 8 tags - ; Break - } - ; msgbox - -/* Xpath = //div[@class='emojionearea-editor pastable'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=3,SleepLength:=1000,StringTextContent:=PostTitleAndBody) - if(Status){ - SaveOrPostProgress(Message:="Failed to Input Post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - - ; Send, - } - */ - - - ; Msgbox,4096,Pause!!,asdf - - SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") - - ; CLick the post button - Xpath = //button[normalize-space()='Post'] - loop, 3 { - try driver.FindElementByXPath(Xpath).click() - sleep, 1500 - } - ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) - ; sleep, 2000 - ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) -/* if(Status){ - Message = Failed to Submit Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - */ - Message = Waiting 5 seconds to double check that post got submitted - SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - sleep, 5000 - ; try PossiblyError := driver.findElementsByClass("paddingmobilewrapper").item[1].Attribute("innerText") ; Grabb innertext - - ; CHeck if input box still contains text - JsToExecute = return document.getElementsByClassName('emojionearea-editor pastable')[0].textContent; - try Status := driver.executeScript(JsToExecute) - if(Status){ - ; sleep, 2000 - try Jscheck = return document.querySelector(".paddingmobilewrapper").textContent ; Grabb innertext - PossiblyError := driver.executeScript(Jscheck) - PossiblyError := StrReplace(PossiblyError, "`n", "") ; remove extra stuff from text - PossiblyError := StrReplace(PossiblyError, " ", "") ; remove extra stuff from text - PossiblyError := StrReplace(PossiblyError, A_Tab, "") ; remove extra stuff from text - - ; Msgbox % "PossiblyError: " PossiblyError - Message = Failed To Submit Post: Error was: %PossiblyError% - ; DevModeMsgBox(PossiblyError) - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - - - ; sleep, 2000 - ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) -/* if(Status){ - Message = Failed to Submit Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - */ - - - IniWrite, Successful, %StatusFileFilePath%, Status, PocketNet - AddToTotalPostsPostedCount() - - - - SaveOrPostProgress(Message:=Message,PostType:="Tooltip") - PauseBetweenPosts() - DevModeMsgBox("done!") - - Message = Post Publish Successful - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - - Return - ; -------------------------------/Bastyon------------------------------- - - - - ;-----------------------Steemit------------------------- - PostToSteemit: - CurrentSite := "Steemit" - - - - SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - URLAttempt := NavigateFromBaseURLTo("https://steemit.com/submit.html") - if(URLAttempt = "Failed") - Return - - Status := CheckCurrentTabForCurrentSite() - if(Status){ - Return - } - - - Message = Checking for Content from Previous Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - ; Click CLear Button - Xpath = //button[normalize-space()='Clear'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Trying to log back in - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Xpath = //a[normalize-space()='Login'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Login Expired. Please log back in - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - sleep, 2000 - ; otherwise button was clicked and we need to submit the saved credentials - Xpath = //button[normalize-space()='Login'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=20,SleepLength:=100) - ; DevModeMsgBox(Status) - if(Status){ - Message = Login Expired. Please log back in - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - else, - { - sleep, 3000 - Xpath = //button[normalize-space()='Clear'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Upload Failed: Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - } - - } - else, { - sleep, 500 - try, driver.switchToalert().accept() ; if text exists Steemit will pop up menu asking for confirmation for clearing - } - - - - -/* if(Status){ - Message = Post Failed, Please check login status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - ; Click "Accept" popup that asks if you're sure you want to clear post - try, driver.switchToalert().accept() - - */ - - - - Message = Inputting Post Content - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - - ; Input title - Xpath = //input[@placeholder='Title'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitle) - if(Status){ - Message = Login Expired. Please log back in - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - - Xpath = //textarea[@placeholder='Write your story...'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostBody) - if(Status){ - Message = Failed to input Post Body - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - - - if(ImageAttachmentFilepath != ""){ - Message = Attaching Thumbnail - SaveOrPostProgress(Message:=Message,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 - } - -/* - Xpath = //a[normalize-space()='selecting them'] - Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) - if(Status){ - Message = Failed to click on "Attach Image" button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - 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 - } - - */ - Message = Waiting 5 seconds for thumbnail to be generated - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - sleep, 5000 - } - - - message = Inputting Tags - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - ; Input Post Tags - Xpath = //input[@placeholder='#tag'] - TagsArray := StrSplit(PostTags, ",") - TagsArrayLength := TagsArray.Length() ; Save total number of items in the array - loop, %TagsArrayLength%{ - Tag := TagsArray[A_Index] - Tag := StrReplace(Tag, " ", "") - Tag = #%Tag% - Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag) - try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Space) - - if(A_index = 8) ; Steemit only allows 8 tags - Break - } - - - Message = Submitting Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - - ; Click Submit Button - Xpath = //button[@type='submit'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - Message = Failed to submit Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - IniWrite, Successful, %StatusFileFilePath%, Status, Steemit - AddToTotalPostsPostedCount() - - - - PauseBetweenPosts() - DevModeMsgBox("done!") - - Message = Post Publish Successful - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - - Return - ;-----------------------/Steemit------------------------- - -/* -*/ - -;---Gettr--- -;------------------------------------------------ -PostToGettr: -CurrentSite := "Gettr" - -SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -URLAttempt := NavigateFromBaseURLTo("https://gettr.com/") -if(URLAttempt = "Failed") -Return - -Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} - -Message = Checking Login Status -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -sleep, 1000 - -; if string in tab url, then we are logged out -try CurrentTabURL := driver.Url -if(InStr(CurrentTabURL, "/onboarding")) -{ - Message = Login Expired. Please log back in - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - -; click input area -; Xpath =//button[contains(text(),'Post')] -; Xpath = ///div[@id='textarea-post'] -Xpath = //*[contains(text(),'What's new?')] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) -; double click, first click fails sometimes -sleep, 500 -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - -; Input image -if(ImageAttachmentFilepath != ""){ - - ; Attach image - 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 - } - - Message = Waiting for image to upload - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 3000 - - -} - - -; click input area -Xpath = //*[@id="textarea-post"] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - -; disable spellcheck on input field using javascript so text doesn't get garbled -js = document.getElementById('textarea-post').setAttribute("spellcheck", "false"); -try driver.executeScript(js) ;Executes a Javascript on the webpage, mostly used for buttons. - -; DevModeMsgBox(JSPostTitleAndBody) -; JsToExecute = document.querySelector("#textarea-post").text = "%JSPostTitleAndBody%"; -; JsToExecute = document.getElementById('textarea-post')[0].text = "%JSPostTitleAndBody%"; - - - -StrLengthOfPost := StrLen(PostTitleAndBody) - -SaveOrPostProgress(Message:="Inputting post very slow way to avoid issues with gettr's buggy text post-processing",PostType:="Tooltip,ErrorLoggingTextFile") - -Loop % StrLengthOfPost{ - ; IndexPlusOne := A_index + 1 - - Current_Char := SubStr(PostTitleAndBody, A_index, 1) - ; SubStr(String, StartingPos [, Length]) - ; MsgBox % Current_Char - ; Gettr_Index_Of_Line_Post := GettrPostArray[A_index] - ; DevModeMsgBox(Gettr_Index_Of_Line_Post) - - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100,StringTextContent:=Current_Char) - if(Status){ - Message = Failed to Input Text - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - ; sleep, 10 - ; try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Right) -} -sleep, 500 -; SaveOrPostProgress(Message:="Waiting 2 seconds before submitting",PostType:="Tooltip,ErrorLoggingTextFile") -; sleep, 2000 - - -SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") -sleep, 2000 - -; Click post button -Xpath = //span[normalize-space()='Post'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) -if(Status){ - Message = Failed to Submit Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorSummaryVar") - SaveDriverURLOFErrorPage() - Return -} - - -Message = Post Publish Successful -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -IniWrite, Successful, %StatusFileFilePath%, Status, gettr -AddToTotalPostsPostedCount() - - - -PauseBetweenPosts() - -DevModeMsgBox("done!") - -Return - - -;---/Gettr--- - - -; -------------------------------MeWe------------------------------- -PostToMeWe: -CurrentSite := "MeWe" - - - -SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -URLAttempt := NavigateFromBaseURLTo("https://www.mewe.com/myworld") -if(URLAttempt = "Failed") -Return - -Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} - -; Click out of try MeWe Premium popup if it appears -SaveOrPostProgress(Message:="Checking for Popups and closing them",PostType:="Tooltip,ErrorLoggingTextFile") -Xpath = //button[normalize-space()='Skip Trial'] -try driver.FindElementByXPath(Xpath).click() - -sleep, 1000 - -; Click on Tell your contacts what's happening button -SaveOrPostProgress(Message:="Clicking into Start Post Box",PostType:="Tooltip,ErrorLoggingTextFile") - -Xpath = //div[@data-testid='post-placeholder'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) -if(Status){ - SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - -; DevModeMsgBox("popup activated?") - - -; click into popup box to make sure it's activated -/*xpath = //div[@class='ql-editor ql-blank']//div -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) -DevModeMsgBox(Status) -*/ -; DevModeMsgBox("inputting post now after clickng") - -; input post title and body with javascript -JsToExecute = document.querySelector(".ql-editor").innerText = '%JSPostTitleAndBody%'; -try Status := driver.executeScript(JsToExecute) - - -; check that the input box contains text -JsToExecute = return document.querySelector(".ql-editor").innerText -try Status := driver.executeScript(JsToExecute) -if(StrLen(Status) < 5){ - Message = Failed to input post into popup box - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - - -/* -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostTitleAndBody) -if(Status){ - Message = Failed to input text into page. - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} -*/ - -; DevModeMsgBox("input worked?") - - -if(ImageAttachmentFilepath != ""){ - ; Click "Image" button - SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") - - Xpath = //input[@id='fake-upload-photo'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) -/* - ; Xpath = /html/body/div[2]/div/div[1]/div[2]/div[1]/div/div[2]/div/div[4]/div[1]/button[1] - Xpath = //button[@data-tooltip='Photo'] - Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) - if(Status){ - Message = Failed to click "Attach Photo" button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - - 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 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") - - sleep, 10000 -} - - -; Click the "Post" button -SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") -Xpath = (//button[normalize-space()='Post'])[1] -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, MeWe -AddToTotalPostsPostedCount() - - - -PauseBetweenPosts() -DevModeMsgBox("done!") - - -Message = Post Publish Successful -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -Return -; -------------------------------/MeWe------------------------------- - -; -------------------------------Twetch------------------------------- -TwetchAttemptNumber := 1 -PostToTwetch: -CurrentSite := "Twetch" - -; if(StrLen(PostTitleAndBody) > 256){ - ; Message = Post Skipped as it's longer than 256 Characters - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - ; IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, Twetch - ; Return - ; } - - - SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - URLAttempt := NavigateFromBaseURLTo("https://twetch.com/") - if(URLAttempt = "Failed") - Return - - Status := CheckCurrentTabForCurrentSite() - if(Status){ - Return - } - - sleep, 1000 - - Message = Checking Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - try CurrentTabURL := driver.Url - if(InStr(CurrentTabURL, "/welcome")){ - Message = Login Cookies Expired. Trying to Re-Login - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - sleep, 2000 ; 2 seconds for password to get loaded in by chrome - - Xpath = //button[@type='submit'][normalize-space()='Sign in'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - if(Status){ - SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - Message = Waiting for Page to finish loading - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 2000 - driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding - } - - - - ; SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - ; URLAttempt := NavigateFromBaseURLTo("https://twetch.com/") - ; if(URLAttempt = "Failed") - ; Return - - ; Message = - - - ; Click on "Create Post" - SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") - -/*Xpath = //textarea[@id='downshift-post-editor-default-input'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) -if(Status){ - SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} -*/ - -; Click into text input box at top of page -Xpath = //div[@role='textbox'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - - - -; Input Post contents -Xpath = //div[@role='textbox'] -status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=5000,SendKeysContent:=PostTitleAndBody) -if(Status){ - Message = Failed to Input Post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - -; DevModeMsgBox("input?") - -if(ImageAttachmentFilepath != ""){ - ; Click "Image" button - SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") - - Xpath = //input[@id='rich-file-input'] - 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 5 Seconds for Image to Upload ",PostType:="Tooltip,ErrorLoggingTextFile") - sleep, 5000 -} - - - -; Click on "Post" button -sleep, 2000 - -SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") - -Xpath = //button[normalize-space()='Post $0.02'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=4,SleepLength:=1000) -if(Status){ - Message = Failed to click on Submit Post Button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - -sleep, 1000 - -Xpath = //p[normalize-space()='Insufficient wallet balance'] -try, FundsStatus := driver.findelementbyxpath(Xpath).Attribute("innerText") ; Grabb innertext -if(FundsStatus){ - Message = Insufficient wallet balance to post - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - IniWrite, Insufficient wallet balance to post, %StatusFileFilePath%, Status, Twetch - Return -} - - -IniWrite, Successful, %StatusFileFilePath%, Status, Twetch -AddToTotalPostsPostedCount() - - - -PauseBetweenPosts() -DevModeMsgBox("done!") - -Message = Post Publish Successful -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -Return -; -------------------------------/Twetch------------------------------- - - -; -------------------------------Flote------------------------------- -PostToFlote: -CurrentSite := "Flote" - - -SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - -URLAttempt := NavigateFromBaseURLTo("https://flote.app/") -if(URLAttempt = "Failed") -Return - -Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} - -Message = Checking Login Status -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -js = return document.querySelector(".sc-iTONeN.jMeRLz.items").textContent; -try, status := driver.executeScript(js) - -if(InStr(Status, "Sign in")){ - if(AutoLogin){ - - ; click Sign In button at top of page - Xpath = //button[normalize-space()='SIGN IN'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - - driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding - - ; click login button underneath username/password fields - Xpath = //input[@name='login'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) - } - else, { - Message = Login Expired. Please log back in - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - } - - -} - - -SaveOrPostProgress(Message:="Inputting Post",PostType:="Tooltip,ErrorLoggingTextFile") -sleep, 1000 - - -; Click button to select text input box -Xpath = //input[@placeholder='Share whatever flotes your boat..'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) -if(Status){ - ; if error, then try clicking on "Login" button at the top right - TabUrl := GetCurrentTabURlBase() - Message = Unable to Click into New Post Box. Please check login status. Current URL: %TabUrl% - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - -} - -sleep, 1000 -; Wait for animation -; sleep, 5000 - -; Click into Title Inputbox -Xpath = //input[@placeholder='Title'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) -if(Status){ - Message = Failed to click into title inputbox, Please check login status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() - Return -} - -Message = Inputting Title -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -; Input Title -Xpath = //input[@placeholder='Title'] -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitle) - -; Input Body -Message = Inputting Body -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -Xpath = //div[@class='ql-editor']//p -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostBody) - -; DevModeMsgBox("testing") - -if(ImageAttachmentFilepath != ""){ - ; Click "Image" button - SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") - - ; Click Attach image button - Xpath = //*[@id="fileinput"] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) - if(Status){ - Message = Failed to Attach Image - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - Return - } - - Message = Waiting for Image to Finish Uploading - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - sleep, 5000 -} - -; DevModeMsgBox("test") - -; Message = Waiting 5 seconds for website to catch up -; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") -; sleep, 5000 - -Message = Submitting Post -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -; button changes depending on if image is attached or not -if(ImageAttachmentFilepath) -Xpath = //span[normalize-space()='Upload & Post'] -else, -Xpath = //span[normalize-space()='Post'] - - -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) -if(Status){ - SaveOrPostProgress(Message:="Failed to Click Submit Button. Please submit manually",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - SaveDriverURLOFErrorPage() -} - - - -IniWrite, Failed to Submit, %StatusFileFilePath%, Status, Flote -AddToTotalPostsPostedCount() - - - -PauseBetweenPosts() -DevModeMsgBox("done!") - - -Message = Post Publish Successful -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -Return -; -------------------------------/Flote------------------------------- - - - -; -------------------------------ThinkSpot------------------------------- -PostToThinkSpot: -CurrentSite := "Thinkspot" - -if(PostTags = ""){ - Message = Skipped: No Post Tags - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - IniWrite, Skipped: No Post Tags, %StatusFileFilePath%, Status, Thinkspot - Return -} - -SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - - -URLAttempt := NavigateFromBaseURLTo("https://www.thinkspot.com/create/post") -if(URLAttempt = "Failed") -Return - -Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} - -Message = Checking Login Status -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - -sleep, 1000 -try CurrentTabURL := driver.Url -if(InStr(CurrentTabURL, "/sign_in")){ - Message = Login Cookies Expired. Trying to Re-Login - ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") - ; SaveDriverURLOFErrorPage() - ; Return - Xpath = //input[@name='commit'] - Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=1000) - if(!Status){ - Message = Logged in Successfully - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - Status := NavigateFromBaseURLTo("https://www.thinkspot.com/create/post") - (Status)?(Return):() - sleep, 2000 - } - -} - -Status := CheckCurrentTabForCurrentSite() -if(Status){ - Return -} - - - -/* -Xpath = //a[@href='/create/post'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) -if(Status){ - Message = Failed to Click "Create Post" button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - -*/ - -; CLick into the title box of the new post window -Xpath = //div[@id='editorjs']//div[@class='ql-editor ql-blank'] -Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) -if(Status){ - Message = Failed to Click Into Titlebox: Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - -sleep, 500 - -; Input the Post Title -SaveOrPostProgress(Message:="Inputting Post Title",PostType:="Tooltip,ErrorLoggingTextFile") -Xpath = //input[@id='title'] -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostTitle) -if(Status){ - Message = Failed to Input Post Title: Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - -; Input post body -if(ImageAttachmentFilepath != "") -PostBody := PostBody . "`n" -SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") -Xpath = //div[@id='editorjs']//p -Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostBody) -if(Status){ - Message = Failed to Input Post Body: Check Login Status - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return -} - - -; Input Post Tags -Xpath = //span[@role='textbox'] -TagsArray := StrSplit(PostTags, ",") -TagsArrayLength := TagsArray.Length() ; Save total number of items in the array -loop, %TagsArrayLength%{ - Tag := TagsArray[A_Index] - - Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag) - try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.ENTER) -} - - - -if(ImageAttachmentFilepath != ""){ - ; Click "Image" button - SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") - - ; Insert image by sending it directly. - ; elements aren't loaded until the attach image button is pressed though, so defeats the purpose -/*Xpath = //input[@class='ql-image'] -try driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) - -*/ - -Xpath = //button[@class='ql-image'] -Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) -if(Status){ - Message = Failed to click "Attach Image" button - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - Xpath = //input[@class='ql-image'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) - if(Status){ - Message = Failed to Attach Image (E#7611) - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } -} -else, { - InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) - if(InputStatus = "Failed") - { - sleep, 2000 - Xpath = //i[@class='material-icons-outlined'][normalize-space()='image'] ; give it a second try :fingerscrossed: - Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) - - InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) - if(InputStatus) - { ; Try sending directly to element - Xpath = //input[@class='ql-image'] - Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) - if(Status){ - Message = Failed to Attach Image (E#7612) - SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") - Return - } - } - } - -} - -SaveOrPostProgress(Message:="Waiting 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") - -sleep, 10000 -} - -; Click the Post button -SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") -Xpath = //button[normalize-space()='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") - Return -} - - -IniWrite, Successful, %StatusFileFilePath%, Status, Thinkspot -AddToTotalPostsPostedCount() - - - -PauseBetweenPosts() - -; dismiss the pop up that appears for some reason -; try driver.switchToalert().accept() -DevModeMsgBox("done!") - -Message = Post Publish Successful -SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") - - -Return -; -------------------------------/ThinkSpot------------------------------- - - - - -; -------------------------------Functions------------------------------- -; #Include %A_scriptdir%\Lib\RunCMD.ahk - - -PauseBetweenPosts(){ - ; TimeBetweenpostsInMiliseconds := PauseTimeBetweenPosts*1000 - Message = Waiting %PauseTimeBetweenPosts% seconds before Moving on To Next Site - TooltipThis(Message) - ; Msgbox % "Message: " Message - ; Msgbox % "PauseTimeBetweenPosts: " PauseTimeBetweenPosts - sleep, %TimeBetweenpostsInMiliseconds% -} - - -ReadWebsiteStatuses(){ - ; Read status of each website and save them to variables to be used in GUI - IniRead, Gettr, %StatusFileFilePath%, Status, Gettr, %A_Space% - ; IniRead, Parler, %StatusFileFilePath%, Status, Parler, %A_Space% - IniRead, Steemit, %StatusFileFilePath%, Status, Steemit, %A_Space% - IniRead, Discord, %StatusFileFilePath%, Status, Discord, %A_Space% - IniRead, SubScribeStar, %StatusFileFilePath%, Status, SubScribeStar, %A_Space% - IniRead, Telegram, %StatusFileFilePath%, Status, Telegram, %A_Space% - IniRead, Minds, %StatusFileFilePath%, Status, Minds, %A_Space% - IniRead, Gab, %StatusFileFilePath%, Status, Gab, %A_Space% - IniRead, Locals, %StatusFileFilePath%, Status, Locals, %A_Space% - IniRead, LinkedIn, %StatusFileFilePath%, Status, LinkedIn, %A_Space% - IniRead, MeWe, %StatusFileFilePath%, Status, MeWe, %A_Space% - IniRead, Twetch, %StatusFileFilePath%, Status, Twetch, %A_Space% - IniRead, ThinkSpot, %StatusFileFilePath%, Status, ThinkSpot, %A_Space% - ; IniRead, Flote, %StatusFileFilePath%, Status, Flote, %A_Space% - IniRead, PocketNet, %StatusFileFilePath%, Status, PocketNet, %A_Space% - ; IniRead, Pintrest, %StatusFileFilePath%, Status, Pintrest, %A_Space% - ; IniRead, Tumblr, %StatusFileFilePath%, Status, Tumblr, %A_Space% -} - -; -------------------------------CreateErrorLoggingFiles------------------------------- -CreateErrorLoggingFiles(Path := ""){ - FormatTime, TodayDate, YYYYMMDDHH24MISS, yyyyMMdd_hhmmss - - ErrorLoggingDirectory := Path - - if(Path = ""){ - ErrorLoggingDirectory := A_ScriptDir . "\Lib\ErrorLogging" - ; If directory for error logging doesn't exist, create it - if(!FileExist(ErrorLoggingDirectory)) - FileCreateDir, %ErrorLoggingDirectory% - - ErrorLoggingDirectory := ErrorLoggingDirectory . "\" . TodayDate . "_FSMP" - } - ; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory - FileCreateDir, %ErrorLoggingDirectory% - - ; Create variables with filepaths that content will be saved to. - ErrorLoggingFilePath := ErrorLoggingDirectory . "\" . "ErrorLogging.txt" - StatusFileFilePath := ErrorLoggingDirectory . "\" . "PostStatus.ini" - PostTitleFilePath := ErrorLoggingDirectory . "\" . "PostTitle.txt" - PostBodyFilePath := ErrorLoggingDirectory . "\" . "PostBody.txt" - - ; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory - Return -} -; -------------------------------/CreateErrorLoggingFiles------------------------------- - -AddToTotalPostsPostedCount(){ - IniRead, TotalPostsPosted, %SettingsIniFilepath%, SocialMediaPoster, TotalPostsPosted, 0 - TotalPostsPosted += 1 - IniWrite, %TotalPostsPosted%, %SettingsIniFilepath%, SocialMediaPoster, TotalPostsPosted -} - -AddToTotalRunTime(){ - IniRead, TotalRunTime, %SettingsIniFilepath%, SocialMediaPoster, TotalRunTime, 0 - TotalRunTime := Round(TotalRunTime + ScriptRunTime),2 - ; TotalRunTime += ScriptRunTime - IniWrite, %TotalRunTime%, %SettingsIniFilepath%, SocialMediaPoster, TotalRunTime - -} - -OnMsgBoxConfirmPost() { - DetectHiddenWindows, On - Process, Exist - If (WinExist("ahk_class #32770 ahk_pid " . ErrorLevel)) { - WinMove,, 0 - } -} +; MeWe +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-MeWe.ahk +; Twetch +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Twetch.ahk +; Thinkspot +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Post-To-Thinkspot.ahk +; Misc Functions +;------------------------------------------------ +#include %A_ScriptDir%\Modules\Miscellaneous-Functions.ahk diff --git a/Modules/Miscellaneous-Functions.ahk b/Modules/Miscellaneous-Functions.ahk new file mode 100644 index 0000000..f416cf0 --- /dev/null +++ b/Modules/Miscellaneous-Functions.ahk @@ -0,0 +1,76 @@ + +PauseBetweenPosts(){ + ; TimeBetweenpostsInMiliseconds := PauseTimeBetweenPosts*1000 + Message = Waiting %PauseTimeBetweenPosts% seconds before Moving on To Next Site + TooltipThis(Message) + ; Msgbox % "Message: " Message + ; Msgbox % "PauseTimeBetweenPosts: " PauseTimeBetweenPosts + sleep, %TimeBetweenpostsInMiliseconds% +} + + +ReadWebsiteStatuses(){ + ; Read status of each website and save them to variables to be used in GUI + IniRead, Gettr, %StatusFileFilePath%, Status, Gettr, %A_Space% + ; IniRead, Parler, %StatusFileFilePath%, Status, Parler, %A_Space% + IniRead, Steemit, %StatusFileFilePath%, Status, Steemit, %A_Space% + IniRead, Discord, %StatusFileFilePath%, Status, Discord, %A_Space% + IniRead, SubScribeStar, %StatusFileFilePath%, Status, SubScribeStar, %A_Space% + IniRead, Telegram, %StatusFileFilePath%, Status, Telegram, %A_Space% + IniRead, Minds, %StatusFileFilePath%, Status, Minds, %A_Space% + IniRead, Gab, %StatusFileFilePath%, Status, Gab, %A_Space% + IniRead, Locals, %StatusFileFilePath%, Status, Locals, %A_Space% + IniRead, LinkedIn, %StatusFileFilePath%, Status, LinkedIn, %A_Space% + IniRead, MeWe, %StatusFileFilePath%, Status, MeWe, %A_Space% + IniRead, Twetch, %StatusFileFilePath%, Status, Twetch, %A_Space% + IniRead, ThinkSpot, %StatusFileFilePath%, Status, ThinkSpot, %A_Space% + ; IniRead, Flote, %StatusFileFilePath%, Status, Flote, %A_Space% + IniRead, PocketNet, %StatusFileFilePath%, Status, PocketNet, %A_Space% + ; IniRead, Pintrest, %StatusFileFilePath%, Status, Pintrest, %A_Space% + ; IniRead, Tumblr, %StatusFileFilePath%, Status, Tumblr, %A_Space% +} + +; -------------------------------CreateErrorLoggingFiles------------------------------- +CreateErrorLoggingFiles(Path := ""){ + FormatTime, TodayDate, YYYYMMDDHH24MISS, yyyyMMdd_hhmmss + + ErrorLoggingDirectory := Path + + if(Path = ""){ + ErrorLoggingDirectory := A_ScriptDir . "\Lib\ErrorLogging" + ; If directory for error logging doesn't exist, create it + if(!FileExist(ErrorLoggingDirectory)) + FileCreateDir, %ErrorLoggingDirectory% + + ErrorLoggingDirectory := ErrorLoggingDirectory . "\" . TodayDate . "_FSMP" + } + ; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory + FileCreateDir, %ErrorLoggingDirectory% + + ; Create variables with filepaths that content will be saved to. + ErrorLoggingFilePath := ErrorLoggingDirectory . "\" . "ErrorLogging.txt" + StatusFileFilePath := ErrorLoggingDirectory . "\" . "PostStatus.ini" + PostTitleFilePath := ErrorLoggingDirectory . "\" . "PostTitle.txt" + PostBodyFilePath := ErrorLoggingDirectory . "\" . "PostBody.txt" + + ; Msgbox % "ErrorLoggingDirectory: " ErrorLoggingDirectory + Return +} +; -------------------------------/CreateErrorLoggingFiles------------------------------- + +AddToTotalPostsPostedCount(){ + IniRead, TotalPostsPosted, %SettingsIniFilepath%, SocialMediaPoster, TotalPostsPosted, 0 + TotalPostsPosted += 1 + IniWrite, %TotalPostsPosted%, %SettingsIniFilepath%, SocialMediaPoster, TotalPostsPosted +} + +AddToTotalRunTime(){ + IniRead, TotalRunTime, %SettingsIniFilepath%, SocialMediaPoster, TotalRunTime, 0 + TotalRunTime := Round(TotalRunTime + ScriptRunTime),2 + ; TotalRunTime += ScriptRunTime + IniWrite, %TotalRunTime%, %SettingsIniFilepath%, SocialMediaPoster, TotalRunTime + +} + + + diff --git a/Modules/Post-To-Bastyon.ahk b/Modules/Post-To-Bastyon.ahk new file mode 100644 index 0000000..e62a96f --- /dev/null +++ b/Modules/Post-To-Bastyon.ahk @@ -0,0 +1,261 @@ + +; -------------------------------Bastyon------------------------------- +PostToPocketNet: +CurrentSite := "Bastyon" + + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +URLAttempt := NavigateFromBaseURLTo("https://bastyon.com/index") +if(URLAttempt = "Failed") +Return + +Status := CheckCurrentTabForCurrentSite() +if(Status){ + Return +} +; Loop a bunch of times for page to load +SaveOrPostProgress(Message:="Waiting for Page to Load Fully",PostType:="Tooltip,ErrorLoggingTextFile") +loop, 12 { + + ; click into input box + js = document.querySelector(".emojionearea-editor.pastable").click() + try driver.executeScript(js) + + Xpath = //div[@class='emojionearea-editor pastable'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=5000) + if(!Status) + break + + Xpath = //b[normalize-space()='Sign in'] + try Status := driver.findelementbyxpath(Xpath).Attribute("textContent") ;XPath: ID=site-title & span tag + if(InStr(Status, "Sign in")){ + break + } + + ; Msgbox % "Status: " Status +} +if(Status){ ; if failed to click into entry box + Message = Login Expired. Please log back in + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + + + +Message = Clearing Previous Post Content +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +js = document.querySelector("div[title='Clear post'] i[class='fas fa-times-circle']").click() +try driver.executeScript(js) + +sleep, 1000 + +js = document.querySelector(".btn1.medium").click() +try driver.executeScript(js) + +sleep, 1000 + +; msgbox + +; input post text content +Message = Inputting Post Content +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +JsToExecute = document.getElementsByClassName('emojionearea-editor pastable')[0].innerText = '%JSPostTitleAndBody%' +Status := JS_TryToExecute(JsToExecute) +if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +JsToExecute = return document.getElementsByClassName('emojionearea-editor pastable')[0].textContent; +try Status := driver.executeScript(JsToExecute) +if(Status = ""){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} +; Message = Post that got input: %Status% +; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordErrorLogging") +; DevModeMsgBox(Message) +; msgbox % "textContent: " . textContent + + + +; Doesn't work for some reason +; JsToExecute = return document.querySelector("div.txt div.emojionearea.message div.emojionearea-editor.pastable").innerText +; Status := JS_TryToExecute(JsToExecute) +; if(Status){ + ; Message = Check Login Status: Failed to Input Post + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; Return + ; } + + + sleep, 2000 + + if(ImageAttachmentFilepath != ""){ + ; Message = Attaching Image + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + + ; Click the "Image" button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") +/* Xpath = //div[@title='Add Images to Post'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to Click "Attach Image" Button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + */ + + + + ; sleep, 5000 + + Xpath = //input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=3,SleepLength:=5000,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 Upload",PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 10000 + + + } + + ; Input Tags + Xpath = //div[@class='search fastSearchShow']//input[@id='text'] + TagsArray := StrSplit(PostTags, ",") + TagsArrayLength := TagsArray.Length() ; Save total number of items in the array + loop, %TagsArrayLength% { + Tag := TagsArray[A_Index] + Tag := StrReplace(Tag, " ", "") + DevModeMsgBox(Tag) + ; Tag = %Tag% + Xpath = //input[@placeholder='Categories and tags'] + driver.FindElementByXPath(Xpath).SendKeys(Tag) + driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.ENTER) + + ; driver.findElementsByClass("sminput").item[2].click() + + ; JsToExecute = document.querySelector("#text[placeholder='Add Categories/Tags']").value = "#%Tag%" + ; Status := JS_TryToExecute(JsToExecute) + ; + ; driver.SendKeys(driver.Keys.SPACE) + ; + ; JsToExecute = return document.querySelector("#text[placeholder='Add Categories/Tags']").value + ; Status := JS_TryToExecute(JsToExecute) + + if(A_index = 5) + Break + + + /*Tag := TagsArray[A_Index] + Tag := StrReplace(Tag, " ", "") + ; Tag = %Tag% + Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag) + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Space) + + */ + ; if(A_index = 8) ; Steemit only allows 8 tags + ; Break + } + ; msgbox + +/* Xpath = //div[@class='emojionearea-editor pastable'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=3,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + SaveOrPostProgress(Message:="Failed to Input Post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + + ; Send, + } + */ + + + ; Msgbox,4096,Pause!!,asdf + + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + ; CLick the post button + Xpath = //button[normalize-space()='Post'] + loop, 3 { + try driver.FindElementByXPath(Xpath).click() + sleep, 1500 + } + ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) + ; sleep, 2000 + ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) +/* if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + */ + Message = Waiting 5 seconds to double check that post got submitted + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + sleep, 5000 + ; try PossiblyError := driver.findElementsByClass("paddingmobilewrapper").item[1].Attribute("innerText") ; Grabb innertext + + ; CHeck if input box still contains text + JsToExecute = return document.getElementsByClassName('emojionearea-editor pastable')[0].textContent; + try Status := driver.executeScript(JsToExecute) + if(Status){ + ; sleep, 2000 + try Jscheck = return document.querySelector(".paddingmobilewrapper").textContent ; Grabb innertext + PossiblyError := driver.executeScript(Jscheck) + PossiblyError := StrReplace(PossiblyError, "`n", "") ; remove extra stuff from text + PossiblyError := StrReplace(PossiblyError, " ", "") ; remove extra stuff from text + PossiblyError := StrReplace(PossiblyError, A_Tab, "") ; remove extra stuff from text + + ; Msgbox % "PossiblyError: " PossiblyError + Message = Failed To Submit Post: Error was: %PossiblyError% + ; DevModeMsgBox(PossiblyError) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + + ; sleep, 2000 + ; Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) +/* if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + */ + + + IniWrite, Successful, %StatusFileFilePath%, Status, PocketNet + AddToTotalPostsPostedCount() + + + + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + PauseBetweenPosts() + DevModeMsgBox("done!") + + Message = Post Publish Successful + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + Return + ; -------------------------------/Bastyon------------------------------- diff --git a/Modules/Post-To-Discord.ahk b/Modules/Post-To-Discord.ahk new file mode 100644 index 0000000..c6128e2 --- /dev/null +++ b/Modules/Post-To-Discord.ahk @@ -0,0 +1,127 @@ +; -------------------------------Discord------------------------------- +PostToDiscord: +CurrentSite := "Discord" + +; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile") +Message = Posting Through API +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +if(DiscordParlerWebhookURL = ""){ + Message = Webhook Link not found. Please set "DiscordParlerWebhookURL" in %SettingsIniFilepath%. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + + +if(BoldTitleWAPI){ + if(NewLineBetweenTitle) + Message = **%PostTitle%**`n`n%PostBody% + else, + Message = **%PostTitle%**`n%PostBody% +} +else, { ; NOT bold title + if(NewLineBetweenTitle) + Message = %PostTitle%`n`n%PostBody% + else, + Message = %PostTitle%`n%PostBody% +} + + + +if(ImageAttachmentFilepath != ""){ + SingleQuotationMark = " + ; remove any single quotes from filepath + ImageAttachmentFilepath := StrReplace(ImageAttachmentFilepath, SingleQuotationMark, "") + + if(StrLen(Message) > 1999){ ; split message into two parts if longer than this + loop % StrLen(Message) { + + if(A_index < 1900) + Continue + + SplitCharNumber := A_index + ; IndexMinusOne := A_index - 1 + + SplitLocationText := SubStr(Message, SplitCharNumber, 1) + if(SplitLocationText = " "){ + Break + ; Msgbox % "SplitLocation: " SplitLocation + } + } + + + + DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber) + SplitCharNumber := SplitCharNumber + 1 + DiscordMessagePartTwo := SubStr(Message, SplitCharNumber) + ; Msgbox % "DiscordMessagePartOne: " DiscordMessagePartOne + ; Msgbox % "DiscordMessagePartTwo: " DiscordMessagePartTwo + + Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler") + Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler") + Status := UploadImageToDiscord(DiscordParlerWebhookURL, "", ImageAttachmentFilepath) + + ; Msgbox % "StatusOne: " StatusOne + ; Msgbox % "StatusTwo: " StatusTwo + +/* if(!InStr(StatusOne, "id")){ ; if error for each of the messages, post its + parsed := JSON.Load(StatusOne) + StatusOneFailure := parsed.content[1] + + parsed := JSON.Load(StatusTwo) + StatusTwoFailure := parsed.content[1] + + Message = Partial Failure for the following reason: %StatusOneFailure% OR %StatusTwoFailure% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } + */ + } ; end of strlen > 1999 + else, { + Status := UploadImageToDiscord(DiscordParlerWebhookURL, Message, ImageAttachmentFilepath) + SaveOrPostProgress(Message:="Status",PostType:="ErrorLoggingTextFile") + + if(!InStr(Status, "id")){ + parsed := JSON.Load(Status) + Error := parsed.content[1] + ; Msgbox % "error: " error + Message = Discord Post Failed due to API Issue. Error was saved to errorlog; please forward to Yuriy + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + } + } + else { + if(StrLen(Message) > 1999){ ; split message into two parts if longer than this + loop % StrLen(Message) { + + if(A_index < 1900) + Continue + + SplitCharNumber := A_index + + SplitLocationText := SubStr(Message, SplitCharNumber, 1) + if(SplitLocationText = " "){ + Break + } + } + + DiscordMessagePartOne := SubStr(Message, 1, SplitCharNumber) + SplitCharNumber := SplitCharNumber + 1 + DiscordMessagePartTwo := SubStr(Message, SplitCharNumber) + + Status := SaveOrPostProgress(Message:=DiscordMessagePartOne,PostType:="ErrorLoggingTextFile,DiscordParler") + Status := SaveOrPostProgress(Message:=DiscordMessagePartTwo,PostType:="ErrorLoggingTextFile,DiscordParler") + } + else, + SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordParler") + } + + IniWrite, Successful, %StatusFileFilePath%, Status, Discord + AddToTotalPostsPostedCount() + + Message = Post Publish Successful + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + Return + ; -------------------------------/Discord------------------------------- diff --git a/Modules/Post-To-Facebook.ahk b/Modules/Post-To-Facebook.ahk new file mode 100644 index 0000000..70bdce1 --- /dev/null +++ b/Modules/Post-To-Facebook.ahk @@ -0,0 +1,190 @@ +;---------------Facebook---------------------------------- +PostToFacebook: +CurrentSite := "Facebook" + +Message = Navigating to Post Creation Page +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +Status := NavigateFromBaseURLTo("https://www.facebook.com/") +if(Status){ + Message = Failed to Navigate to Feed Page + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +} + +; Status := CheckCurrentTabForCurrentSite() +if(Status){ + Return +} + +sleep, 2000 +js = document.querySelector("div[class='m9osqain a5q79mjw gy2v8mqq jm1wdb64 k4urcfbm qv66sw1b'] span[class='a8c37x1j ni8dbmo4 stjgntxs l9j0dhe7']").click() + +; js = document.querySelector('a[aria-label$="Timeline"] + div > div:nth-child(1)').click() +try driver.executeScript(js) + +IniWrite, Incomplete, %StatusFileFilePath%, Status, Facebook +try Clipboard := PostTitleAndBody +SaveDriverURLOFErrorPage() + +Return + + + + + + + +; try html := driver.pagesource ; save page's entire HTML to a variable +; Clipboard := html +; Msgbox % "html: " html + +; Pull out greeting message +/*GreetingMessage := StrSplit(HTML, "What's on your mind,") +GreetingMessage := GreetingMessage[2] +GreetingMessage := StrSplit(GreetingMessage, "") +GreetingMessage := GreetingMessage[1] +GreetingMessage := "What's on your mind," . GreetingMessage +*/ +; Msgbox % "GreetingMessage: " GreetingMessage + +; //span[normalize-space()="What's on your mind, Yuriy?"] +; + +Message = Inputting Post +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +; Msgbox % "Status: " Status +if(ImageAttachmentFilepath = "" AND Status){ ; upload a temporary file and then remove it and input psot + Message = Inputting post using temporary image attachment workaround + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //div[@aria-label='Create a post']//div//input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=TemporaryImageFilepath) + if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + ; driver.FindElementByXPath(Xpath).SendKeys(TemporaryImageFilepath) + + sleep, 2000 + ; remove attachment + Xpath = //div[@aria-label='Remove post attachment'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=3000) + if(Status){ + Message = Upload Failed: Failed to remove temporary image. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + ; driver.FindElementByXPath(Xpath).click() + + + Xpath = //span[normalize-space()="What's on your mind, Stefan?"] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to click with Relative Xpath + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + ; click on "what's on your mind text box" + Xpath = //div[@aria-label='Create a post']//div[1]//div[1]//div[1]//span[1] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to click "What's on your mind" box to input post with relative and direct xpath + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Return + } + } + +} +if(ImageAttachmentFilepath != "") { ; otherwise send image straight to upload input box. The post box will open up automatically + Message = Attaching Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //div[@aria-label='Create a post']//div//input[@type='file'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Post Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } +/* ; Attach image button + Xpath = //div[@aria-label='Photo/Video']//div//div//div//div//div//i[@data-visualcompletion='css-img'] + Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + if(Status){ + Message = Failed to click "Attach Image" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + ; Input filepath of image/video + Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(Status) + { + Message = Upload Failed: Unable to Find "Open File" window to input Video filepath into + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + */ + + Message = Waiting 5 Seconds For Thumbnail Preview to Load + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + ; Wait for thumbnail to load + sleep, 5000 + +} + +Message = Posting Exited Early for Testing +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") +Return + +; Xpath = //div[@data-block='true']//div +Xpath = //div[@data-block='true']//div +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) +if(Status){ + Message = Failed to input Text Post message with Relative and direct Xpath + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + + + +IniWrite, Input - NOT Submitted, %StatusFileFilePath%, Status, Facebook +Message = Post Button Click Skipped. Please Double Check and Submit Post Manually +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar") +SaveDriverURLOFErrorPage() +Return + + + +Message = Submitting Post +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +; Click Post Button +xpath = //div[@aria-label='Post']//div//div//div//span[contains(text(),'Post')] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +if(Status){ + Message = Failed to click "Post" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +IniWrite, Successful, %StatusFileFilePath%, Status, Facebook +AddToTotalPostsPostedCount() + +Message = Post Publish Successful +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + +PauseBetweenPosts() +DevModeMsgBox("done!") + +Return +;---------------/Facebook---------------------------------- diff --git a/Modules/Post-To-Gab.ahk b/Modules/Post-To-Gab.ahk new file mode 100644 index 0000000..656e1ad --- /dev/null +++ b/Modules/Post-To-Gab.ahk @@ -0,0 +1,113 @@ + +; -------------------------------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") + +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------------------------------- diff --git a/Modules/Post-To-Gettr.ahk b/Modules/Post-To-Gettr.ahk new file mode 100644 index 0000000..62f1af6 --- /dev/null +++ b/Modules/Post-To-Gettr.ahk @@ -0,0 +1,135 @@ + +;---Gettr--- +;------------------------------------------------ +PostToGettr: +CurrentSite := "Gettr" + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +URLAttempt := NavigateFromBaseURLTo("https://gettr.com/") +if(URLAttempt = "Failed") +Return + +Status := CheckCurrentTabForCurrentSite() +if(Status){ + Return +} + +Message = Checking Login Status +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +sleep, 1000 + +; if string in tab url, then we are logged out +try CurrentTabURL := driver.Url +if(InStr(CurrentTabURL, "/onboarding")) +{ + Message = Login Expired. Please log back in + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +; click input area +; Xpath =//button[contains(text(),'Post')] +; Xpath = ///div[@id='textarea-post'] +Xpath = //*[contains(text(),'What's new?')] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +; double click, first click fails sometimes +sleep, 500 +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + +; Input image +if(ImageAttachmentFilepath != ""){ + + ; Attach image + 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 + } + + Message = Waiting for image to upload + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 3000 + + +} + + +; click input area +Xpath = //*[@id="textarea-post"] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + +; disable spellcheck on input field using javascript so text doesn't get garbled +js = document.getElementById('textarea-post').setAttribute("spellcheck", "false"); +try driver.executeScript(js) ;Executes a Javascript on the webpage, mostly used for buttons. + +; DevModeMsgBox(JSPostTitleAndBody) +; JsToExecute = document.querySelector("#textarea-post").text = "%JSPostTitleAndBody%"; +; JsToExecute = document.getElementById('textarea-post')[0].text = "%JSPostTitleAndBody%"; + + + +StrLengthOfPost := StrLen(PostTitleAndBody) + +SaveOrPostProgress(Message:="Inputting post very slow way to avoid issues with gettr's buggy text post-processing",PostType:="Tooltip,ErrorLoggingTextFile") + +Loop % StrLengthOfPost{ + ; IndexPlusOne := A_index + 1 + + Current_Char := SubStr(PostTitleAndBody, A_index, 1) + ; SubStr(String, StartingPos [, Length]) + ; MsgBox % Current_Char + ; Gettr_Index_Of_Line_Post := GettrPostArray[A_index] + ; DevModeMsgBox(Gettr_Index_Of_Line_Post) + + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=100,StringTextContent:=Current_Char) + if(Status){ + Message = Failed to Input Text + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; sleep, 10 + ; try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Right) +} +sleep, 500 +; SaveOrPostProgress(Message:="Waiting 2 seconds before submitting",PostType:="Tooltip,ErrorLoggingTextFile") +; sleep, 2000 + + +SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") +sleep, 2000 + +; Click post button +Xpath = //span[normalize-space()='Post'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) +if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorSummaryVar") + SaveDriverURLOFErrorPage() + Return +} + + +Message = Post Publish Successful +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +IniWrite, Successful, %StatusFileFilePath%, Status, gettr +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() + +DevModeMsgBox("done!") + +Return + + +;---/Gettr--- \ No newline at end of file diff --git a/Modules/Post-To-LinkedIn.ahk b/Modules/Post-To-LinkedIn.ahk new file mode 100644 index 0000000..be4944c --- /dev/null +++ b/Modules/Post-To-LinkedIn.ahk @@ -0,0 +1,229 @@ + +; -------------------------------LinkedIn------------------------------- +PostToLinkedIN: +CurrentSite := "LinkedIn" + +if(StrLen(PostTitleAndBody) > 1300){ + Message = Post longer than LinkedIn's 1300 character limit. Posting Skipped. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, LinkedIn + Return +} + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + +URLAttempt := NavigateFromBaseURLTo("https://www.linkedin.com/login") +if(URLAttempt = "Failed") +Return + +Status := CheckCurrentTabForCurrentSite() +if(Status){ + Return +} + +Message = Checking Login Status +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +sleep, 1000 +try CurrentTabURL := driver.Url +if(InStr(CurrentTabURL, "login")){ + Message = Login Expired. Please log back in + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + +Message = Clicking "Start a Post" button +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +loop, 3 { + Xpath = (//span[normalize-space()='Start a post'])[1] ; start a post button + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(!Status) + Break + ; Msgbox % "Status: " Status + if(Status AND A_index = 1){ + try CurrentURL := driver.url + Message = Failed to click on "Start a post" button`nChecking Login Status`nCurrent URL: %CurrentURL% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + try html := driver.pagesource ; save page's entire HTML to a variable + if(InStr(HTML, "Sign In") AND InStr(HTML, "Forgot password")){ + Xpath = //button[normalize-space()='Sign in'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + sleep, 2000 + driver.Get("https://www.linkedin.com/feed/") ;Open selected URL + ; driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + continue + } + else, ; otherwise check and toggle the chat popup on the side + { + Message = Checking if Chat Sidebar is in the way + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + try html := driver.pagesource ; save page's entire HTML to a variable + if(InStr(HTML,"You are on the messaging overlay. Press enter to minimize it.")){ ; if sidebar is open + Xpath = //body//div//aside//button[2] ; click to minimize it + try driver.FindElementByXPath(Xpath).click() + Message = Chat sidebar was minimized + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Continue ; continue to next loop + } + } + } + ; DevModeMsgBox("test") + ; Check if linked in post popup appeared + Xpath = //div[@aria-label='Text editor for creating content'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to click into Create Post popup to input post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + } +} + +if(Status){ + Message = Login Expired. Please log back in + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + +if(ImageAttachmentFilepath != ""){ + ; Click the upload image button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + ; click attach image button + Xpath = //li-icon[@type='image']//*[name()='svg'] + Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Message = Failed to click "Attach Image" button with Selenium + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + Xpath = //input[@id='image-sharing-detour-container__file-input'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach photo with both attempts. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + if(WinExist("Open")) ; if open image popup still exists, close it + WinClose, Open + ; Return + } + else, { + Status := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(Status) + { + Message = Failed to input filepath into "Open File" window. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + ; sleep, 10000 + + Xpath = //span[normalize-space()='Done'] ; click done button + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + if(Status){ + Message = Failed to click "Done" button on image upload + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + SaveOrPostProgress(Message:="Waiting 5 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 + +} + +Message = Inputting Post +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +; Input Post text contents +loop, 3 { + Xpath = //div[@aria-label='Text editor for creating content'] ; Input text of post + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + if(Status){ + Message = Failed to input post content + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + } + + ; Double check that post got input + Jscheck = return document.querySelector("div[aria-label='Text editor for creating content']").innerText + try Status := driver.executeScript(Jscheck) + ; DevModeMsgBox(Status) + if(StrLen(Status) > 5) + Break + + if(A_index = 3){ + Message = Post Failed: Failed to input Post for some reason + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; Continue +} + +/* if(!Status){ ; if BLANK + Message = Post Failed: Failed to input Post for some reason + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + */ + ; sleep, 2000 + + if(InStr(PostTitleAndBody, "http") OR InStr(PostTitleAndBody, "www")){ + Message = Waiting 10 seconds for Preview to Get Fetched + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 10000 + } + else, { + sleep, 2000 + } + + + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //span[normalize-space()='Post'] ; Click the final "post" button + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Jscheck = return document.querySelector("div[aria-label='Text editor for creating content']").textContent ; Grabb innertext + try TextContent := driver.executeScript(Jscheck) + + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + + Message = Failed to Submit Post: Text Content that got input: %TextContent% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + +/* ; Keep trying to click the home button until able to and then move on to next site because sometimes it takes a while for a post to upload + Xpath = //span[normalize-space()='Home'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=30,SleepLength:=1000) + + */ + + IniWrite, Successful, %StatusFileFilePath%, Status, LinkedIn + AddToTotalPostsPostedCount() + + ; DevModeMsgBox("done!") + + PauseBetweenPosts() + DevModeMsgBox("done!") + + Message = Post Publish Successful + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + Return + ; -------------------------------/LinkedIn------------------------------- diff --git a/Modules/Post-To-Locals.ahk b/Modules/Post-To-Locals.ahk new file mode 100644 index 0000000..d593d2d --- /dev/null +++ b/Modules/Post-To-Locals.ahk @@ -0,0 +1,162 @@ + +; -------------------------------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, %A_Space% +if(LocalsURL = ""){ + Message = Please add your Locals Profile URL to the settings.ini file under`n`n[General]`nLocalsURL= + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + + +Message = LocalsURL from Ini File: %LocalsURL% +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + +if(!InStr(LocalsURL, "/share/post")){ + LocalsURL = https://freedomain.locals.com/share/post + + Message = LocalsURL from ini file was incorrect. New URL set to %LocalsURL% and saved to settings.ini + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + IniWrite, %LocalsURL%, %SettingsIniFilepath%, %ScriptSettingsSection%, LocalsURL +} + +; 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 +} +sleep, 1000 + +Message = Checking Login Status + +try CurrentTabURL := driver.Url +if(InStr(CurrentTabURL, "/login") OR InStr(CurrentTabURL, "/register")){ + Message = Login Expired. Please log back in + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + + + +Message = Inputting Post Content +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +Xpath = //*[@id="body"] +try driver.FindElementByXPath(Xpath).click() +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) +if(Status){ + Message = Failed to input Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + + + +if(ImageAttachmentFilepath != ""){ + ; Click the upload image button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + + Xpath = //input[@multiple='multiple'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Upload Image + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + ; driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) + ; driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) + + + SaveOrPostProgress(Message:="Waiting 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 10000 +} +Message = Submitting Post +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + + +/* ; Click the final "post" button + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + Status := Selenium_LoopToClickName(ElementName:="submitPost",NumOfLoops:=5,SleepLength:=1000) + if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + */ + + ; msgbox + + ; @todo: add error check into here to check the current page url and after page url + ; Click Publish post + js = document.getElementsByName('submitPost')[0].click(); ; Send content through javascript (Great for getting around emoji chrome limitaitons) + try driver.executeScript(js) + + Message = Double checking that post got submitted + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 + + + try CurrentTabURL := driver.Url + if(InStr(CurrentTabURL, "share/post")) { ; post failed to submit if it's still on the create new post page + Message = Error: Post Was Input but Failed to Submit. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + +} + +/* ; Double check that post got submitted + js = return document.querySelector("#body").value + Status := driver.executeScript(js) + if(Status != ""){ + Message = Error: Post Failed to Submit for some reason + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + */ + + IniWrite, Successful, %StatusFileFilePath%, Status, Locals + AddToTotalPostsPostedCount() + + + + SaveOrPostProgress(Message:=Message,PostType:="Tooltip") + PauseBetweenPosts() + DevModeMsgBox("done!") + + Message = Post Publish Successful + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + + Return + ; -------------------------------/Locals------------------------------- diff --git a/Modules/Post-To-MeWe.ahk b/Modules/Post-To-MeWe.ahk new file mode 100644 index 0000000..6aa39d3 --- /dev/null +++ b/Modules/Post-To-MeWe.ahk @@ -0,0 +1,132 @@ + +; -------------------------------MeWe------------------------------- +PostToMeWe: +CurrentSite := "MeWe" + + + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +URLAttempt := NavigateFromBaseURLTo("https://www.mewe.com/myworld") +if(URLAttempt = "Failed") +Return + +Status := CheckCurrentTabForCurrentSite() +if(Status){ + Return +} + +; Click out of try MeWe Premium popup if it appears +SaveOrPostProgress(Message:="Checking for Popups and closing them",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //button[normalize-space()='Skip Trial'] +try driver.FindElementByXPath(Xpath).click() + +sleep, 1000 + +; Click on Tell your contacts what's happening button +SaveOrPostProgress(Message:="Clicking into Start Post Box",PostType:="Tooltip,ErrorLoggingTextFile") + +Xpath = //div[@data-testid='post-placeholder'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +; DevModeMsgBox("popup activated?") + + +; click into popup box to make sure it's activated +/*xpath = //div[@class='ql-editor ql-blank']//div +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +DevModeMsgBox(Status) +*/ +; DevModeMsgBox("inputting post now after clickng") + +; input post title and body with javascript +JsToExecute = document.querySelector(".ql-editor").innerText = '%JSPostTitleAndBody%'; +try Status := driver.executeScript(JsToExecute) + + +; check that the input box contains text +JsToExecute = return document.querySelector(".ql-editor").innerText +try Status := driver.executeScript(JsToExecute) +if(StrLen(Status) < 5){ + Message = Failed to input post into popup box + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + + +/* +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostTitleAndBody) +if(Status){ + Message = Failed to input text into page. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} +*/ + +; DevModeMsgBox("input worked?") + + +if(ImageAttachmentFilepath != ""){ + ; Click "Image" button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //input[@id='fake-upload-photo'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) +/* + ; Xpath = /html/body/div[2]/div/div[1]/div[2]/div[1]/div/div[2]/div/div[4]/div[1]/button[1] + Xpath = //button[@data-tooltip='Photo'] + Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + if(Status){ + Message = Failed to click "Attach Photo" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + 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 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 10000 +} + + +; Click the "Post" button +SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = (//button[normalize-space()='Post'])[1] +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, MeWe +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() +DevModeMsgBox("done!") + + +Message = Post Publish Successful +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + +Return +; -------------------------------/MeWe------------------------------- diff --git a/Modules/Post-To-Minds.ahk b/Modules/Post-To-Minds.ahk new file mode 100644 index 0000000..25423c2 --- /dev/null +++ b/Modules/Post-To-Minds.ahk @@ -0,0 +1,244 @@ + +; -------------------------------Minds------------------------------- +PostToMinds: +CurrentSite := "Minds" + + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +URLAttempt := NavigateFromBaseURLTo("https://www.minds.com/newsfeed/subscriptions") +if(URLAttempt = "Failed") +Return + +Status := CheckCurrentTabForCurrentSite() +if(Status){ + Return +} + +sleep, 1000 + +try CurrentTabURL := driver.Url +; Msgbox % "CurrentTabURL: " CurrentTabURL +if(InStr(CurrentTabURL, "login")){ + Message = Login Cookies Expired. Trying to Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 2000 + Xpath = //div[contains(text(),'Login')] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding +} + +Message = Clicking into Speak your mind.. Box +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +loop, 3 { + if(A_index = 3){ + SaveOrPostProgress(Message:="Failed to click into -speak your mind..- input box.",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + ; Click the Big Compose Box at the top of the page + Xpath = //div[@class='m-composer__triggerOverlay'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + ; Status := Selenium_LoopToClickXpath(Xpath,5,1000) + if(Status){ + SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; check that popup appears by checking for "Create Blog" button in popup + js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText + try status := driver.executeScript(js) + if(InStr(Status, "Create Blog")){ + break + } + else, { + continue + } + + ; Msgbox % "status: " status + + + +} + +; Attach Image +if(ImageAttachmentFilepath != ""){ + ; Click the upload image button + SaveOrPostProgress(Message:="Attaching Image",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 (E#1203) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + SaveOrPostProgress(Message:="Waiting 2 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 2000 + + + SaveOrPostProgress(Message:="Inputting Post Content`nMight take 5-15 seconds to get input",PostType:="Tooltip,ErrorLoggingTextFile") + + ; Click the plus button to make the title box show up + Xpath = //div[@class='m-composer__base m-composer__base--withPreview']//i[@class='material-icons ng-star-inserted'][normalize-space()='add_circle_outline'] + try driver.FindElementByXPath(Xpath).click() + catch e { ; if failed to plus button, then input the post body and text into the same box + ; msgbox, failed to click Plus + ; goto, InputMindsPostCombined + } + + ; if plus button was clicked successfully, input title and body individually + ; Input title + ; Msgbox % "PostTitle: " PostTitle + Xpath = //textarea[@placeholder='Title'] + ; driver.FindElementByXPath(Xpath).SendKeys("heleeoeoe") + + ; CLick into title box + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + + ; Input text itno title box + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitle) + if(Status){ ; if failed to input title then skip to inputting both combined + ; msgbox, failed to input title + Message = Failed to input Title + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + MindsTitleStatus := "Failed" + ; Return + + ; goto, InputMindsPostCombined + } + + ; msgbox, title input? + ; Input body + if(MindsTitleStatus) + MindsPost := PostTitleAndBody + else, MindsPost := PostBody + + ; Msgbox % "PostBody: " PostBody + Xpath = //textarea[@id='minds-m-composer__textarea--1003'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=MindsPost) + if(Status){ + ; msgbox, failed to input body + Message = Failed to post with Xpath, trying with ID + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,MindsPost) + if(Status){ + Message = Failed to input Post Content into Page + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } +} +else, { ; otherwise, input just text + SaveOrPostProgress(Message:="Inputting Text Post",PostType:="Tooltip,ErrorLoggingTextFile") + ; DevModeMsgBox("Inputting Text Post") + Xpath = //textarea[@id='minds-m-composer__textarea--1003'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody) + + + if(Status){ + Message = Failed to post with Xpath, trying with ID + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Status := Selenium_LoopToSendValueToID("minds-m-composer__textarea--1003",5,1000,PostTitleAndBody) + if(Status){ + Message = Failed to input Post Content into Page + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + + + if(InStr(PostBody,"http")) + { + Message = Sleeping 5 seconds for preview to load + SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 + } + +} + +; sleep, 2000 +SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + +loop, 3 { + if(A_index = 3){ + SaveOrPostProgress(Message:="Failed to submit post",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + ; click submit button + 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) + catch e { + Message = Clicking submit button with JS resulted in status: %status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + } + + SaveOrPostProgress(Message:="Waiting 5 seconds to confirm post got submitted",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + sleep, 5000 + + ; check that popup appears by checking for "Create Blog" button in popup + js = return document.querySelector("div[class='m-composer__base'] div[class='m-composerTitleBar__createBlogTrigger ng-star-inserted']").innerText + try status := driver.executeScript(js) + if(InStr(Status, "Create Blog")){ + continue + } + else, { + break + } + + +} + + +/* if(!TestingMode){ + SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = Xpath = (//span[@class='ng-star-inserted'][normalize-space()='Post'])[2] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=5000) + sleep, 1000 + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=5000) + if(Status){ + Message = Failed to Submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + + */ + + ; Click the post button + + + IniWrite, Successful, %StatusFileFilePath%, Status, Minds + AddToTotalPostsPostedCount() + + + + PauseBetweenPosts() + DevModeMsgBox("done!") + + Message = Post Publish Successful + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + Return + ; -------------------------------/Minds------------------------------- diff --git a/Modules/Post-To-Steemit.ahk b/Modules/Post-To-Steemit.ahk new file mode 100644 index 0000000..10c928f --- /dev/null +++ b/Modules/Post-To-Steemit.ahk @@ -0,0 +1,193 @@ + +;-----------------------Steemit------------------------- +PostToSteemit: +CurrentSite := "Steemit" + + + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +URLAttempt := NavigateFromBaseURLTo("https://steemit.com/submit.html") +if(URLAttempt = "Failed") +Return + +Status := CheckCurrentTabForCurrentSite() +if(Status){ + Return +} + + +Message = Checking for Content from Previous Post +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +; Click CLear Button +Xpath = //button[normalize-space()='Clear'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) +if(Status){ + Message = Trying to log back in + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + Xpath = //a[normalize-space()='Login'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Login Expired. Please log back in + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + sleep, 2000 + ; otherwise button was clicked and we need to submit the saved credentials + Xpath = //button[normalize-space()='Login'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=20,SleepLength:=100) + ; DevModeMsgBox(Status) + if(Status){ + Message = Login Expired. Please log back in + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + else, + { + sleep, 3000 + Xpath = //button[normalize-space()='Clear'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Upload Failed: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + } + +} +else, { + sleep, 500 + try, driver.switchToalert().accept() ; if text exists Steemit will pop up menu asking for confirmation for clearing +} + + + + +/* if(Status){ + Message = Post Failed, Please check login status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + ; Click "Accept" popup that asks if you're sure you want to clear post + try, driver.switchToalert().accept() + + */ + + + + Message = Inputting Post Content + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + ; Input title + Xpath = //input[@placeholder='Title'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitle) + if(Status){ + Message = Login Expired. Please log back in + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + Xpath = //textarea[@placeholder='Write your story...'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostBody) + if(Status){ + Message = Failed to input Post Body + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + + + if(ImageAttachmentFilepath != ""){ + Message = Attaching Thumbnail + SaveOrPostProgress(Message:=Message,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 + } + +/* + Xpath = //a[normalize-space()='selecting them'] + Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) + if(Status){ + Message = Failed to click on "Attach Image" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + 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 + } + + */ + Message = Waiting 5 seconds for thumbnail to be generated + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 5000 + } + + + message = Inputting Tags + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; Input Post Tags + Xpath = //input[@placeholder='#tag'] + TagsArray := StrSplit(PostTags, ",") + TagsArrayLength := TagsArray.Length() ; Save total number of items in the array + loop, %TagsArrayLength%{ + Tag := TagsArray[A_Index] + Tag := StrReplace(Tag, " ", "") + Tag = #%Tag% + Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag) + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.Space) + + if(A_index = 8) ; Steemit only allows 8 tags + Break + } + + + Message = Submitting Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + + ; Click Submit Button + Xpath = //button[@type='submit'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + Message = Failed to submit Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + IniWrite, Successful, %StatusFileFilePath%, Status, Steemit + AddToTotalPostsPostedCount() + + + + PauseBetweenPosts() + DevModeMsgBox("done!") + + Message = Post Publish Successful + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + Return + ;-----------------------/Steemit------------------------- diff --git a/Modules/Post-To-Subscribestar.ahk b/Modules/Post-To-Subscribestar.ahk new file mode 100644 index 0000000..b717811 --- /dev/null +++ b/Modules/Post-To-Subscribestar.ahk @@ -0,0 +1,186 @@ + +; -------------------------------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------------------------------- diff --git a/Modules/Post-To-Telegram.ahk b/Modules/Post-To-Telegram.ahk new file mode 100644 index 0000000..94bddda --- /dev/null +++ b/Modules/Post-To-Telegram.ahk @@ -0,0 +1,106 @@ + +; -------------------------------Telegram------------------------------- +; API documentation +; https://core.telegram.org/bots/api#sendmessage +PostToTelegram: +CurrentSite := "Telegram" + +; SaveOrPostProgress(Message:="Posting through API",PostType:="Tooltip,ErrorLoggingTextFile") +Message = Posting Through API +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + +if(TelegramBotToken = "" Or TelegramBotChatID =""){ + Message = TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script. + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + ; Msgbox, 4096, Error!, TelegramBotToken or TelegramBotChatID is missing from %SettingsIniFilepath%. `nPlease input them and rerun the script. + Return +} + + +LineBreakChar = `%0A ; Used for API + + +TelegramTitle := ASCIISTRReplace(PostTitle) +TelegramBody := ASCIISTRReplace(PostBody) + + +/* TelegramTitle := PostTitle + TelegramBody := PostBody + + */ + + ; Msgbox % "TelegramBody: " TelegramBody + + if(PostBody = ""){ + if(BoldTitleWAPI) + Message := "*" . TelegramTitle . "*" + else, + Message := TelegramTitle + } + else, { ; if postbody is not blank + ; MsgBox, we in post body + if(BoldTitleWAPI){ + if(NewLineBetweenTitle) + Message := "*" . TelegramTitle . "*" . "`n`n" . TelegramBody + else, + Message := "*" . TelegramTitle . "*" . "`n" . TelegramBody + } + else, { ; NOT Bold Title + if(NewLineBetweenTitle) + Message := TelegramTitle . "`n`n" . TelegramBody + else, + Message := TelegramTitle . "`n" . TelegramBody + + } + } + + ; Msgbox % "Message: " Message + ; REMOVE + ; Message := PostTitle . "`n" . PostBody + + ; Msgbox % "TelegramTitle: " TelegramTitle + ; Msgbox % "TelegramBody: " TelegramBody + + ; Msgbox % "Message: " Message + + + if(ImageAttachmentFilepath != "" AND StrLen(Message) > 1020){ ; utilize function that converts image to MIME/multi form + ; Telegram API character limit of 4096 for a basic message. + ; @todo: add functionality to split messages longer than 4096 characters + ; msgbox, 2 + + if(BoldTitleWAPI) + TelegramTitle := "*" . TelegramTitle . "*" + else, + TelegramTitle := TelegramTitle + + Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := TelegramTitle ) ; you could add more options; compare the Telegram API docs + Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := TelegramBody ) + } + else if(ImageAttachmentFilepath != "" AND StrLen(Message) <= 1020){ + Status := SendTelegramPhoto(TelegramBotToken, TelegramBotChatID, ImageAttachmentFilepath, caption := Message ) ; you could add more options; compare the Telegram API docs + + } + else, + { ; send just the text + ; Msgbox % "Message: " Message + Status := SendTelegramMessage(TelegramBotToken, TelegramBotChatID, text := Message ) + } + + if(Status){ + Message = Upload Failed due to API issue. Telegram API Returned Value:`n %Status% + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + + ; SaveOrPostProgress(Message:=Message,PostType:=",ErrorLoggingTextFile,DiscordParler") + IniWrite, Successful, %StatusFileFilePath%, Status, Telegram + AddToTotalPostsPostedCount() + + Message = Post Publish Successful + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + + Return + ; -------------------------------/Telegram------------------------------- diff --git a/Modules/Post-To-Thinkspot.ahk b/Modules/Post-To-Thinkspot.ahk new file mode 100644 index 0000000..b59ecf7 --- /dev/null +++ b/Modules/Post-To-Thinkspot.ahk @@ -0,0 +1,196 @@ + +; -------------------------------ThinkSpot------------------------------- +PostToThinkSpot: +CurrentSite := "Thinkspot" + +if(PostTags = ""){ + Message = Skipped: No Post Tags + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + IniWrite, Skipped: No Post Tags, %StatusFileFilePath%, Status, Thinkspot + Return +} + +SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + +URLAttempt := NavigateFromBaseURLTo("https://www.thinkspot.com/create/post") +if(URLAttempt = "Failed") +Return + +Status := CheckCurrentTabForCurrentSite() +if(Status){ + Return +} + +Message = Checking Login Status +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + +sleep, 1000 +try CurrentTabURL := driver.Url +if(InStr(CurrentTabURL, "/sign_in")){ + Message = Login Cookies Expired. Trying to Re-Login + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; SaveDriverURLOFErrorPage() + ; Return + Xpath = //input[@name='commit'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=1000) + if(!Status){ + Message = Logged in Successfully + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + Status := NavigateFromBaseURLTo("https://www.thinkspot.com/create/post") + (Status)?(Return):() + sleep, 2000 + } + +} + +Status := CheckCurrentTabForCurrentSite() +if(Status){ + Return +} + + + +/* +Xpath = //a[@href='/create/post'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + Message = Failed to Click "Create Post" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + +*/ + +; CLick into the title box of the new post window +Xpath = //div[@id='editorjs']//div[@class='ql-editor ql-blank'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + Message = Failed to Click Into Titlebox: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + +sleep, 500 + +; Input the Post Title +SaveOrPostProgress(Message:="Inputting Post Title",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //input[@id='title'] +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostTitle) +if(Status){ + Message = Failed to Input Post Title: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + +; Input post body +if(ImageAttachmentFilepath != "") +PostBody := PostBody . "`n" +SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //div[@id='editorjs']//p +Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=PostBody) +if(Status){ + Message = Failed to Input Post Body: Check Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} + + +; Input Post Tags +Xpath = //span[@role='textbox'] +TagsArray := StrSplit(PostTags, ",") +TagsArrayLength := TagsArray.Length() ; Save total number of items in the array +loop, %TagsArrayLength%{ + Tag := TagsArray[A_Index] + + Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,SendKeysContent:=Tag) + try driver.FindElementByXPath(Xpath).SendKeys(driver.Keys.ENTER) +} + + + +if(ImageAttachmentFilepath != ""){ + ; Click "Image" button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + ; Insert image by sending it directly. + ; elements aren't loaded until the attach image button is pressed though, so defeats the purpose +/*Xpath = //input[@class='ql-image'] +try driver.FindElementByXPath(Xpath).SendKeys(ImageAttachmentFilepath) + +*/ + +Xpath = //button[@class='ql-image'] +Status := Selenium_LoopToClickXpathAndWaitForOpenWindow(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1000) +if(Status){ + Message = Failed to click "Attach Image" button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + Xpath = //input[@class='ql-image'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach Image (E#7611) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } +} +else, { + InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(InputStatus = "Failed") + { + sleep, 2000 + Xpath = //i[@class='material-icons-outlined'][normalize-space()='image'] ; give it a second try :fingerscrossed: + Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) + + InputStatus := InputFilePathIntoOpenWindow(ImageAttachmentFilepath) + if(InputStatus) + { ; Try sending directly to element + Xpath = //input[@class='ql-image'] + Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath) + if(Status){ + Message = Failed to Attach Image (E#7612) + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return + } + } + } + +} + +SaveOrPostProgress(Message:="Waiting 10 seconds for Image to finish uploading",PostType:="Tooltip,ErrorLoggingTextFile") + +sleep, 10000 +} + +; Click the Post button +SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") +Xpath = //button[normalize-space()='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") + Return +} + + +IniWrite, Successful, %StatusFileFilePath%, Status, Thinkspot +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() + +; dismiss the pop up that appears for some reason +; try driver.switchToalert().accept() +DevModeMsgBox("done!") + +Message = Post Publish Successful +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + +Return +; -------------------------------/ThinkSpot------------------------------- + diff --git a/Modules/Post-To-Twetch.ahk b/Modules/Post-To-Twetch.ahk new file mode 100644 index 0000000..838f569 --- /dev/null +++ b/Modules/Post-To-Twetch.ahk @@ -0,0 +1,153 @@ + +; -------------------------------Twetch------------------------------- +TwetchAttemptNumber := 1 +PostToTwetch: +CurrentSite := "Twetch" + +; if(StrLen(PostTitleAndBody) > 256){ + ; Message = Post Skipped as it's longer than 256 Characters + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + ; IniWrite, Skipped - Too Long, %StatusFileFilePath%, Status, Twetch + ; Return + ; } + + + SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + URLAttempt := NavigateFromBaseURLTo("https://twetch.com/") + if(URLAttempt = "Failed") + Return + + Status := CheckCurrentTabForCurrentSite() + if(Status){ + Return + } + + sleep, 1000 + + Message = Checking Login Status + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + try CurrentTabURL := driver.Url + if(InStr(CurrentTabURL, "/welcome")){ + Message = Login Cookies Expired. Trying to Re-Login + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + sleep, 2000 ; 2 seconds for password to get loaded in by chrome + + Xpath = //button[@type='submit'][normalize-space()='Sign in'] + Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + if(Status){ + SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return + } + + Message = Waiting for Page to finish loading + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 2000 + driver.executeScript("return document.readyState").equals("complete") ; wait until page loads completely before proceeding + } + + + + ; SaveOrPostProgress(Message:="Navigating to Post Creation Page",PostType:="Tooltip,ErrorLoggingTextFile") + ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile") + + ; URLAttempt := NavigateFromBaseURLTo("https://twetch.com/") + ; if(URLAttempt = "Failed") + ; Return + + ; Message = + + + ; Click on "Create Post" + SaveOrPostProgress(Message:="Inputting Post Content",PostType:="Tooltip,ErrorLoggingTextFile") + +/*Xpath = //textarea[@id='downshift-post-editor-default-input'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000) +if(Status){ + SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + Return +} +*/ + +; Click into text input box at top of page +Xpath = //div[@role='textbox'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) + + + +; Input Post contents +Xpath = //div[@role='textbox'] +status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=5000,SendKeysContent:=PostTitleAndBody) +if(Status){ + Message = Failed to Input Post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +; DevModeMsgBox("input?") + +if(ImageAttachmentFilepath != ""){ + ; Click "Image" button + SaveOrPostProgress(Message:="Attaching Image",PostType:="Tooltip,ErrorLoggingTextFile") + + Xpath = //input[@id='rich-file-input'] + 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 5 Seconds for Image to Upload ",PostType:="Tooltip,ErrorLoggingTextFile") + sleep, 5000 +} + + + +; Click on "Post" button +sleep, 2000 + +SaveOrPostProgress(Message:="Submitting Post",PostType:="Tooltip,ErrorLoggingTextFile") + +Xpath = //button[normalize-space()='Post $0.02'] +Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=4,SleepLength:=1000) +if(Status){ + Message = Failed to click on Submit Post Button + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + Return +} + +sleep, 1000 + +Xpath = //p[normalize-space()='Insufficient wallet balance'] +try, FundsStatus := driver.findelementbyxpath(Xpath).Attribute("innerText") ; Grabb innertext +if(FundsStatus){ + Message = Insufficient wallet balance to post + SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") + SaveDriverURLOFErrorPage() + IniWrite, Insufficient wallet balance to post, %StatusFileFilePath%, Status, Twetch + Return +} + + +IniWrite, Successful, %StatusFileFilePath%, Status, Twetch +AddToTotalPostsPostedCount() + + + +PauseBetweenPosts() +DevModeMsgBox("done!") + +Message = Post Publish Successful +SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") + + +Return +; -------------------------------/Twetch-------------------------------