Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    63
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Need Help Removing Content

    I can't really get any help over on the greasemonkey forums so hopefully I can get some needed help here.

    My goal with a script I am writing is to remove signatures from a forum I am a part of. Some of the people abuse it with half a page of stuff and it's out of control. So here is what the HTML source code for it looks like

    Code:
    <table cellSpacing="1" width="100%" border="0" class="tback" cellPadding="2">
    <tr>
    <td width="100" class="headcell">Author</td>
    
    <td class="headcell">Topic</td>
    </tr>
    <tr vAlign="top" class="cell">
    <td align="center">
    <div><a href="profile.asp?$sid=&amp;id=5126">Roadwildcat</a></div>
    <div class="fcaption">Pee Wee League</div><br><div><img src="images/stars-2.gif" alt="2 Stars"></div><br><img src="Avatars/Georgia.gif" alt="Member Avatar" height="62" width="62"><div class="fcaption">DC Georgia 2020 to Present</div>
    <div class="fcaption">115 Posts</div>
    </td>
    <td>
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td><span class="fcaption"><img src="images/oPost.gif" alt="Old Post" height="10" width="10" border="0" align="absmiddle">Posted - 03 January 2011 5:41</span></td>
    
    <td align="right"><a href="myForum.asp?$sid=&amp;mode=compose&amp;to=5126"><img src="images/pm.gif" width="33" height="18" border="0" hspace="3" align="absmiddle" alt="Send Roadwildcat a Private Message"></a><a href="post.asp?$sid=&amp;mode=Quote&amp;id=24958&amp;fid=2&amp;t=24958&amp;fpage=1"><img hspace="3" alt="Reply With Quote" src="images/quote.gif" width="28" height="18" align="absmiddle" border="0"></a></td>
    </tr>
    </table>
    <hr size="1" noshade>I have been trying to set my attendance to the all star games but when I do a game search on the map it is showing no games at all. Anyone else having this problem?<hr size="1"><span class="fcaption">SEC Champions 2022-2027 <br/> National Runner-up 2027 <br/> Recruiting BEAST! <br/> BULLDAWG BOUNCE</span></td>
    </tr>
    The very bottom where it has the 'span' tag and it says "SEC Champions" is where the Signatures are located. I want to completely remove that using my script and this is what I have right now

    Code:
    function sigRemove() {
    	var sigs = document.getElementsByTagName('span');
    	for (var i = 0; i < sigs.length; i++) {
    		sigs[i].style.display = 'none';
    	}
    }
    I know it's incomplete but I only want to remove that bottom span tag and everything inside of it and not every span tag on the page. Please help and I apologize for the long post

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,170
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    Give your <span> an id

    <span id = "myspan" class="fcaption">SEC Champions 2022-2027 <br/> National Runner-up 2027 <br/> Recruiting BEAST! <br/> BULLDAWG BOUNCE</span></td>
    </tr>


    Then

    Code:
    function sigRemove() {
    document.getElementById('myspan').style.display="none";
    }

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • #3
    New Coder
    Join Date
    Sep 2010
    Posts
    63
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Philip M View Post
    Give your <span> an id

    <span id = "myspan" class="fcaption">SEC Champions 2022-2027 <br/> National Runner-up 2027 <br/> Recruiting BEAST! <br/> BULLDAWG BOUNCE</span></td>
    </tr>


    Then

    Code:
    function sigRemove() {
    document.getElementById('myspan').style.display="none";
    }

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    If you don't mind me sounding completely idiotic... how would I add that id to that span only?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,170
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    Quote Originally Posted by Johnb21 View Post
    If you don't mind me sounding completely idiotic... how would I add that id to that span only?
    Oh. I thought I had shown that.

    <span id = "myspan"


    But if you never want to show that <span> why do you not simply delete it?

  • #5
    New Coder
    Join Date
    Sep 2010
    Posts
    63
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Philip M View Post
    Oh. I thought I had shown that.

    <span id = "myspan"


    But if you never want to show that <span> why do you not simply delete it?
    It's not my forum I am just a user on the game that visits the forum too.

  • #6
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    If it is the bottom (the last) span element, just:
    Code:
    var spans=document.getElementsByTagName('span');
    var lastSpan=spans[spans.length-1];
    lastSpan.parentNode.removeChild(lastSpan);
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #7
    New Coder
    Join Date
    Sep 2010
    Posts
    63
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Kor View Post
    If it is the bottom (the last) span element, just:
    Code:
    var spans=document.getElementsByTagName('span');
    var lastSpan=spans[spans.length-1];
    lastSpan.parentNode.removeChild(lastSpan);
    One last question before this can be marked as resolved.

    Say I want to delete the last span of a specific class name.

    example: <div class = "classname'><span>Content</span><a href="">Link</a><span>more content</span>

    If i want to delete the last span of a class what is your suggestion for that?

  • #8
    New Coder
    Join Date
    Sep 2010
    Posts
    63
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by Johnb21 View Post
    One last question before this can be marked as resolved.

    Say I want to delete the last span of a specific class name.

    example: <div class = "classname'><span>Content</span><a href="">Link</a><span>more content</span>

    If i want to delete the last span of a class what is your suggestion for that?
    This is the last bit of help I need for this script to work. Since I am not an expert at it, I was going to try and run a loop to get the last tag but im not sure if it would work.

  • #9
    New Coder
    Join Date
    Sep 2010
    Posts
    63
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Mark this as resolved. I got it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •