Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| def4d4d57b | |||
| e810133ff5 |
@@ -146,6 +146,27 @@ sleep, 500
|
|||||||
driver.FindElementByXPath(Xpath).SendKeys("`n`n")
|
driver.FindElementByXPath(Xpath).SendKeys("`n`n")
|
||||||
sleep, 500
|
sleep, 500
|
||||||
|
|
||||||
|
if(InStr(PostBody, "http")){
|
||||||
|
StrLengthOfPost := StrLen(PostBody)
|
||||||
|
|
||||||
|
SaveOrPostProgress(Message:="Body has hyperlink, Inputting text key by key",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
|
Loop % StrLengthOfPost{
|
||||||
|
|
||||||
|
Current_Char := SubStr(PostBody, A_index, 1)
|
||||||
|
|
||||||
|
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=1,SleepLength:=20,StringTextContent:=Current_Char)
|
||||||
|
if(Status){
|
||||||
|
Message = Failed to Input Text
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
SaveDriverURLOFErrorPage()
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else, {
|
||||||
|
SaveOrPostProgress(Message:="Body has no hyperlink, inputting entire text body into element.",PostType:="Tooltip,ErrorLoggingTextFile")
|
||||||
|
|
||||||
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostBody)
|
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostBody)
|
||||||
if(Status){
|
if(Status){
|
||||||
Message = Failed to input Post Body
|
Message = Failed to input Post Body
|
||||||
@@ -153,6 +174,8 @@ if(Status){
|
|||||||
SaveDriverURLOFErrorPage()
|
SaveDriverURLOFErrorPage()
|
||||||
Return
|
Return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
; check if value was input
|
; check if value was input
|
||||||
js = return document.querySelector("trix-editor[role='textbox']").innerText
|
js = return document.querySelector("trix-editor[role='textbox']").innerText
|
||||||
|
|||||||
153
Modules/Post-To-Substack.ahk
Normal file
153
Modules/Post-To-Substack.ahk
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
|
||||||
|
; -------------------------------Minds-------------------------------
|
||||||
|
PostToSubstack:
|
||||||
|
CurrentSite := "Substack"
|
||||||
|
Message = Navigating to Post Creationg Page
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IniRead, SubstackProfileURL, %SettingsIniFilepath%, SocialMediaPoster, SubstackProfileURL, %A_Space%
|
||||||
|
if(SubstackProfileURL = ""){
|
||||||
|
Message = SubstackProfileURL is blank. Please update Settings.ini under [SocialMediaPoster]`nSubstackProfileURL=https://PROFILENAME.substack.com/publish/home
|
||||||
|
IniWrite,%A_Space%,%SettingsIniFilepath%, SocialMediaPoster, SubstackProfileURL
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
URLAttempt := NavigateFromBaseURLTo(SubstackProfileURL)
|
||||||
|
if(URLAttempt = "Failed")
|
||||||
|
Return
|
||||||
|
|
||||||
|
Status := CheckCurrentTabForCurrentSite()
|
||||||
|
if(Status){
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
; Check Login Status
|
||||||
|
; ------------------------------------------------
|
||||||
|
Message = Checking Login Status
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip")
|
||||||
|
|
||||||
|
|
||||||
|
; Check for New Post button at the top right of page
|
||||||
|
Xpath = (//button[@id='trigger7'])[1]
|
||||||
|
try ElementInnerText := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text
|
||||||
|
if(!InStr(ElementInnerText, "New post")){
|
||||||
|
Message = New post button not found. Please check login status. If already logged in, the xpath of the element might have changed.
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
SaveDriverURLOFErrorPage()
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
; Start Text Post
|
||||||
|
; ------------------------------------------------
|
||||||
|
Message = Creating New Post
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
; click new post button
|
||||||
|
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||||
|
if(status){
|
||||||
|
Message = Failed to click New post button
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; click new note button in popup menu
|
||||||
|
Xpath = //div[contains(text(),'New note')]
|
||||||
|
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||||
|
if(status){
|
||||||
|
Message = Failed to click New note button
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; Input Title and Text
|
||||||
|
; ------------------------------------------------
|
||||||
|
|
||||||
|
; Input Text Box, this is awful and will probably break in the future, but works for now.
|
||||||
|
; @todo: Figure out relative xpath, SelectorHub is not providing anything useful.
|
||||||
|
Xpath = /html[1]/body[1]/div[4]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[1]
|
||||||
|
|
||||||
|
|
||||||
|
try, CurrentText := driver.findelementbyxpath(Xpath).Attribute("innerText") ;XPATH Inner Text
|
||||||
|
if(strlen(CurrentText) > 1){
|
||||||
|
Message = Exiting. Functionality to clear out previous failed posts is a WIP.
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
SaveDriverURLOFErrorPage()
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=PostTitleAndBody, ClearElement:=0)
|
||||||
|
if(Status){
|
||||||
|
Message = Failed to input Post Title/Body
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; Attach Image
|
||||||
|
; ------------------------------------------------
|
||||||
|
if(ImageAttachmentFilepath){
|
||||||
|
Message = Attaching Image
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
Xpath = (//input[@accept='image/*,.heic'])[1]
|
||||||
|
|
||||||
|
; Attach image
|
||||||
|
Status := Selenium_LoopToSendValueToXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000,StringTextContent:=ImageAttachmentFilepath, ClearElement:=0)
|
||||||
|
if(status){
|
||||||
|
Message = Failed to attach image
|
||||||
|
SaveOrPostProgress(Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; driver.FindElementByXPath(Xpath).SendKeys(PostTitleAndBody)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sleep, 1000
|
||||||
|
|
||||||
|
|
||||||
|
if (ConfirmBeforeSubmit && ConfirmBeforeSubmitMsgboxFunc() != true) {
|
||||||
|
Message = User Selected STOP button when asked for confirmation. Cancelling Rest of Site Upload.
|
||||||
|
SaveOrPostProgress(Message:=Message, PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Xpath = //button[normalize-space()='Post']
|
||||||
|
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
|
||||||
|
if(status){
|
||||||
|
Message = Failed to Click Post Now Button
|
||||||
|
SaveOrPostProgress(Message,PostType:=",ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
IniWrite, Successful, %StatusFileFilePath%, Status, %CurrentSite%
|
||||||
|
AddToTotalPostsPostedCount()
|
||||||
|
|
||||||
|
PauseBetweenPosts()
|
||||||
|
DevModeMsgBox("done!")
|
||||||
|
|
||||||
|
Message = Post Publish Successful
|
||||||
|
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||||
|
|
||||||
|
|
||||||
|
Return
|
||||||
|
; -------------------------------/Minds-------------------------------
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
[Social-Media-Poster]
|
[Social-Media-Poster]
|
||||||
Version=2.95
|
Version=2.96
|
||||||
|
|||||||
Reference in New Issue
Block a user