Updated Shared functions import, updated git api URLs, added login check to flote, added status messages to all sites for when post is posted successfully

main
Yuriy 2 years ago
parent 0682f4ebea
commit 65ed1f7a8c

@ -30,16 +30,17 @@ global UpdateVersionNumber
;---Notes/Extra Info/#Includes------------------------------------------------------ ;---Notes/Extra Info/#Includes------------------------------------------------------
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Freedomain-Posters-Shared-Functions.ahk #include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\StdOutToVar.ahk
; #Include %A_ScriptDir%\Lib\SharedFunctions.ahk #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\General-Shared-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Json.ahk #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Selenium-Shared-Functions.ahk
; #Include %A_ScriptDir%\Lib\ChromeAutomationFunctions.ahk #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-Shared-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\APIs-Shared-Functions.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\JSON.ahk
#Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\RunCMD.ahk #Include %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\RunCMD.ahk
ScriptName = Freedomain Social Media Poster ScriptName = Freedomain Social Media Poster
ScriptVersion = 2.74 ScriptVersion = 2.75
FullScriptName := ScriptName . " " . ScriptVersion FullScriptName := ScriptName . " " . ScriptVersion
;---ToDo--- ;---ToDo---
@ -182,7 +183,7 @@ UpdateURL = https://freedomainplaylists.com/wp-content/FreedomainScripts/Freedom
*/ */
global GitReleasesAPIURL global GitReleasesAPIURL
GitReleasesAPIURL = https://git.zinchuk.xyz/api/v1/repos/yuriy/Freedomain-Social-Media-Poster/releases GitReleasesAPIURL =https://git.freedomainplaylists.com/api/v1/repos/yuriy/Freedomain-Social-Media-Poster/releases
; Save filepath of the current script to %SettingsIniFilepath% so it can be read and used by the script updater ; Save filepath of the current script to %SettingsIniFilepath% so it can be read and used by the script updater
; Append informatio to ini files for Freedomain Program Updater ; Append informatio to ini files for Freedomain Program Updater
@ -631,7 +632,7 @@ run, "%A_ScriptFullPath%" "LastPost"
Return Return
OpenGiteaPage: OpenGiteaPage:
run, https://git.zinchuk.xyz/yuriy/Freedomain_Social_Media_Poster run, https://git.freedomainplaylists.com/yuriy/Freedomain_Social_Media_Poster
Return Return
CompileScript: CompileScript:
@ -1310,8 +1311,6 @@ AddToTotalPostsPostedCount()
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
; ; sleep, %TimeBetweenPosts%
DevModeMsgBox("done!") DevModeMsgBox("done!")
Return Return
@ -1339,8 +1338,6 @@ if(Status){
} }
; Check login status by checking the header of the page for "Feed" text ; Check login status by checking the header of the page for "Feed" text
loop, 5 { loop, 5 {
SaveOrPostProgress(Message:="Checking Login Status",PostType:="Tooltip,ErrorLoggingTextFile") SaveOrPostProgress(Message:="Checking Login Status",PostType:="Tooltip,ErrorLoggingTextFile")
@ -1549,14 +1546,17 @@ if(InStr(CurrentTabURL, "/login")){
*/ */
; Msgbox % "Status: " Status ; Msgbox % "Status: " Status
IniWrite, Successful, %StatusFileFilePath%, Status, Parler IniWrite, Successful, %StatusFileFilePath%, Status, Parler
AddToTotalPostsPostedCount() AddToTotalPostsPostedCount()
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Return Return
@ -1693,6 +1693,11 @@ if(InStr(CurrentTabURL, "/login")){
IniWrite, Successful, %StatusFileFilePath%, Status, Discord IniWrite, Successful, %StatusFileFilePath%, Status, Discord
AddToTotalPostsPostedCount() AddToTotalPostsPostedCount()
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/Discord------------------------------- ; -------------------------------/Discord-------------------------------
@ -1776,7 +1781,6 @@ if(InStr(CurrentTabURL, "/login")){
if(Status){ if(Status){
Message = Login Expired. Please log back in Message = Login Expired. Please log back in
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; TakeScreenshotOfPage()
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
} }
@ -1805,8 +1809,6 @@ if(InStr(CurrentTabURL, "/login")){
if(Status){ if(Status){
Message = Failed to Input Post using Direct Xpath. Trying with Relative Message = Failed to Input Post using Direct Xpath. Trying with Relative
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; TakeScreenshotOfPage()
; msgbox, 1
Xpath = /html/body/div/div[3]/div[2]/div[2]/div/div[1]/form/div[2]/div[1]/trix-editor 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) Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000,StringTextContent:=PostTitleAndBody)
@ -1821,7 +1823,6 @@ if(InStr(CurrentTabURL, "/login")){
catch e { catch e {
Message = Failed to Input Post Contents (E#8281) Message = Failed to Input Post Contents (E#8281)
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; TakeScreenshotOfPage()
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
} }
@ -1879,8 +1880,9 @@ if(InStr(CurrentTabURL, "/login")){
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/SubScribeStar------------------------------- ; -------------------------------/SubScribeStar-------------------------------
@ -1984,6 +1986,10 @@ if(InStr(CurrentTabURL, "/login")){
IniWrite, Successful, %StatusFileFilePath%, Status, Telegram IniWrite, Successful, %StatusFileFilePath%, Status, Telegram
AddToTotalPostsPostedCount() AddToTotalPostsPostedCount()
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/Telegram------------------------------- ; -------------------------------/Telegram-------------------------------
@ -2207,12 +2213,15 @@ if(InStr(CurrentTabURL, "/login")){
IniWrite, Successful, %StatusFileFilePath%, Status, LinkedIn IniWrite, Successful, %StatusFileFilePath%, Status, LinkedIn
AddToTotalPostsPostedCount() AddToTotalPostsPostedCount()
DevModeMsgBox("done!") ; DevModeMsgBox("done!")
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/LinkedIn------------------------------- ; -------------------------------/LinkedIn-------------------------------
@ -2450,9 +2459,12 @@ if(InStr(CurrentTabURL, "/login")){
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/Minds------------------------------- ; -------------------------------/Minds-------------------------------
@ -2536,7 +2548,7 @@ if(InStr(CurrentTabURL, "/login")){
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000) Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){ if(Status){
SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; TakeScreenshotOfPage()
Return Return
} }
@ -2650,9 +2662,12 @@ if(InStr(CurrentTabURL, "/login")){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip") SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/Locals------------------------------- ; -------------------------------/Locals-------------------------------
@ -2763,9 +2778,11 @@ if(InStr(CurrentTabURL, "/login")){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip") SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/Gab------------------------------- ; -------------------------------/Gab-------------------------------
@ -3022,9 +3039,12 @@ if(InStr(CurrentTabURL, "/login")){
SaveOrPostProgress(Message:=Message,PostType:="Tooltip") SaveOrPostProgress(Message:=Message,PostType:="Tooltip")
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/Bastyon------------------------------- ; -------------------------------/Bastyon-------------------------------
@ -3214,9 +3234,12 @@ if(InStr(CurrentTabURL, "/login")){
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
;-----------------------/Steemit------------------------- ;-----------------------/Steemit-------------------------
@ -3343,7 +3366,6 @@ if(InStr(CurrentTabURL, "/login")){
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
@ -3475,10 +3497,13 @@ AddToTotalPostsPostedCount()
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/MeWe------------------------------- ; -------------------------------/MeWe-------------------------------
@ -3568,7 +3593,6 @@ status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength
if(Status){ if(Status){
Message = Failed to Input Post Message = Failed to Input Post
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging") SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; TakeScreenshotOfPage()
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
} }
@ -3627,9 +3651,11 @@ AddToTotalPostsPostedCount()
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/Twetch------------------------------- ; -------------------------------/Twetch-------------------------------
@ -3653,7 +3679,38 @@ if(Status){
Return Return
} }
SaveOrPostProgress(Message:="Inputting Text",PostType:="Tooltip,ErrorLoggingTextFile") 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 sleep, 1000
@ -3662,27 +3719,13 @@ Xpath = //input[@placeholder='Share whatever flotes your boat..']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000) Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=2000)
if(Status){ if(Status){
; if error, then try clicking on "Login" button at the top right ; if error, then try clicking on "Login" button at the top right
Message = Unable to Click "Write New Post" Button. Trying to Re-Login TabUrl := GetCurrentTabURlBase()
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging") Message = Unable to Click into New Post Box. Please check login status. Current URL: %TabUrl%
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Xpath = //div[@class='nav-action-button blue-link half-padding-left half-padding-right white-space-no-wrap'] ; Log in button
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){ ; if failed to click login button
SaveOrPostProgress(Message:="Post Failed: Check Login Status",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage() SaveDriverURLOFErrorPage()
Return Return
} ; SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
else, { ; if login button was clicked successfully. try logging in
sleep, 2000
Xpath = //button[@class='submit-button ng-star-inserted']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){ ; if failed to click login button, give error and quit
SaveOrPostProgress(Message:="Login Expired. Please log back in",PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
Return
}
Xpath = //div[@class='new-text-area'] ; start new post button
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=5,SleepLength:=1000)
}
} }
sleep, 1000 sleep, 1000
@ -3762,10 +3805,13 @@ AddToTotalPostsPostedCount()
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/Flote------------------------------- ; -------------------------------/Flote-------------------------------
@ -3954,12 +4000,15 @@ AddToTotalPostsPostedCount()
PauseBetweenPosts() PauseBetweenPosts()
; TakeScreenshotOfPage()
; dismiss the pop up that appears for some reason ; dismiss the pop up that appears for some reason
; try driver.switchToalert().accept() ; try driver.switchToalert().accept()
DevModeMsgBox("done!") DevModeMsgBox("done!")
Message = Submitted Successfully
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Return Return
; -------------------------------/ThinkSpot------------------------------- ; -------------------------------/ThinkSpot-------------------------------

@ -1 +1 @@
Subproject commit f39051ff5fd27550ef00d62d1bfaffcf2cf4a51b Subproject commit 296dd6eabffee3c8de0243cab988518fb822c83e
Loading…
Cancel
Save