Skip to content

Instantly share code, notes, and snippets.

@xulapp
Created February 23, 2010 14:40
Show Gist options
  • Save xulapp/312218 to your computer and use it in GitHub Desktop.
Save xulapp/312218 to your computer and use it in GitHub Desktop.
selectElementByMiddleClick.uc.js
// ==UserScript==
// @name selectElementByMiddleClick.uc.js
// @description DOM Inspector -> Select Element By Click
// @include chrome://inspector/content/inspector.xul
// @compatibility Firefox 3.*
// @namespace http://twitter.com/xulapp
// @author xulapp
// @license MIT License
// @version 2010/02/23 23:40 +09:00
// ==/UserScript==
(function selectElementByMiddleClick() {
var menuitem = document.getElementById('item:selectByClick');
menuitem.setAttribute('label', menuitem.getAttribute('label').replace('Click', 'MiddleClick'));
var codeForDOMViewer = '' + <><![CDATA[
eval('MouseDownListener.handleEvent = ' + MouseDownListener.handleEvent.toString().replace(
'if (aEvent.type == "mousedown")',
'if (aEvent.type == "mousedown" && aEvent.button == 1)'
));
]]></>;
var viewerFrame = document.getElementById('bxDocPanel');
eval('viewerFrame.notifyViewerReady = ' + viewerFrame.notifyViewerReady.toString().replace(
'{',
'{' + <><![CDATA[
try {
(function(doc) {
var script = doc.createElementNS('http://www.w3.org/1999/xhtml', 'html:script');
script.type = 'text/javascript';
script.appendChild(
doc.createTextNode(]]>{ uneval(codeForDOMViewer) }<![CDATA[)
);
doc.documentElement.appendChild(script);
doc.documentElement.removeChild(script);
})(this.viewerDocument);
} catch (e) {
}
]]></>
));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment