Opera Link Numbering
Since Opera doesn’t seem to support link numbering, and I wanted the same behaviour I have in Elinks – numbered links for easy keyboard navigation – I searched for it.
The only useful source was a userjs, numbered links script for Opera, but I didn’t like the behaviour. I don’t want to have to use a opera nickname for it as a shortcut, and I want to toogle it.
I’m not really familar of the userjs possibilites Opera offers, but I rewrote it quickly for my use:
// ==UserScript==
document.addEventListener("keypress",shortcut,false);
function shortcut(e){
if(e.keyCode==78 && e.ctrlKey && e.shiftKey){ //shift ctrl n
if (document && document.body) {
var db = document.body;
linksLijst = new Array();
var links = document.getElementsByTagName("a");
var i;
for(i = 1; i <= links.length; i++) {
linksLijst[i-1] = links[i-1].href;
var linkLabel = document.createElement("span");
linkLabel.className = "linkLijstNummer";
linkLabel.appendChild(document.createTextNode(i));
links[i-1].insertBefore(linkLabel, links[i-1].firstChild);
//links[i-1].parentNode.insertBefore(linkLabel, links[i-1]);
}
}
}
if (e.keyCode==79 && e.ctrlKey && e.shiftKey) { //shift ctrl o
lnk=parseInt(prompt("Open:"));
if (lnk > 0 && lnk <= linksLijst.length) {
top.location.href = linksLijst[lnk-1];
}
}
}
This is quite ugly, and there are probably a ton of better ways to achieve this, but I’m too lazy for that. As you can see the keybinding is Ctrl-Shift-N to number the links and Ctrl-Shift-O to open a link.
Feel free to post your changes (eg. a binding to hide the numbers again) in the comments :)