Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 89478b3ded | |||
| def4d4d57b | |||
| e810133ff5 |
@@ -508,6 +508,7 @@ Gui, Add, Checkbox, y+7 vPocketNet Checked%PocketNetCheckStatus% , Bastyon
|
||||
Gui, Add, Checkbox, y+7 vGettr Checked%GettrCheckStatus% gUpdateVars, Gettr
|
||||
Gui, Add, Checkbox, y+7 vMeWe Checked%MeWeCheckStatus% gUpdateVars, MeWe
|
||||
Gui, Add, Checkbox, y+7 vTumblr Checked%Tumblr% gUpdateVars, Tumblr
|
||||
Gui, Add, Checkbox, y+7 vSubstack Checked%Substack% gUpdateVars, SubStack
|
||||
|
||||
|
||||
Gui, Font, Bold
|
||||
@@ -653,6 +654,7 @@ GuiControl,,Bastyon, 0
|
||||
GuiControl,,Gettr, 0
|
||||
GuiControl,,MeWe, 0
|
||||
GuiControl,,Tumblr, 0
|
||||
GuiControl,,Substack, 0
|
||||
Return
|
||||
|
||||
UpdateVars:
|
||||
@@ -799,6 +801,7 @@ IniWrite, %ShowTooltipProgress%, %SettingsIniFilepath%, SocialMediaPoster, ShowT
|
||||
(Gettr = 1)?(PostedWebsites .= "Gettr|") : ()
|
||||
(Steemit = 1)?(PostedWebsites .= "Steemit|") : ()
|
||||
(Tumblr = 1)?(PostedWebsites .= "Tumblr|") : ()
|
||||
(SubStack = 1)?(PostedWebsites .= "SubStack|") : ()
|
||||
|
||||
Message = Starting SMP with: **V%ScriptVersion%** `nTo sites: %PostedWebsites% `nWith Title: **%PostTitle%** `nWith Body:%PostBody% `nWith Tags: %PostTags%
|
||||
SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
@@ -876,6 +879,10 @@ Gosub, PostToPocketNet
|
||||
if(Gettr)
|
||||
Gosub, PostToGettr
|
||||
|
||||
if(SubStack)
|
||||
Gosub, PostToSubStack
|
||||
|
||||
|
||||
CurrentSite :=
|
||||
Message = Social Media Posting Complete
|
||||
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
|
||||
@@ -981,6 +988,9 @@ Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Bastyon%
|
||||
Gui, Add, Button,x%MarginSize% w%WebsiteButtonWidths% h%ButtonHeights% Center, Tumblr
|
||||
Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %Tumblr%
|
||||
|
||||
Gui, Add, Button,x%MarginSize% w%WebsiteButtonWidths% h%ButtonHeights% Center, SubStack
|
||||
Gui, Add, Edit, x+5 w%WebsiteStatusEditWidths% h%ButtonHeights%, %SubStack%
|
||||
|
||||
|
||||
; Gui, Font, s9
|
||||
/*
|
||||
@@ -1075,6 +1085,10 @@ Return
|
||||
;------------------------------------------------
|
||||
#include %A_ScriptDir%\Modules\Post-To-Tumblr.ahk
|
||||
|
||||
; SubStack
|
||||
;------------------------------------------------
|
||||
#include %A_ScriptDir%\Modules\Post-To-Substack.ahk
|
||||
|
||||
|
||||
; Minds
|
||||
;------------------------------------------------
|
||||
|
||||
@@ -146,6 +146,27 @@ sleep, 500
|
||||
driver.FindElementByXPath(Xpath).SendKeys("`n`n")
|
||||
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)
|
||||
if(Status){
|
||||
Message = Failed to input Post Body
|
||||
@@ -153,6 +174,8 @@ if(Status){
|
||||
SaveDriverURLOFErrorPage()
|
||||
Return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
; check if value was input
|
||||
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]
|
||||
Version=2.95
|
||||
Version=2.99
|
||||
|
||||
Reference in New Issue
Block a user