[Greasemonkey] Turnabout: More Greasemonkey for IE

Matthew Gertner matthew at allpeers.com
Wed Jun 1 16:33:30 EDT 2005


Gah, would suck not to be able to use XPath. Pathan supports full XPath and
is open source. I'd bet it wouldn't be *that* hard to write a backend that
uses MSHTML's DOM. That would be truly impressive.

Matt

> -----Original Message-----
> From: greasemonkey-bounces at mozdev.org [mailto:greasemonkey-
> bounces at mozdev.org] On Behalf Of Mark Pilgrim
> Sent: Wednesday, June 01, 2005 2:49 PM
> To: greasemonkey at mozdev.org
> Subject: Re: [Greasemonkey] Turnabout: More Greasemonkey for IE
> 
> On 5/31/05, chris feldmann <cfeldmann at gmail.com> wrote:
> >  How about the possiblility of an XPath translation layer? Most XPath
> > queries I've seen (and written) for greasemonkey are "ACTIVE QUERY,
> > document, null, standard format, null." Base functionality could be
> > replicated with (cringe) regular expressions on the query, am I wrong?
> The
> 
> <jwz>Now you have two problems...</jwz>
> 
> I've taken an inventory of all the scripts I've ever written
> (including several unreleased ones).  Granted this is not a
> representative sample, since I have a particular coding style,
> particular interests, etc.  Some of these could undoubtedly be
> rewritten without XPath, using the various document.foo properties and
> collections.  But here goes:
> 
> //*[@accesskey]
> //label[@for='some element name determined at runtime']
> //a[contains(@href, '?')]
> //head/title
> //table[@bgcolor='#e5ecf9']
> //form[@name='f']
> //form[@id='cf']//table//tr//table/tbody
> //th/ancestor::table
> //td/ancestor::tr
> //th|//td
> //html/@lang
> //input[@type='hidden']
> //img[@width='36'][@height='14']
> //img[contains(@src, 'MZZZZZZZ')]
> //input[@type='submit']
> //img[not(@alt)]
> //a[starts-with(translate(translate(@href, 'http:', ''),
> '.:abcdefghijklmnopqrstuvwxyz0123456789', ''),
> '//--')]/ancestor::p[@class='g']
> //a[@href='http://validator.w3.org/check/referer']
> //p[@class='g']
> //img[@width='1'][@height='1'][contains(@src, '?')]
> //a[@class='yschttl']
> //text()
> //*[@rel][@type][@href]
> //img[@alt]
> 
> All told, 37 scripts, of which 25 use XPath.  It is unlikely that a
> "simple" XPath-like compatibility library could faithfully reproduce
> all of these expressions.  But it is quite likely that I could rewrite
> most of them without using XPath.
> 
> --
> Cheers,
> -Mark
> _______________________________________________
> Greasemonkey mailing list
> Greasemonkey at mozdev.org
> http://mozdev.org/mailman/listinfo/greasemonkey



More information about the Greasemonkey mailing list