nilsonrdg

Script to backup and move posts from steemit to another blog

Feb 28th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.61 KB | None | 0 0
  1. /*
  2. There's some problem in posting this in AutoHotkey forum, so I'm posting here
  3.  
  4. This script allows you to backup and move steemit posts to another blogging platform (blogspot or wordpress, for example).
  5.  
  6. Maybe because you want to monetize your content longer, or because steemit is not really a good blogging platform (it isn't easy for visitor navigate through blog posts, or see a list of links of posts, or widgets, statistics etc.
  7.  
  8. To use the script you need to do the following:
  9.  
  10. 1 - Change the variable: BlogUrl
  11.  
  12. 2 - Press "Control Alt i" to initiate the script
  13.  
  14. 3 - Insert new blog content:
  15.  
  16. Control Alt T => to paste post title (para inserir o título da postagem)
  17. Control Alt V => to paste post content (para colar o text da postagem)
  18. Control Alt K => to paste tags (para inserir as palavras chave)
  19. Control Alt R => to reload (para recarregar)
  20. */
  21.  
  22.  
  23. ; Change to the blog new post URL | Mude para o endereço para inserir novo post do blog
  24. BlogUrl=yourblognewposturl
  25.  
  26. /*
  27. This script is useful if you want to post your best steemit posts to other place, maybe where you can monetize it for longer.
  28. It also backups your posts.
  29.  
  30. Este script é útil se você quer postar seus melhores posts do steemit em outro lugar, talvez onde você pode monetizá-lo por mais tempo.
  31. Ele também faz backups dos seus posts.
  32.  
  33. Hotkeys (Atalhos):
  34.  
  35. Control Alt T => to insert post title (para inserir o título da postagem)
  36. Control Alt V => to paste post content (para colar o text da postagem)
  37. Control Alt K => to insert tags (para inserir as palavras chave)
  38. Control Alt R => to reload (para recarregar)
  39.  
  40. */
  41.  
  42.  
  43. HotKeys=
  44. (
  45. Hotkeys (Atalhos):
  46.  
  47. Control Alt T => to insert post title (para inserir o título da postagem)
  48. Control Alt V => to paste post content (para colar o text da postagem)
  49. Control Alt K => to insert tags (para inserir as palavras chave)
  50. Control Alt R => to reload (para recarregar)
  51. )
  52.  
  53. tooltip, ...`nPress "Control Alt i" to initiate the script`n`nPressione "Control Alt i" para iniciar o script`n, 480,250
  54. sleep, 8000
  55. tooltip,
  56.  
  57. ^!i::
  58. tooltip, ...`nCopy the steemit post URL!`n`nCopie o endereço da postagem!`n, 480,250
  59.  
  60. Clipboard=
  61.  
  62. Clipwait
  63.  
  64. SteemitURL := Clipboard
  65.  
  66. FileName:=RegExReplace(SteemitURL,".+\/","")
  67.  
  68. Link = <br><i><a href="%SteemitURL%" target="%FileName%">Veja também no Steemit</a></i><br><br>
  69.  
  70. tooltip, Wait`, ...`nwhile the post is loaded...`n`nAguarde enquanto o post é carregado..., 480,250
  71.  
  72. ; Creates an Internet Explore COM object
  73. ie := ComObjCreate("InternetExplorer.Application")
  74.  
  75. ; Navigate to a website
  76. ie.navigate(SteemitURL)
  77.  
  78. ; This ensures the webpage completely loads before doing anything else
  79. while ie.ReadyState != 4
  80. Sleep, 100
  81.  
  82. ; Shows the actual internet explorer window
  83. ie.visible := true
  84.  
  85.  
  86. htmlTagsFull := ie.document.getElementsByClassName("TagList__horizontal")[0].innerHTML
  87. TagsSteem := RegExReplace(htmlTagsFull, "<.+?>", ",")
  88. TagsSteem := RegExReplace(TagsSteem, "^\,", "")
  89.  
  90. PageTitle := ie.document.getElementsByTagName("title")[0].innerHTML
  91.  
  92. TagsSteem:=RegExReplace(TagsSteem,"\s","")
  93. TagsSteem:=RegExReplace(TagsSteem,"\,+",",")
  94.  
  95.  
  96. PageTitle := RegExReplace(PageTitle,"— Steemit","")
  97.  
  98. FileContents := ie.document.getElementsByClassName("PostFull__body entry-content")[0].innerHTML
  99.  
  100. FileContents = %FileContents%%Link%
  101.  
  102. FileContents := RegExReplace(FileContents,"title=""This link will take you away from steemit.com""","target='_blank'")
  103.  
  104. FileContents := RegEXReplace(FileContents,"class=""MarkdownViewer Markdown""","")
  105. FileContents := RegEXReplace(FileContents,"rel=""nofollow noopener""","")
  106.  
  107. FileContents := RegEXReplace(FileContents,"<div >","<div>")
  108. FileContents := RegEXReplace(FileContents,"class=""text-justify""","align='justify'")
  109. FileContents := RegEXReplace(FileContents,"class=""pull-left""","align='center'")
  110. FileContents := RegEXReplace(FileContents,"class=""pull-right""","align='center'")
  111. FileContents := RegEXReplace(FileContents,"class=""text-center""","align='center'")
  112.  
  113.  
  114.  
  115. StringReplace, FileContents, FileContents,<center>,<center>, UseErrorLevel
  116. Occurrences01 = %ErrorLevel%
  117. StringReplace, FileContents, FileContents,</center>,</center>, UseErrorLevel
  118. Occurrences02 = %ErrorLevel%
  119.  
  120. if (Occurrences01=Occurrences02 and Occurrences01<>0 and Occurrences02<>0)
  121. {
  122. FileContents := RegEXReplace(FileContents,"<center>","<div align='center'>")
  123. FileContents := RegEXReplace(FileContents,"</center>","</div>")
  124.  
  125. ;msgbox, Center tags replaced by Div tags - %Occurrences02% of %Occurrences01%
  126. tooltip, ...`nCenter tags replaced by Div tags - %Occurrences02% of %Occurrences01%
  127. sleep, 1000
  128. }
  129.  
  130.  
  131. ; Removing special characters that windows doesn't allow in file names
  132. FileName := RegExReplace(PageTitle,"\:|\*|\/|\||\\|<|>|""|\?","")
  133. PreviewFile = %A_ScriptDir%/%FileName%.htm
  134.  
  135. if FileExist(PreviewFile)
  136. {
  137. msgbox, File exists! Script will be restarted!
  138. ie.quit
  139. reload
  140. }
  141.  
  142.  
  143. FileAppend, %PageTitle%`n`r`n`r%FileContents%, %PreviewFile%
  144.  
  145. ; Quits out of the application.
  146. ie.quit
  147.  
  148.  
  149. tooltip, => Press Esc to skip this note`n`n%HotKeys%`n,300,100
  150. keywait, Esc, D
  151. tooltip,
  152.  
  153.  
  154. ;MsgBox, 4,, Would you like to open the blog editor? (press Yes or No)
  155. ;IfMsgBox Yes
  156. run, %BlogURL%
  157.  
  158. return
  159.  
  160.  
  161. ^!T::
  162. Clipboard := PageTitle
  163. send ^v
  164. tooltip,
  165. return
  166.  
  167.  
  168. ^!v::
  169. Clipboard := FileContents
  170. send ^v
  171. return
  172.  
  173.  
  174. ^!K::
  175.  
  176. InputBox, UserInput, HotKeys, Edit the tags, , 640, 200,,,,,%TagsSteem%
  177.  
  178. Clipboard = %UserInput%
  179.  
  180. send, ^v
  181. return
  182.  
  183. ^!R::
  184. reload
  185. return
  186.  
  187.  
  188.  
  189. ; Hotkeys for editing the code if it is needed
  190.  
  191. ^!m::
  192. send, <!--more-->
  193. return
  194.  
  195. ^!j::
  196. send, <div align="justify">
  197. return
  198.  
  199. ^!b::
  200. send, target="_Blank"
  201. return
Advertisement
Add Comment
Please, Sign In to add comment