Removing content from a page using Greasemonkey

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #16
    Heya, Moishy.

    I'm thinking something like this:
    [code=javascript]
    var tds = document.getEle mentsByTagName( 'td');

    for( var i = 0; i < tds.length; i++ )
    {
    var spans = tds.getElements ByTagName('span ');
    if( spans && spans[0].className && spans[0].className.matc h('title1') )
    {
    tds[i].parentNode.rem oveChild(tds[i]);
    }
    }
    [/code]

    Comment

    • moishy
      New Member
      • Oct 2006
      • 104

      #17
      But I don't want to remove all the TDs that have "title1"
      I only want to evict the one's that "title1" is wrapped with <b>

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #18
        Heya, Moishy.

        So you want to remove the element where spans[0].getElementsByT agName('b')[0].firstChild.nod eValue is 'title1', eh?

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #19
          Originally posted by moishy
          But I don't want to remove all the TDs that have "title1"
          I only want to evict the one's that "title1" is wrapped with <b>
          If the bold tags can appear anywhere within the span, once the span with a class of "title1" has been matched, use document.getEle mentsByTagName( "b").length to find the number of bold tags. If the length is 0, don't remove the table cell, otherwise you have the line that deletes.

          Comment

          Working...