...

View Full Version : Need Help Removing Content



Johnb21
01-04-2011, 07:20 AM
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



<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




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

Philip M
01-04-2011, 08:30 AM
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


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.

Johnb21
01-04-2011, 08:44 AM
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


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?

Philip M
01-04-2011, 08:51 AM
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?

Johnb21
01-04-2011, 09:35 AM
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.

Kor
01-04-2011, 11:33 AM
If it is the bottom (the last) span element, just:


var spans=document.getElementsByTagName('span');
var lastSpan=spans[spans.length-1];
lastSpan.parentNode.removeChild(lastSpan);

Johnb21
01-04-2011, 06:05 PM
If it is the bottom (the last) span element, just:


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?

Johnb21
01-04-2011, 11:28 PM
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.

Johnb21
01-05-2011, 02:18 AM
Mark this as resolved. I got it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum