Created
April 3, 2009 18:51
-
-
Save satyr/89895 to your computer and use it in GitHub Desktop.
Shows accesskey-ed elements on the current page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.CreateCommand({ | |
name: 'accesskeys', | |
description: 'Shows accesskey-ed elements on the current page.', | |
author: 'satyr', license: 'X', | |
icon: 'chrome://ubiquity/skin/icons/text_underline.png', | |
execute: function(){}, | |
preview: function(pb){ | |
var {top} = context.focusedWindow | |
if(top.document.contentType == 'application/vnd.mozilla.xul+xml') | |
return void this.previewDefault(pb) | |
var {href} = top.document | |
if(this._last === (this._last = href) && | |
pb.querySelector('.'+ this.name)) return | |
var dl = <dl class={this.name}/> | |
for each(var {document} in [top].concat(Array.slice(top.frames))){ | |
if(document.URL == 'about:blank') continue | |
var ul = <ul/> | |
for each(var x in Array.slice(document.querySelectorAll('[accesskey]'))) | |
ul.appendChild(<li> | |
<kbd>{x.getAttribute('accesskey')}</kbd> | |
<em>{x.type || x.nodeName}</em> | |
{Utils.ellipsify(x.value || x.textContent || '', 20)} | |
</li>) | |
dl.appendChild(<> | |
<dt><nobr>{document.title}<wbr/> | |
<small>{document.URL}</small></nobr></dt> | |
<dd>{'li' in ul ? ul : 'N/A'}</dd> | |
</>) | |
} | |
pb.innerHTML = this._style + dl | |
}, | |
_style: <style><![CDATA[ | |
ul {list-style:none; padding:0} | |
dt {overflow:hidden} | |
dd {margin-left:1em} | |
kbd { | |
text-transform:uppercase; text-decoration:underline; | |
font:bold 111% monospace} | |
]]></style>.toXMLString(), | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment