Get Discourse Forum Code Block & Post Info [TEST]

###MACRO:   Get Discourse Forum Code Block & Post Info [TEST]

~~~ VER: 1.1    2016-08-23 ~~~

####DOWNLOAD:
Get Discourse Forum Code Block & Post Info [TEST].kmmacros (38 KB)


2016-08-23 22:59 CT (Tue)

  • Fixed Date bug
  • Added Script Language as output

###This is a TEST

  • For those of you who like to try shiny new things, with minimal risk, please give this a try.
  • It is part of larger macro I'll be publishing soon.
  • Please post any/all feedback.

###Example Results

####Two Big Deals

  1. All of the data is returned in fields, so you can use as you like. (see below).
  2. This captures the Reply Post info (as opposed to the Topic/Page info) for Author, Date, & URL, which is hard to get.
    ###ReleaseNotes

Author.@JMichaelTX

HOW TO USE:

  1. Select, or mouse-over, text in a Code Block in a Discourse Forum
  2. Trigger this macro.

PURPOSE:

  • Auto-Select and Copy Entire Code Block on Web Page
  • Get Author and Post Date

RETURNS:

  • The following, separated by a vertical bar("|")
    * authorName
    * postDate
    * postURL
    * docTitle
    .

  • IF ERROR, you get a nice, friendly, error message.

    Example:

JMichaelTX|2016-08-23|https://forum.keyboardmaestro.com/t/why-do-we-code-jxa-scripts-using-closures/4739/12|Why do we code JXA scripts using closures? - general - Keyboard Maestro Discourse


1 Like

###Bug: Post Date is being converted to GMT when using this function:

dateNow.toISOString()

I thought it just converted to the ISO format (yyyy-mm-dd), but it also changes the time to zulu time!!!

Anyone know a better JavaScript function to just get the ISO format?

Just posted update.

Coming soon: An update using @DanThomas’ great JSON method for passing variable between JavaScript > KM > JXA.

Should be later today.