Re: [greasemonkey-users] Changing HTML code (NOT CSS) possible? Addressing NESTED,INNER

Mon, 04 Feb 2013 10:41:09 -0800

On 2/2/13 5:33 PM, LWChris@LyricWiki wrote:
Am 03.02.2013 01:49, schrieb Brian L. Matthews:

Solution for 2.) is maybe not so easy, because all methods I know don't care about the element's level, so you'd have to find out which level your table-node has on your own. How dynamical is your target page, is the second level table's tag always the second <table>-tag on the page or something like that?

I use XPath a lot for this sort of thing. For example, something like /html/body/table/tbody/tr/td/table (I haven't tried that, but it should be close) will select the second level tables in the example HTML. The path would need tweaking for the actual page, but the concept would be the same.

Brian


Yes, that's not the problem, but depending on how differently the page is rendered, there might be various and changing elements between body and the first level table, which makes it so difficult. Personally, if I know I'll use my script in Firefox only, I prefer CSS selectors over XPath, for example:

document.querySelector("div#content table.navigation ul li.active span");

I agree, I was just offering one possible technique. XPath, CSS selectors, and just traversing the DOM using JavaScript are all dependent on the layout of the page and vulnerable to changes in that layout. I've used all of the above on different pages, and often more than one, depending on the page, how dynamic it is, and what sorts of techniques the page designer used.

Brian

--
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to