1

On a forum I frequent, there is a shoutbox. The administrators took it off the index to encourage people to post more. I want to pull the shoutbox from it's page and put it on the index again. I can pull the div of the shoutbox off the page and have it load on the index, but either it is interfering with another script or it won't actively load to be able to use because all of the buttons will not work. I think the shoutbox uses AJAX for dynamic loading and shouting, but I'm new to all this. Please help. This is a userscript for Greasemonkey, so be aware of limitations to the script.

// ==UserScript==
// @name          DW24/7 Shoutbox Index
// @namespace     McPeake
// @description   Shoutbox on index
// @include       http://forums.digitalwarfare247.com/* 
// ==/UserScript==

var jQuery;

// Add jQuery
(function(){
    if (typeof unsafeWindow.jQuery == 'undefined') {
        var GM_Head = document.getElementsByTagName('head')[0] || document.documentElement,
            GM_JQ = document.createElement('script');

        GM_JQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js';
        GM_JQ.type = 'text/javascript';
        GM_JQ.async = true;

        GM_Head.insertBefore(GM_JQ, GM_Head.firstChild);
    }
    GM_wait();
})();

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

// All your GM code must be inside this function
function letsJQuery() {
$(document).ready(function() {
$("#category_45").load('http://forums.digitalwarfare247.com/index.php?/shoutbox #shoutbox-wrapper');
});
}

If this matters: Link to the shoutbox script: http://forums.digitalwarfare247.com/public/js/shoutbox.js

Link to other script: http://forums.digitalwarfare247.com/public/js/shoutbox.ajax.js

Thanks.

1 Answers1

1

I don't know if this specifically resolves your answer. But jQuery has the method load which can load page fragments (see section "Loading Page Fragments" in previous link). I think, however, that it won't work cross-domain in websites; probably, Greasemonkey is different.

Edit: See related StackOverflow question: Load content of a div on another page

Community
  • 1
  • 1
user1264201
  • 75
  • 1
  • 9