Am 27.05.2013 11:10, schrieb cc:
Grab a reference to the <div>, then set its style.display property to "none".

For example (untested):
var divFoobar = document.evaluate('//div[@class="foobar"]', document, null, typeXPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (divFoobar) {
  divFoobar.style.display = "none";
} else { /*complain*/ }

If you feel like it, you can actually delete the element, but most of the time that isn't needed.

I don't know why you would use that complicated code.
If you're not going to do anything with the element, there is no benefit from grabbing it, right? ;)

You could rather use the easy and failsafe:

GM_addStyle("div.foobar { display: none !important; }");

to hide them all. If you're going to remove the element, use

var divsFoobar = document.querySelectorAll("div.foobar");

to retrieve all foobar divs, or respectively

var divFoobar = document.querySelector("div.foobar");

to retrieve the first. No XPath needed here.

Chris

--
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