Search Results

Search found 1 results on 1 pages for 'xpathengines'.

Page 1/1 | 1 

  • Merging getComputedStyle and evaluate in Greasemonkey

    - by Keheliya Gallaba
    I need to get all the text nodes with a certain font-face in a page to an array. I tried.. textnodes = document.evaluate("//* [@style='font-family: foo;']//text()[" + "not(ancestor::script) and not(ancestor::style)]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); and textnodes = document.evaluate("//* [@face='foo']//text()[" + "not(ancestor::script) and not(ancestor::style)]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); But these does not work with pages that is styled by external CSS files. Seems getComputedStyle() is the way to go. I think what I need is something like.. var tags = document.getElementsByTagName('*'); for (var i in tags) { var style = getComputedStyle(tags[i], ''); if (style.fontFamily.match(/foo/i)) { textnodes.push(tags[i]); } } But text nodes were not returned in this method. Is there anyway I can use a hybrid of xpath evaluate() and getComputedStyle() or any other way to achieve this?

    Read the article

1