I thought it would be nice to open a resource from the web inspector sidebar in directly TextMate instead of the web inspector source view, but adding
<script type="text/javascript" charset="utf-8">
window.onload = function() {
var links = document.getElementsByTagName("a");
for (var i=0;i<links.length;i++) {
if(links[i].className==="webkit-html-resource-link") {
links[i].addEventListener('click',function(e) {
console.log('openInTextmate', e);
e.preventDefault();
var tmLocation = 'txmt://open/?url=' + e.target.href;
window.location = tmLocation;
},false);
}
};
};
</script>
to the inspector.html didn’t work. The event listeners are added but never fired. Does somebody have some experience of why this could be like this?
the problem is that the click event propagation is stopped before the event reaches your handler. This happens in WebInspector.documentClick(inspector.js):
http://codesearch.google.com/codesearch/p?hl=en#OAMlx_jo-ck/src/third_party/WebKit/WebCore/inspector/front-end/inspector.js&q=WebInspector.documentClick&exact_package=chromium&l=728
I believe you can put your code directly into WebInspector.documentClick to make it work for now. It also sounds like a good feature request for inspector extension API.