Skip to main content
2 of 5
edited title
ᔕᖺᘎᕊ
  • 4.4k
  • 2
  • 16
  • 37

Make your own custom "magic links" for comments!

There are loads of feature requests on Meta for adding specific 'magic links' to comments. (links that expand, eg. [edit] -> [edit](/posts/id/edit)).

So I made a userscript that allows you to create your own magic links to expand to your own custom URLs.

##Usage

At the top of the script, before the -------------------------------------- add either:

  • magicLinks['COMMAND LINK TEXT'] = 'URL'; or
  • magicLinksCustomText['COMMAND'] = "URL";

The difference is that the first one acts as the standard ones do (ie a simple [command]) but the second one allows you to have custom text (something that SE doesn't have). Note the syntax for this is different, as seen in the example below.

There are few placeholder variables you can use:

  • $ANSWERID - the current answer's ID
  • $QUESTIONID - the current question's ID
  • $BASEURL$ - the base URL of the site (eg. http://stackapps.com)
  • $METABASEURL$ - the meta base URL of the site (eg. http://meta.stackapps.com)

##Examples

  • magicLinks['edit/q Edit Question'] = '$BASEURL$/posts/$QUESTIONID$/edit';
  • [edit/q] --> [Edit Question](http://stackapps.com/posts/3421/edit)
  • magicLinksCustomText['edit/q'] = '$BASEURL$/posts/$QUESTIONID$/edit';
  • [Edit the question to add extra info][edit/q] --> [Edit the question to add extra info](http://stackapps.com/posts/3421/edit)

##Installation

Install the script from Github Gist or view the source here

##Notes

  • As this is client-side and only acting as a shortcut for bigger chunks of text: the character count will look at the expanded text and not the shortened one :(
ᔕᖺᘎᕊ
  • 4.4k
  • 2
  • 16
  • 37