|
Post by Wormopolis on Mar 9, 2009 2:05:31 GMT -8
Browser Tested: IE and FF Placement: Board or Global Footer
Sets a minimum number of posts to display any links a member posts. Useful for trolls who post links to other sites.
<script type="text/javascript"> <!-- // Post Requirement to post Links // v2.1 // By Wormopolis - wormocodes.proboards.com // Keep Header Intact
(function(){ var restrictLinks=true; var postMinLinks=5; //number of posts required to be able to post links var removeMsgLinks='<br>«LINK REMOVED - POST COUNT LOW»<br>'; var keepTextLinks=true; //set to true to put back the text without a hyperlink
var restrictImages=true; var postMinImages=10; //number of posts required to be able to post images var removeMsgImages='<br>«IMAGE REMOVED - POST COUNT LOW»<br>';
var restrictVideos=true; var postMinVideos=20; //number of posts required to be able to post videos var removeMsgVideos='<br>«VIDEO REMOVED - POST COUNT LOW»<br>';
// NO NEED TO EDIT BELOW
tds=document.getElementsByTagName('td'); for (h=0; h<tds.length; h++) { if (tds[h].width=='20%' && tds[h].vAlign=='top' && tds[h].className.match(/windowbg/i) && tds[h].align=='left' && (tds[h].innerHTML.match(/posts:/i) || tds[h].innerHTML.match(/<br>Guest<br>/i))) { var numposts=(tds[h].innerHTML.match(/<br>Guest<br>/i) ? 0 : parseInt(tds[h].innerHTML.split(/posts:/i)[1].split(/<br>/i)[0].replace(/,/g,''))); var postCell=tds[h].nextSibling.getElementsByTagName('tr')[1].firstChild; if (restrictLinks && (numposts < postMinLinks)) { while (postCell.innerHTML.match(/<a(.*?)>(.*?)<\/a>/i)) { var putback=(keepTextLinks ? RegExp.$2 : removeMsgLinks); postCell.innerHTML=postCell.innerHTML.replace(/<a(.*?)>(.*?)<\/a>/i,putback); } } if (restrictImages && (numposts < postMinImages)) { var tmpfrag=document.createElement('span'); tmpfrag.innerHTML=removeMsgImages; for (ri=postCell.getElementsByTagName('img'), rr=ri.length-1; rr>=0; rr--) { if (!ri[rr].src.match(/images.proboards.com/)) ri[rr].parentNode.replaceChild(tmpfrag,ri[rr]); } } if (restrictVideos && (numposts < postMinVideos)) { while (postCell.innerHTML.match(/<object(.*?)youtube(.*?)\/object>/i)) { postCell.innerHTML=postCell.innerHTML.replace(/<object(.*?)youtube(.*?)\/object>/i,removeMsgVideos); } } } } })(); // --> </script>
Preview: at some point
|
|
hcfwesker
Not New Member
Posts: 37
hcfwesker said 0 great things
|
Post by hcfwesker on Jun 19, 2009 5:00:03 GMT -8
Hey, wormopolis. Don't know if you were still going to modify that other restricting code .... but this one seems to be what i need. Set it to 20; and just put it in my Ad Board's footers. Yes, I'm going down your complete Index, and finding some great codes on my way
|
|
trublu
Not New Member
Posts: 2
trublu said 0 great things
|
Post by trublu on Jan 1, 2010 10:55:00 GMT -8
Hi Wormo, I tried out this code, but I seem to have an issue; the error message that is only supposed to pop up for those under 5 posts is popping up for everyone. I don't know if anyone has experienced this before. Because the forum is live, I couldn't really leave the code in; I can put it on a test forum if you need. Here's the forum: coldcase2.proboards.comAnd here is exactly what I was using: <script type="text/javascript"> <!-- // Post Requirement to post Links // By Wormopolis - [url]wormocodes.proboards.com[/url] // Keep Header Intact
var postMin=5; //number of posts required to be able to post links var removeMsg='<br>Error: You need 5 posts to post links.<br>'; var keepText=false; //set to true to put back the text without a hyperlink
// NO NEED TO EDIT BELOW
tds=document.getElementsByTagName('td'); for (h=0; h<tds.length; h++) { if (tds[h].width=='20%' && tds[h].vAlign=='top' && tds[h].className.match(/windowbg/i) && tds[h].align=='left' && (tds[h].innerHTML.match(/posts:/i) || tds[h].innerHTML.match(/<br>Guest<br>/i))) {
numposts=(tds[h].innerHTML.match(/<br>Guest<br>/i) ? 0 : parseInt(tds[h].innerHTML.split(/posts:/i)[1].split(/<br>/i)[0])); if (numposts < postMin) { postCell=tds[h].nextSibling.getElementsByTagName('tr')[1].firstChild; while (postCell.innerHTML.match(/<a(.*?)>(.*?)<\/a>/i)) { putback=(keepText ? RegExp.$2 : removeMsg); postCell.innerHTML=postCell.innerHTML.replace(/<a(.*?)>(.*?)<\/a>/i,putback); } } } }
// --> </script>
|
|
|
Post by Wormopolis on Jan 1, 2010 13:26:21 GMT -8
Investigating this right now.
|
|
|
Post by Wormopolis on Jan 1, 2010 13:32:49 GMT -8
recopy the code above. it was faulting because of post counts over 1000 havcing the darn comma in there. it dropped everything after the comma. I wrote this code in my early days before I knew to check for those things.
Thank you for finding that bug!
|
|
dynastygal
Not New Member
[Sj1:0]
Posts: 23
dynastygal said 0 great things
|
Post by dynastygal on Mar 2, 2010 3:15:12 GMT -8
|
|
|
Post by Wormopolis on Mar 3, 2010 20:22:14 GMT -8
you have a post where a link isnt being removed? all the posts in that thread dont have any links.
|
|
dynastygal
Not New Member
[Sj1:0]
Posts: 23
dynastygal said 0 great things
|
Post by dynastygal on Mar 4, 2010 7:11:53 GMT -8
The post by thomastallis
|
|
|
Post by Wormopolis on Mar 5, 2010 2:10:27 GMT -8
looking at the source, the code isnt installed....
|
|
dynastygal
Not New Member
[Sj1:0]
Posts: 23
dynastygal said 0 great things
|
Post by dynastygal on Mar 5, 2010 8:50:45 GMT -8
|
|
|
Post by Wormopolis on Mar 5, 2010 10:45:14 GMT -8
I see the code in there now.
the miniprofile was changed making the code unable to see it.
find this line:
if (tds[h].width=='20%' && tds[h].vAlign=='top' && tds[h].className.match(/windowbg/i) && tds[h].align=='left' && (tds[h].innerHTML.match(/posts:/i) || tds[h].innerHTML.match(/<br>Guest<br>/i))) {
change to:
if (tds[h].width=='20%' && tds[h].vAlign=='top' && tds[h].className.match(/windowbg/i) && tds[h].align=='center' && (tds[h].innerHTML.match(/posts:/i) || tds[h].innerHTML.match(/<br>Guest<br>/i))) {
|
|
dynastygal
Not New Member
[Sj1:0]
Posts: 23
dynastygal said 0 great things
|
Post by dynastygal on Mar 5, 2010 12:37:22 GMT -8
Well, it works, kinda now...although I presume it doesn't automatically replace current links with the no link message but only links from now on?
|
|
|
Post by Wormopolis on Mar 5, 2010 23:23:44 GMT -8
it doesnt change the data they entered into the post, it just changes how it is displayed to all your other users. past posts should still be affected by the code if the post count was under the setting.
|
|
|
Post by Wormopolis on Oct 15, 2012 23:33:45 GMT -8
version update 2.0: added in ability to also restrict images
|
|
|
Post by Wormopolis on Oct 17, 2012 20:01:47 GMT -8
version update 2.1: added in ability to restrict youtube videos.
|
|