Forum Hacks • Raw Quote Button • You Can Help!

Forum Hacks • Raw Quote Button • You Can Help!
0

#1

Just a little functionality hack that I felt was missing from the forum — quoting the raw (Markdown) content of a post. Use cases include:

  • Viewing the code when someone tries to post their solution to an HTML challenge and forgets to enclose in backticks
  • Quoting someone’s post without ruining the existing formatting
  • Finding out how someone created a cool Markdown or HTML effect like this :wink:

Repo

How to Use

  1. Install Tampermonkey (link to Chrome version) or your userscript manager of choice.
  2. Add the code from raw_quoter.js as a userscript.
  3. Refresh the freeCodeCamp forum and you should now see Raw Quote buttons next to every post.

Screenshot

How Can I Help?

Several ways:

  • Post feedback in this thread — is this actually useful? What would make it better? What other forum hacks would you like to see?
  • Open issues on GitHub if you encounter bugs.
  • Help optimize the code. At the moment, it’s hacky, not performant, and UX isn’t great either (there’s a bug that prevents the post preview from immediately displaying/updating).
  • Create more userscripts for different hacks (I’ve left the scope of the repo pretty broad and I’m happy to include anything that works and is useful).

For the last two items, please start by checking and opening issues on the repo to make sure people don’t end up repeating the same work.

Enjoy!


#2

When you click “Raw Quote” it should trigger a click on “Reply” (opening the reply box) and then placing the quote inside it.

let replyBtn = document.querySelector(".actions .reply");
replyBtn.click();
// Wait for reply box to open
let textarea = document.querySelector("d-editor-input");
textarea.value = reply;

#3

Great idea! Implemented like this:

document.querySelector(`#post_${postNumber} .actions .reply`).click();

setTimeout(function() {
  const replyBox = document.querySelector('.d-editor-input');
  replyBox.value = replyBox.value ? `${reply}\n\n${replyBox.value}` : reply;
}, 50);

Due to simulating that click on the Reply button of the relevant post, it also differs from the current Quote functionality in that it classifies your post as a reply to that message.

I’m not a fan of that setTimeout, though… I guess there’d be a better way to do it with promises?

There’s also a minor bug in that the post preview doesn’t immediately display/update. I’m assuming this is due to some implementation detail of the forum software, but I’m not sure how to get around it.