As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

Random comic button (Greasemonkey script)

Hey guys. Yesterday I made the following greasemonkey script. It adds a "Random" link under all the buttons that are normally beneath a Penny Arcade comic, which (unsurprisingly) links to a random comic. I don't know if something like this has been done before, but if not, I thought some of you might enjoy that functionality.
// ==UserScript==
// @name Penny Arcade Random Button
// @namespace [email protected]
// @description Adds a random comic button to penny-arcade.com
// @include http://*penny-arcade.com/comic*
// ==/UserScript==


GM_xmlhttpRequest({
   method: 'GET',
   url: 'http://www.penny-arcade.com/archive/',
   onload: function(responseDetails) {
      var parser = new DOMParser();
      var xmlDoc = parser.parseFromString(responseDetails.responseText,"application/xml");
      var comics = xmlDoc.getElementById('id_comic');
      var n = comics.options.length;
      var myLink=comics.options[Math.floor(Math.random()*n)].value;
      var btns = document.forms[0].parentNode;
      if(btns)
      {
         var newElement = document.createElement('a');
         newElement.innerHTML='Random';
         newElement.href=myLink;
         btns.appendChild(newElement);
      }
   }
});

Installation instructions:
1. You will need to be using Firefox to use this script
2. If you have never added the Greasemonkey add-on, add it here.
3. Copy the code above and save it to a file on your hard drive called "penny_arcade_random.user.js"
4. In Firefox, go to File > Open file... and open the file you just created. Greasemonkey will prompt you to install the script.

Let me know if there are any problems.

Comments?

TheAmazingOne on

Posts

  • DadouwDadouw Registered User regular
    edited October 2008
    Cool

    Dadouw on
  • OrikaeshigitaeOrikaeshigitae Registered User, ClubPA regular
    edited October 2008
    this is cool! a slightly better place would be Tube's Circus, so I'm moving it there

    Orikaeshigitae on
  • the cheatthe cheat Registered User, ClubPA regular
    edited October 2008
    that is cool, but >.>

    think you could make a script to make double clicking a thread's blue dot mark the thread as read?

    the cheat on
    tKfL2Yd.png?1
  • WillethWilleth Registered User regular
    edited October 2008
    Just to skip a step, I've hosted this for people at http://www.willeth.com/penny_arcade_random.user.js so all you need to do is click that link and Greasemonkey will prompt an install.

    This works pretty well, but is there a way you could add a button and maybe one for the news posts?

    Willeth on
    @vgreminders - Don't miss out on timed events in gaming!
    @gamefacts - Totally and utterly true gaming facts on the regular!
Sign In or Register to comment.