All pastes #159912 Raw Edit

Faux

public javascript v1 · immutable
·published 2006-09-03 17:34 UTC
rendered paste body
// ==UserScript==// @name Access keys// @author Faux// @namespace http://faux.uwcs.co.uk/// @version 0.1// @description Offers ctrl+alt+{specified key} links for the first 26 links on the page. May collide with shortcuts, woe.// add excluded sites here (if the script causes problems on those sites)// @exclude http://www.some.example.com/*// ==/UserScript==var prefix = 'zomgfaux';// On load, add all of the labels.window.opera.addEventListener('BeforeEvent.load',function (e){	if( e.event.target instanceof Document )	{		for( var i = 0; i < 26 && document.links[i]; i++ )			document.links[i].innerHTML = document.links[i].innerHTML + '<span style="display: none; padding: .5em; border: 2px dotted black; position: relative; z-index:24; top: 2px; left: 5px; background-color: #ffffe1; color: black" class="' + prefix + 'akey" id="' + prefix + i + '">' + String.fromCharCode(97 + i) + '</div>';		;	}}, false);// Grab our access key label by numbers.function get(i){	return document.getElementById(prefix + i);}// Set all our access key label's style.display to arg.function setall(st){	for (var i=0; i<26; i++)		get(i).style.display=st;}// Handle a key in our range being pressed.document.addEventListener('keyup', function(e){	if (!(e.ctrlKey && e.altKey))		return;	if (e.keyCode >= 65 && e.keyCode <= 91) // A-Z	{		get(e.keyCode - 65).parentNode.click();		e.preventDefault();	}}, false);// The magic combo was pressed, show the labels!document.addEventListener('keydown', function(e){	if (e.ctrlKey && e.altKey)		setall("");}, false);// Ctrl was released, hide, hide.document.addEventListener('keyup',function (e){	if (e.keyCode == 17) // e.ctrlKey not workey here?		setall("none");} ,false);