|
Post by Wormopolis on Apr 26, 2009 20:07:52 GMT -8
Browser tested: IE Chrome and FF placement: Global footer
Makes Karma invisible to any user with less than set post count. also gives ability to rename karma, and remove smite privs for non-selected users. also has variable to have selected users without restriction, and also to hide karma numbers from guests.
code:
<script type="text/javaScript"> <!-- // Post requirements for Karma use - version 1.81 // by Wormopolis - [url]wormocodes.proboards.com[/url] // Do not repost - keep header intact
var postsRequiredToUseKarma=10;
// if you want to rename karma: var useNewKarmaWords=true; var newKarmaWord="Mojo"; var newSmiteWord="Ice"; var newExaltWord="Work";
// if you want only certain people to use smite: var restrictSmite=true; var smiteAllowedAlways = "admin|user1|wormopolis"; //seperate by | var smiteByPostcount = 20; //minimum post count to use smite var noSmiteAllowed="user1|user2|user3"; //regardless of postcount, seperate by |
// if you want certain users to use karma regardless of postcount var alwaysKarma="admin|user1|wormopolis"; //seperate by |
// if you want Karma hidden to Guests var guestHideKarma=false;
// no need to edit below
var rgxAlwaysKarma=new RegExp('^('+alwaysKarma+')$',''); var rgxNeverSmite=new RegExp('^('+noSmiteAllowed+')$',''); var rgxAlwaysSmite=new RegExp('^('+smiteAllowedAlways+')$','');
if(location.href.match(/action=(display|recent|viewprofile|userrecentposts|pmview)/) || pb_action=='search2') { pstcnt=0; var ahh=document.getElementsByTagName('a') for(q=0;q<ahh.length;q++){ if(ahh[q].href.match('viewprofile&user='+pb_username) && ahh[q].parentNode.parentNode.width=='20%'){ postcount=ahh[q].parentNode.parentNode.innerHTML.split('Posts: ')[1].split(/</)[0]; postcount=postcount.replace(",",""); expDate=new Date(); expDate.setYear(expDate.getFullYear()+1); document.cookie=pb_username+"_postcount="+postcount+"; expires="+expDate; break; } } tst=new RegExp(pb_username+'_postcount=(\\d+)','') if (document.cookie.match(tst)) { pstcnt=parseInt(RegExp.$1); } for (tds=document.getElementsByTagName('td'), t=0; t<tds.length; t++ ) { if (tds[t].width=='20%' && tds[t].className.match(/windowbg/) && tds[t].vAlign=='top') { for (lnks=tds[t].getElementsByTagName('a'), i=0; i<lnks.length; i++) { if (lnks[i].href.match(/action=karma/)) { if (pstcnt<postsRequiredToUseKarma && !pb_username.match(rgxAlwaysKarma)) { lnks[i].style.display="none"; if (lnks[i].previousSibling && lnks[i].previousSibling.nodeName.match(/text/)) lnks[i].previousSibling.nodeValue=""; if (lnks[i].nextSibling && lnks[i].nextSibling.nodeName.match(/text/)) lnks[i].nextSibling.nodeValue=""; lnks[i].parentNode.innerHTML=lnks[i].parentNode.innerHTML.replace(/karma:\s(-?)(\d+)/i,''); if (location.href.match(/action=viewprofile/)) { for (tds=lnks[i].parentNode.nextSibling.getElementsByTagName('td'), j=0; j<tds.length; j++) { if (tds[j].innerHTML.match(/karma:/i)) { tds[j].parentNode.style.display="none"; } } } } else { if (restrictSmite && lnks[i].innerHTML.match(/Smite/) && (pstcnt<smiteByPostcount || pb_username.match(rgxNeverSmite)) && !pb_username.match(rgxAlwaysSmite)) { lnks[i].style.display="none"; if (lnks[i].previousSibling && lnks[i].previousSibling.nodeName.match(/text/)) lnks[i].previousSibling.nodeValue=" ]"; if (lnks[i].nextSibling && lnks[i].nextSibling.nodeName.match(/text/)) lnks[i].nextSibling.nodeValue=""; } } } } if (useNewKarmaWords && tds[t].innerHTML.match(/Smite/)) tds[t].innerHTML=tds[t].innerHTML.replace(/Smite/,newSmiteWord); if (useNewKarmaWords && tds[t].innerHTML.match(/Exalt/)) tds[t].innerHTML=tds[t].innerHTML.replace(/Exalt/,newExaltWord); if (useNewKarmaWords && tds[t].innerHTML.match(/Karma/)) tds[t].innerHTML=tds[t].innerHTML.replace(/Karma/,newKarmaWord); if (location.href.match(/action=viewprofile/) && useNewKarmaWords && tds[t].nextSibling.innerHTML.match(/Karma/)) tds[t].nextSibling.innerHTML = tds[t].nextSibling.innerHTML.replace(/Karma/,newKarmaWord);
} } } if (pb_username=="Guest") { for (tds=document.getElementsByTagName('td'), k=0; k<tds.length; k++) { if (tds[k].innerHTML.match(/karma:\s(-?)(\d+)/gi)) { if (guestHideKarma) tds[k].innerHTML=tds[k].innerHTML.replace(/karma:\s(-?)(\d+)/gi,''); tds[k].innerHTML=tds[k].innerHTML.replace(/karma/gi,newKarmaWord); } } }
// --> </script>
preview: not really needed.. it just makes it hidden
|
|
|
Post by Wormopolis on Dec 9, 2009 14:33:56 GMT -8
version 1.61: bug fix for retrieving new post count.
|
|
|
Post by Wormopolis on Mar 9, 2010 10:11:24 GMT -8
update version 1.65: appends username to postcount for multiple accounts trying to use single postcount for actions.
|
|
|
Post by Wormopolis on Mar 9, 2010 22:16:18 GMT -8
update version 1.66: fixed so code runs in recent posts and search results.
|
|
|
Post by Wormopolis on Mar 16, 2010 13:20:45 GMT -8
update version 1.671: fixed rename bug and added in new smite restriction.
|
|
|
Post by Wormopolis on Mar 16, 2010 18:22:58 GMT -8
version update 1.68: moved postcount search loop up to get fresh data (Eton advice is always taken seriously).
|
|
wildgoosespeeder
Code Helper
Tiers are for strangers!
Posts: 530
wildgoosespeeder said 161 great things
|
Post by wildgoosespeeder on Mar 11, 2011 14:58:43 GMT -8
Isn't the latest version 1.69? Also I think this code should be renamed since it does more than just restrict karma by post count. Nice code by the way. I was using a different code by another member and it was lacking in some ways. Good job!
|
|
|
Post by Wormopolis on Mar 11, 2011 15:50:51 GMT -8
You have seen a 1.69 version somewhere?
|
|
wildgoosespeeder
Code Helper
Tiers are for strangers!
Posts: 530
wildgoosespeeder said 161 great things
|
Post by wildgoosespeeder on Mar 12, 2011 1:35:36 GMT -8
If you remember I complained that the mod here wasn't working right one day and you fixed it. I don't think you updated the code in this thread since that fix. On my forum I incremented myself because of the updated fix.
|
|
|
Post by Wormopolis on Mar 12, 2011 1:39:11 GMT -8
Yeah I dont remember that. I thought this WAS the one out of my footers....
what do you suggest for a new name?
Karma Chameleon?
|
|
wildgoosespeeder
Code Helper
Tiers are for strangers!
Posts: 530
wildgoosespeeder said 161 great things
|
Post by wildgoosespeeder on Mar 12, 2011 11:00:19 GMT -8
Here is the Mojo Not Working thread (it was fixed). I got nothing. Karma Chameleon it is. I suck at coming up with creative names for codes.
|
|
Bones
Code Helper
Posts: 131
Bones said 0 great things
|
Post by Bones on Mar 12, 2011 11:28:55 GMT -8
Karma Reincarnate
|
|
|
Post by Wormopolis on Mar 12, 2011 14:26:10 GMT -8
The Karmanator?
|
|
|
Post by Wormopolis on Mar 12, 2011 14:32:17 GMT -8
As for the version.. I guess I can put it at 1.69 maybe 1.681
|
|
Bones
Code Helper
Posts: 131
Bones said 0 great things
|
Post by Bones on Mar 12, 2011 15:27:06 GMT -8
Karma karma karma karma karma chameleon, you come and go, you come and go. Loving would be easy if your colours were like my dream, red gold and green, red gold and green. Edit: never mind, bit too long-winded for a name...
|
|