d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Useful Greasemonkey Scripts?
12Next
Add Reply New Topic New Poll
Member
Posts: 20,165
Joined: Dec 5 2007
Gold: 690.20
Mar 10 2010 08:35pm
Can anyone recommend me some useful greasemonkey scripts?

So far I have:

Disable Text Ads
Google Secure Pro
MMA
MouseOverThis!
Secure connections on sites
Userscripts Updater
YouTube Download
YouTube HD Lite
Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Mar 10 2010 09:39pm
The most important Greasemonkey script (auto-block Muted):

Code
// ==UserScript==
// @name           D2jsp Forums Helper
// @namespace      http://asbands.d2jsp.org/
// @description    Adds random features to d2jsp forums browsing
// @include        http://forums.d2jsp.org/topic.php?*
// @include        http://forums.d2jsp.org/pm.php?*
// ==/UserScript==
var __num__ = 0;
var collapseOldPosts = false;

function rollPosts(posterRegex, cutoffDate) {
 var posts = document.getElementsByTagName('fieldset').wrappedJSObject;
 for (var i = 0; i < posts.length; i++) {
     var post = posts.item(i);
     var posterName = getPoster(post);
     if (posterName) {
         var div = document.createElement('div');
         post.id = 'post_' + __num__;
         div.id = 'div_' + __num__;
         var link = document.createElement('a');
         link.id = 'lnk_' + __num__;
         link.innerHTML = '+';
         div.appendChild(link);
         div.style.cssFloat = 'left';

         post.parentNode.insertBefore(div, post);
         if (isBadPoster(post, posterRegex)) collapsePost(post, link);
         else if (collapseOldPosts && isPostOlder(post, cutoffDate)) collapsePost(post, link);
         else expandPost(post, link);

         __num__ = __num__ + 1;
     }
 }
}

function getPoster(post) {
 var legend = post.firstChild;
 if (!legend) return null;
 else {
     var link = legend.firstChild;
     if (!link) return null;
     else return link.innerHTML;
 }
}

function getPostTime(post) {
 var infoDiv = post.childNodes[2];
 var dateString = infoDiv.childNodes[5].innerHTML;

 return parseDate(dateString);
}

function parseDate(dateString) {
 dateString = dateString.substring(dateString.indexOf(' ') + 1);
 //    extract month
 var monthString = dateString.substring(0, dateString.indexOf(' '));
 month = getMonth(monthString);
 dateString = dateString.substring(monthString.length + 1);
 //    extract day of month
 var day = dateString.substring(0, dateString.indexOf(' '));
 dateString = dateString.substring(day.length + 1);
 //    extract the year
 var commaIdx = dateString.indexOf(',');
 var spaceIdx = dateString.indexOf(' ');
 var year = dateString.substring(0, commaIdx);
 if (commaIdx + 1 != spaceIdx) {
     year = dateString.substring(0, spaceIdx);
     dateString = dateString.substring(year.length + 1);
 } else {
     dateString = dateString.substring(year.length + 2);
 }
 //    extract the hour and minute
 var hour = dateString.substring(0,2);
 var mins = dateString.substring(3,5);

 var d = new Date();
 d.setFullYear(year, month, day);
 d.setHours(hour);
 if (dateString.substring(5,6) == 'p') d.setHours(d.getHours() + 12);
 d.setMinutes(mins);
 return d;
}

function getMonth(m) {
 if (matches(m, /Jan/i)) { return 0; }
 if (matches(m, /Feb/i)) { return 1; }
 if (matches(m, /Mar/i)) { return 2; }
 if (matches(m, /Apr/i)) { return 3; }
 if (matches(m, /May/i)) { return 4; }
 if (matches(m, /Jun/i)) { return 5; }
 if (matches(m, /Jul/i)) { return 6; }
 if (matches(m, /Aug/i)) { return 7; }
 if (matches(m, /Sep/i)) { return 8; }
 if (matches(m, /Oct/i)) { return 9; }
 if (matches(m, /Nov/i)) { return 10; }
 if (matches(m, /Dec/i)) { return 11; }
}

function isPostOlder(post, cutoff) {
 var postTime = getPostTime(post) - 0;//    get it into long mode
 return postTime < cutoff;
}

function matches(name, regex) {
 return name.search(regex) != -1;
}

function isBadPoster(post, regex) {
 var name = getPoster(post);
 if (name) return matches(name, regex);
 else return false;
}

function togglePost(post, header) {
 if (post.style.visibility == 'collapse') expandPost(post, header);
 else collapsePost(post, header);
}

function collapsePost(post, header) {
 var posterName = getPoster(post);
 post.style.visibility = 'collapse';
 header.innerHTML = '+ ' + posterName + getPostTime(post);
}

function expandPost(post, header) {
 post.style.visibility = 'visible';
 header.innerHTML = '&mdash;';
}

//    adds the click listener, which allows us to intercept user clicks
document.addEventListener('click', function(event) {
     var target = event.target;
     //    is the user clicked on one of the created links
     if (matches(target.id, /^lnk_/)) {
         //    flip the post associated with the link
         var postId = 'post_' + target.id.substring(4);//4 = length of 'lnk_'
         var post = document.getElementById(postId).wrappedJSObject;
         togglePost(post, target);
     }
 }, true);

function getAutohideRegex() {
 var hideRegexString = GM_getValue('hideRegex');
 var regex = null;
 if (!hideRegexString) {
     hideRegexString = prompt('You have not yet specified a regular expression to automatically hide users.  Please input one now (or blank to not autohide).', 'Muted');
     if (hideRegexString.length > 0) {
         regex = new RegExp(hideRegexString);
         GM_setValue('hideRegex', hideRegexString);
     } else GM_setValue('@@NONE');
 } else if (hideRegexString != '@@NONE') {
     regex = new RegExp(hideRegexString);
 }
 return regex;
}

function resetAutohideRegex() {
 var regexString = prompt('Please set the regular expression used to select users to automatically hide (or blank not to hide any).','Muted');
 if (regexString.length > 0) GM_setValue('hideRegex', regexString);
 else GM_setValue('hideRegex', '@@NONE');
}

function onScriptLoad() {
 var purl = '' + window.location;
 purl = purl.substring(purl.indexOf('t=') + 2, purl.indexOf('f=') - 1);
 if (GM_registerMenuCommand) GM_registerMenuCommand('Set D2jsp Forums Autohide', resetAutohideRegex);
 var lastTime = GM_getValue('time_' + purl);
 if (lastTime) {
     lastTime = parseDate(lastTime);
     collapseOldPosts = true;
 }
 GM_setValue('time_' + purl, '' + new Date());

 var regex = getAutohideRegex();
 if (regex) rollPosts(regex, lastTime - 6*60*60*1000);//cutoff time is six hours later
}

onScriptLoad();
Member
Posts: 20,165
Joined: Dec 5 2007
Gold: 690.20
Mar 10 2010 09:41pm
Quote (ASBands @ Mar 10 2010 10:39pm)
The most important Greasemonkey script (auto-block Muted):

What exactly does this do? And where can I d/l the script?


Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Mar 10 2010 10:14pm
Quote (Aurorae @ Mar 10 2010 10:41pm)
What exactly does this do? And where can I d/l the script?


Like I said, it blocks Muted. And you download the script by copying and pasting it into Greasemonkey.
Member
Posts: 20,165
Joined: Dec 5 2007
Gold: 690.20
Mar 10 2010 10:53pm
Quote (ASBands @ Mar 10 2010 11:14pm)
Like I said, it blocks Muted.  And you download the script by copying and pasting it into Greasemonkey.

o.O What does "Block muted" mean?

It blocks people squelched from b.net?

This post was edited by Aurorae on Mar 10 2010 10:56pm
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Mar 11 2010 12:41am
Quote (Aurorae @ 11 Mar 2010 05:53)
o.O What does "Block muted" mean?

It blocks people squelched from b.net?


Muted is a person on D2JSP, seemingly hated(?).
So the script removes his/her posts.

I wouldn't support such hating though and im sure any humanbeing with humanly feelings.

This post was edited by eagl3s1ght on Mar 11 2010 12:42am
Member
Posts: 20,165
Joined: Dec 5 2007
Gold: 690.20
Mar 11 2010 01:12am
Quote (eagl3s1ght @ Mar 11 2010 01:41am)
Muted is a person on D2JSP, seemingly hated(?).
So the script removes his/her posts.

I wouldn't support such hating though and im sure any humanbeing with humanly feelings.

Oh.. no wonder I didn't understand what he meant. No idea who Muted is.

Member
Posts: 6,493
Joined: Apr 5 2006
Gold: 804.88
Mar 11 2010 09:15am
Videoembed
LongURL
Image previewer
Member
Posts: 6,953
Joined: Sep 27 2003
Gold: 518.50
Mar 11 2010 09:17am
Quote (Aurorae @ Mar 11 2010 02:12am)
Oh.. no wonder I didn't understand what he meant. No idea who Muted is.

And with this script, you won't ever have to! There is an option to block whoever you want, but it blocks Muted by default.

You can also collapse posts (instead of scrolling down). I was thinking of doing some spam detection, but I haven't had the time to implement it.

Quote (eagl3s1ght @ Mar 11 2010 01:41am)
Muted is a person on D2JSP, seemingly hated(?).
So the script removes his/her posts.

I wouldn't support such hating though and im sure any humanbeing with humanly feelings.

Some of the asinine stupidity spewed from her keyboard almost made me have a brain aneurysm, so I made a script to auto-block her. Actually, that script also has the potential to automatically hide old posts, but it's somewhat buggy and inconvenient.
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Mar 11 2010 11:37am
Quote (ASBands @ 11 Mar 2010 16:17)
And with this script, you won't ever have to!  There is an option to block whoever you want, but it blocks Muted by default.

You can also collapse posts (instead of scrolling down).  I was thinking of doing some spam detection, but I haven't had the time to implement it.


Some of the asinine stupidity spewed from her keyboard almost made me have a brain aneurysm, so I made a script to auto-block her.  Actually, that script also has the potential to automatically hide old posts, but it's somewhat buggy and inconvenient.



"Some of the asinine stupidity spewed from her keyboard almost made me have a brain aneurys" Sounds like overreacting to me.
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll