As usual, load this in commit handler. window.handle_link_external can be called on its own - or by clicking such a link. Escapes ”@” !
(function() {
var run = Uzbl.run;
delete self.Uzbl;
var escape = self.escape;
var String_methods = {
replace: String.prototype.replace,
slice: String.prototype.slice,
match: String.prototype.match
};
window.handle_link_external = function(element) {
var protocol = element.protocol;
href = element.href;
href=href.replace("@", "\\@");
run("event LINK_" + protocol.toUpperCase().replace(":", " ") + href);
}
var protocol_handler = function(event) {
var element = event.target;
if (event.button === 0 && element.nodeName === "A") {
var protocol = element.protocol;
if (!String_methods.match.call(protocol, /^(https?|javascript):$/)) {
event.stopPropagation();
event.preventDefault();
window.handle_link_external(element);
}
}
};
window.addEventListener("click", protocol_handler, false);
})();
// vim: set noet ff=unix