var getMatchedTextNode = function(text, target) { return document.evaluate( 'descendant::text()[contains(., "' + text.replace(/"/g, '\\"') + '")]', target || document.body, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; }http://subtech.g.hatena.ne.jp/secondlife/20091118/1258554379