Firebugの最新情報が追えるFirebug | Google グループを見ていると、Firefox3beta4くらいから最新版のFirefoxでうまく動くようにするのに手間取っているようで(先日紹介した$$1は1.2alphaでは使えなくなくなっちゃいました)ちょっと心配してたのですが、Firebugのコンソールがぜんぜん機能しないという大きな問題は乗り越えたみたいです。
ちなみにこのグループ、こないだhow to remove a cockroach from the right corner of browser? - Firebug | Google グループなんてアホな投稿(投稿した人はまじめにアイコンを変えたかったみたいですけど)が流れてきておもしろかったです。
$xは、DOM要素のリストしか返せなかったり、コンテキストを指定できなくて不便なので、いろんなハックがされてきました。
userchrome.jsにコードを書いていたのですが、いつの間にか機能しなくなっていました。だいぶんFirebugのコンソールまわりのコードも落ち着いて変更されなくなってきたみたいなのでパッチを書きました。Firebug1.2a24Xで動作を確認。

一部Nov 17 2007 :: New version of $X / nulog, NULL::something : out of the washerのコードを利用させてもらっています。ありがとうございます。
function executeOnReady(parentObject, props, f) {
var fn = props.reduceRight( function (callback, propname) {
return function (parentObject) {
if ( parentObject[propname] ) {
var newValue = parentObject[propname];
parentObject[propname] = callback(newValue) || newValue;
} else {
{
parentObject.watch( propname, function ( name, oldValue, newValue ) {
unwatch(parentObject, name);
return callback(newValue) || newValue;
} );
}
}
};
}, f);
fn(parentObject);
}
executeOnReady(window, ['FBL', 'getElementsByXPath'], function(newvalue) {
return function(context, xpath) {
if ( arguments.callee.caller ) {
context = arguments.callee.caller.arguments[1] || context;
}
var doc = context.nodeType == context.DOCUMENT_NODE ? context : context.ownerDocument;
var result = doc.evaluate(xpath, context, null, XPathResult.ANY_TYPE, null);
var nodes = [];
// snippet from: http://lowreal.net/blog/2007/11/17/1
switch (result.resultType) {
case XPathResult.STRING_TYPE : return result.stringValue;
case XPathResult.NUMBER_TYPE : return result.numberValue;
case XPathResult.BOOLEAN_TYPE: return result.booleanValue;
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: {
for (var item = result.iterateNext(); item; item = result.iterateNext())
nodes.push(item);
return nodes;
}
}
}
return newvalue;
} );
トラックバック元エントリにこのエントリへのリンクがない場合はトラックバックを受け付けません。
http://labs.gmo.jp/mt/mt-tb.cgi/216
comments