How would I remove a DIV if there are no IDs using Greasemonkey?

I am wanting to remove two <div>s from a page (hide and collapse the space).

I was initially going to use Greasemonkey and remove based on ID - but these don't seem to have IDs. Secondly - I am assuming the contents of the iframe change (as this is a content banner).

How would I go about making these disappear? :)

<div style="float: left; width: 700px; height:250px; margin-top:5px; margin-bottom:10px;">
<iframe src='' style='position:relative;top:0px;left:0px;height:272px;width:756px;' frameborder=0 scrolling='no'></iframe>

<div style="background: url('/images/styles/prometheus/black-30.png'); border:1px solid #333333; border-radius: 10px; float: right; margin-top:5px; margin-right: 2px; padding:10px 12px; width:300px; height: 250px;">

<!--Replica Movie Props – 9-->
<!--Screen Used Movie Props and Wardrobe - 45-->
<!--Replica Paper Props – 40-->
<!--Free Harry Paper Props – 64-->
<!--Sculpture and Makeup Effects – 62-->
<!--Replica Movie Costumes - 24-->
<!--Costume and Cosplay Showcase – 67-->
<!--Judge Dredd Costume Group – 71-->
<!--General Modeling - 11-->
<!--Studio Scale Models – 10-->
<!--Entertainment and Movie Talk – 47-->
<!--Conventions and Prop Parties – 68-->
<!--Off-Topic Talk – 12-->
<!--The Junkyard - 13-->

<iframe id='a9418415' name='a9418415' src=';target=_blank' frameborder='0' scrolling='no' width='300' height='250'><a rel='nofollow' href='' target='_blank'><img src=';n=a0516fad' border='0' alt='' /></a></iframe>

<div style="clear:both"></div>

Basically - I'd like to remove the two main DIVs and just replace it with this.

<div style="clear:both"></div>

Any help would be greatly appreciated.


Full output on one of the pages. I've pasted it to pastebin.

Lines 401-465 are what I'm trying to remove and only leave line 465.



We might need to see the whole page to work out robust selectors for those <div>s.

But, if they always contain iframes with src attributes to undesirable content, then you can use those iframes to hunt down the dastardly divs.

Make a list of key text snippets in the bad iframe src attributes. I'm also using jQuery and waitForKeyElements(), in case this content is added by AJAX.

So, the script looks something like this:

// ==UserScript==
// @name     _Remove bad divs containing bad iframes
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @require
// @require
// @grant    GM_addStyle
// ==/UserScript==
/*- The @grant directive is needed to work around a design change
    introduced in GM 1.0.   It restores the sandbox.
var badFrameSrcSnips = [
    //-- These are case-sensitive

for (var J in badFrameSrcSnips) {
    var srcSnippet  = badFrameSrcSnips[J];

    waitForKeyElements (
        "iframe[src*='" + srcSnippet + "']", removeBadDiv

function removeBadDiv (jNode) {
    //-- Replace the bad div (iframe's parent) with a tame one.
    jNode.parent ().replaceWith ('<div style="clear:both"></div>');

Need Your Help

Clearing IDLE's shell for Python


So I'm doing an MIT OCW assignment where I am creating a functional game of hangman. I got everything working. In IDLE, I have to hit F5 to run the code in the shell. I don't know any other way to ...