Need Web Clipper for Discourse Post


#1

###Need Web Clipper for Discourse Post

Hi all. I need a tool (JavaScript, Keyboard Maestro, etc) that will easily clip the following information from a Discourse post (not Topic) when I either hover over the post, or select some text in the post:

  1. URL of the post
  2. Date of the post
  3. Author of the post
  4. Copy as rich text all of the post to the clipboard
  5. Topic Title

I plan to build this tool if I need to, but I thought I would first ask if anyone knows of such a tool, or anything similar?
I would love to get even JavaScript snippets that provide any part of the data I want.

This tool is for use by any user.

All ideas appreciated.

I have done considerable searching, both here and on the Internet in general, and have been unable to find anything relevant/helpful.


(Jeff Atwood) #2

I would start by setting your browser or HTTP request agent to the google web spider agent. Because we present simple 1996 era content to those kinds of webcrawlers to make crawling easier.


#3

Thanks for the suggestion, but I don’t have a clue as to how to do this.

A google search turned up this page, which talks about the web spider, but NOT about how to use it, or how to “set your browser” to it:

Googlebot

Can you please point me in the direction of how to use “the google web spider agent.”.

Thanks.


(Jeff Atwood) #4

Sure, look for a browser plugin that lets you change the user agent.


#5

I have made good progress in building this tool in JavaScript using Xpaths.

But I need a way to detect if the current web page is powered by Discourse.
I need something I could search for using JavaScript that would identify it as Discourse.

Any suggestions?


(Mittineague) #6

If it’s only for your site using the “href.location” property should work.

If for any Discourse site, AFAIK the only place that consistently exposes the string “discourse” is several tags in the head section.


#7

Thanks.

I figured it out on my own:

The Discourse forum page has this meta data:

<meta name="generator" content="Discourse 1.7.0.beta4 - https://github.com/discourse/discourse version 25a82e7d22d9eb2567c9b9e738049050e8e7434d">

So, I use this code to check for a “Discourse” web page:

  //--- DETERMINE FORUM SOFTWARE ---
  
  var metaGen = document.querySelector('meta[property="generator"]');
  var contentStr = metaGen.getAttribute("content");

if (contentsStr.match(/discourse/i)) {
	var forumName = "Discourse";
}

`