Any userscript experts here?

statsman

Thinks s/he gets paid by the post
Joined
Apr 17, 2008
Messages
2,025
I have a website I would like to filter (not ER.org) using Greasemonkey. The structure of the html is as follows (simplified for this example):

<div class="a1">
{some stuff}
</div>

<div class="a2">
{some stuff}
</div>

Based on the occurrence of an URL within "a2" containing a string ("findString"), I would like to remove "a1" just prior to it.

var findDivs = $("div.a2 a:contains(findString)");
findDivs.parent().remove();

The above will remove "a2", but I can't seem to figure out how to remove "a1" instead. Any advice?
 
It appears the following works:

findDivs.parent().prev().remove();

I have zero training in this, so I suspect there may be better and cleaner ways to accomplish this task.
 

Latest posts

Back
Top Bottom