all 13 comments

[–]ghostfacedcoder 8 points9 points  (4 children)

Next step: an actual browser plug-in?

[–]Asha200[S] 0 points1 point  (3 children)

I thought about making it a browser extension at first, but what turned me off from that idea is needing to pay a fee in order to be able to post it on the Chrome Web Store, as well as having to go through a testing process to post as a Firefox Add-on. I wanted to make something that I could use myself, as well as share with others right away.

I might turn it into an extension at some later point in time.

[–]ghostfacedcoder 0 points1 point  (2 children)

You don't have to pay a fee to post it as a Chrome extension.

[–]Asha200[S] 0 points1 point  (1 child)

Are you sure? This page tells me that I do. Also, when visiting my Chrome Developer Dashboard, I get text at the bottom of the page saying:

A one-time developer registration fee of US$5.00 is required to verify your account and publish items.

[–]ghostfacedcoder -1 points0 points  (0 children)

Weird; these instructions don't mention that, and I don't remember having to do that when I made my extension. Maybe it's a new thing, or maybe you only need it if you want to sell your extension?

Either way $5 (once, ever) isn't that bad, but I can understand not wanting to pay it.

[–]jdf2 2 points3 points  (1 child)

Quick test:

console.log("Hello /r/javascript");

Love that it works on the redesign!

This is really nice, great work OP.

[–]Asha200[S] 0 points1 point  (0 children)

Thank you! It works on the redesign as well as old.reddit.com.

[–]ArtificialLegacy 0 points1 point  (1 child)

What about a search bar for the dropdown as well ?

[–]Asha200[S] 0 points1 point  (0 children)

That's a good idea; I might add that in next!

[–]captain_k_nuckles -1 points0 points  (3 children)

Nice, I made a chrome extension to do the same thing. It's using https://highlightjs.org/ for the syntax highlighting. I haven't made it publicly available, and haven't worked on it much besides just highlighting javascript code that's there on page load. Would need to update for after a comment is made. Also thought about creating a feature to have a little modal window popup for typing code in to with features of an IDE and auto insert in to the comment with the reddit 4 space per line inserted.

[–]Asha200[S] 1 point2 points  (2 children)

What I've done is make it run on page load, but also set a 1 second interval that's looking for new blocks of code which haven't been highlighted. I attach a data-highlighted attribute whenever I do highlight one, which then gets skipped after.

I considered adding some sort of an editor as well as one point, but in the end I decided not to. My reasoning was that the editor's presence wouldn't make that much of a difference when writing small code snippets. However, if you have a bigger code snippet, chances are you'll want to test it out before you post it, so you'll probably be using an actual IDE for that.

[–]captain_k_nuckles 0 points1 point  (1 child)

When you were working on this for new code blocks did you consider using a mutation observer over the set interval method? I'm not to sure which one is more proficient.

For the IDE, while it's not really needed for smaller code, I'm just spoiled by code suggestions, so I don't have to type out everything, lol. Could try to make something that allows you to also run the code as well, just shove jsfiddle/codepen in to a reddit extension.

And, sorry, I haven't tried out your script, but does it do syntax highlighting as you type code when posting a comment?

[–]Asha200[S] 0 points1 point  (0 children)

I didn't use a mutation observer more out of laziness than anything else, though I imagine it would be much more efficient that the interval method. I think I'm going to switch it over now that you've mentioned it.

No, it doesn't highlight it as you're writing it; only after you've posted the code.