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';
ormagicLinksCustomText['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](https://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](https://stackapps.com/posts/3421/edit)
Installation
Install the script from Github Gist or view the source here.
Note: To install, you must first have a userscript management extension installed. The popular ones are Greasemonkey (for Firefox) and Tampemonkey (for Chrome). Once they are installed, simply clicking the 'install from Github gist' link above will install the script - the extension will handle everything else. More info on userscripts and their usage over 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 :(