// ==UserScript==
// @name Link Code Insert
// @namespace http://www.openjs.com/
// @description Inserts the HTML code for creating a link at the active element location when the user presses Ctrl+Alt+A
// @include *
//by Binny V A (http://www.openjs.com/)
//Versions : 1.00.A
// ==/UserScript==
function linkCodeInserter(element) {
// If the selection is empty
if(element.selectionStart == element.selectionEnd) {
element.value += '';
element.selectionStart = element.selectionEnd = element.value.length - 6;// The length of [">]
} else {
// Get the selected text.
var text_to_selection = element.value.substr(0, element.selectionStart);
var text_in_selection = element.value.substr(element.selectionStart, element.selectionEnd - element.selectionStart);
var text_after_selection = element.value.substr(element.selectionEnd);
element.value = text_to_selection + '' + text_in_selection + '' + text_after_selection;
element.selectionStart = element.selectionEnd = text_to_selection.length + 9;// The length of [