There are [loads of feature requests on Meta](http://meta.stackexchange.com/questions/tagged/feature-request+magic-links?sort=newest&pageSize=50) 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](https://gist.github.com/shu8/991e94da2cec412be603/raw/d8e3faf3b891fa1b523d479f8a12b7e3762094a9/SE-Custom-Magic-Links.user.js) or view the source [here](https://gist.github.com/shu8/991e94da2cec412be603)

##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 :(