Every once in a while, I want to reply to a forum post part by part. For the common BBCode forums, doing this manually is a tedious matter of repeatedly typing and/or copy-and-pasting
[/QUOTE] tags. An obvious candidate for automation.
I figured the best vehicle for this piece of magic would be a bookmarklet.
I can initiate a quoted reply, put “-snip-” or “-s-” wherever I want a word in, and then run the bookmarklet. It will insert the appropriate start and end tags, including any attributes to the start tag (e.g.
[QUOTE from="Squid"]), newlines to make room for my reply (after first removing superfluous whitespace around the snip point), and then put the caret in the first such slot.
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9 10 11
with the caret automagically placed after the first quotation.
I have the Firefox bookmark keyword “quote” tied to the bookmarklet, meaning I can type that in the address bar and hit ↩ to run it.
Right-click this link and bookmark it: Break up BBCode quote.
Formatted for readability:
1 2 3 4 5 6 7 8 9 10
This code makes the (rather safe, I think) assumption that you only care about the first textarea on the page. Modify to taste.
setSelectionRange() – to move the caret – is Gecko (Firefox) specific, so some modifications are necessary if you want to use this with some other browser.