firefox - counting jquery script tags with xpath -
i want use document.evaluate expression in userscript able detect presence (or absence) of existing jquery library in document head, part of developing jquery wrapper userscripts work in firefox , chrome, , not conflict other libraries (what i'm hoping insert library , jquery code, if necessary, before other script tags , have them run in no conflict mode.)
long story short, statement not appear work:
jqueryscript = document.evaluate("//*script[contains(@src, 'jquery')]", document.head, null, xpathresult.ordered_node_snapshot_type, null);
when try test if jqueryscript.snapshotlength > 0, script fails. incredibly new @ xpath please me understand this.
jqueryscript = document.evaluate ("//script[contains (@src, 'jquery')]", document.head, null, xpathresult.ordered_node_snapshot_type, null);
should work.
but note on sites (like so) yield false hits.
eg:
<script ... src="http://engine2.adzerk.net/z/8277/adzerk2_2_17_45?keywords=jquery,firefox,google-chrome,xpath,greasemonkey,x-user-registered,x-5000plus-rep">
so,
jqueryscript = document.evaluate ("//script[contains (@src, '/jquery')]", document.head, null, xpathresult.ordered_node_snapshot_type, null);
might better.
Comments
Post a Comment