Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

HBH Main Page GreaseMonkey Script (using jQuery) - Javascript Code Bank


HBH Main Page GreaseMonkey Script (using jQuery)
This script hides a lot of the non-essential things on the main page, adds collapsible functionality to those and the navigation, and refreshes the member list, shoutbox, forum list and message list every 30 seconds.
                // Add jQuery
    var GM_JQ = document.createElement('script');
    GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
    GM_JQ.type = 'text/javascript';
    document.getElementsByTagName('head')[0].appendChild(GM_JQ);

// Check if jQuery's loaded
    function GM_wait() {
        if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
    else { $ = unsafeWindow.jQuery; letsJQuery(); }
    }
    GM_wait();

// Place jQuery code in this function
 function letsJQuery() {

	 $("div.side-body iframe, img[src$='.gif']").remove();

	 // Collapse the navigation and make it clickable to show it
	 $('div.side-body:first').css('display','none');
	 $('div.scapmain:first').hover( function(){
		$(this).css('cursor','pointer');
	 }).click( function(){
		if ( $(this).next().css('display') == 'none' ) {
			$('div.side-body:first').css('display','block');
		}
		else {
			$('div.side-body:first').css('display','none');
		} 
	 });
	 
	 // Hide the intro text and new stuff list, since this rarely changes
	 $('div.main-body:first').css('display','none').prev('div.capmain').click( function(){
		if ( $(this).next('div.main-body').css('display') == 'none' ) {
			$(this).next('div.main-body').css('display','block');
		}
		else {
			$(this).next('div.main-body').css('display','none');
		}
	 }).html('What\'s New at HBH?').css('textAlign','center').hover( function(){
		$(this).css('cursor','pointer');
	 });
	 
	 // Hide the video and defacement on the left, directly below the forum threads
	 $('div.open_table').next('div').find('table').css('display','none');
	 
	 $('div.news_box').each( function(){
		$(this).find('div.news_capmain').hover( function(){
			$(this).css('cursor','pointer');
		}).click( function(){
			if ( $(this).next('div').find('div.main-body').css('display') == 'none' ) {
				$(this).next('div').find('div.main-body').css('display','block');
			}
			else {
				$(this).next('div').find('div.main-body').css('display','none');
			}
		}).next('div').find('div.main-body').css('display','none');
	 });
	 
	 // Collapse everything but the shoutbox, but make the headings clickable to show each item
	 $('td.side-border-right div.scapmain').not(':last').each( function(){
		$(this).next('.side-body').css('display','none');
		$(this).hover( function(){
			$(this).css('cursor','pointer');
		}).click( function(){
			if ( $(this).next('.side-body').css('display') == 'none' ) {
				$(this).next('.side-body').css('display','block');
			}
			else {
				$(this).next('.side-body').css('display', 'none');
			}
		});
	 });
	 
	 // Refresh the shoutbox using AJAX to the same file that loads it normally
	 var reloadShout = function(){
		$('#Shoutbox-results').html('<strong>Loading...</strong>');
		$.get('shoutbox/shoutbox_result.php', {}, function(data){
			$('#Shoutbox-results').animate( {opacity:1}, 500, function(){
				$(this).html(data);
			});
		});
	 };
	 
	 // Refresh the member list by doing an AJAX call to the main page and pulling out the member list
	 var reloadMembers = function(){
		$('div.membersonline').html( '<strong>Loading...</strong>' );
		$.get('index.php', {}, function(data){
			$('div.membersonline').animate( {opacity:1}, 500, function(){
				$('div.membersonline').html( $('div.membersonline',data).html() );
			});
		});
	 };
	
         //Refresh forum posts
         var reloadForum = function(){
		$('div.open_table div.open_table div.main-body:first').html( '<strong>Loading...</strong>' );
		$.get('index.php', {}, function(data){
			$('div.open_table div.open_table div.main-body:first').animate( {opacity:1}, 500, function(){
				$('div.open_table div.open_table div.main-body:first').html( $('div.open_table div.open_table div.main-body:first',data).html() );
			});
		});
	 };

         var reloadMessages = function(){
		$.get('index.php', {}, function(data){
			if ( $("td.side-border-right a[href='/messages/']", data).length > 1 ) {
				$('td.side-border-right div.scapmain a').remove();
				$('<a>').attr('href','/messages/').css('fontWeight','bolder').css('marginLeft','5px').html('(New Messages)')
					.appendTo( $('td.side-border-right div.scapmain:first') );
			}
		}); 
	 };

	 // Refresh the shoutbox and member list every 30 seconds
	 setInterval(reloadShout, 30000);
	 setInterval(reloadMembers, 30000);
	 setInterval(reloadForum, 30000);
         setInterval(reloadMessages, 30000);
 }
            
Comments
ghost's avatar
ghost 14 years ago

Be sure to try it out and let me know any glitches or issues you run into. All suggestions are appreciated as well.

ghost's avatar
ghost 14 years ago

Added refresh for forum posts as well.

yours31f's avatar
yours31f 13 years ago

Works great for me.