Enquirer Home Page | Twitter | Back to Improbable Island

 Forum Index > Off-Topic > Out-of-Game New Topic Post Reply
 A Greasemonkey Script: Truancy Meter
 |  Printable Version
Devin
 Monday, August 16 2010 @ 01:56 AM UTC (Read 20882 times)  
Forum Contestant
Contestant

Status: offline

Registered: 06/17/10
Posts: 30

I made a Greasemonkey script that adds a second experience bar below the first, which fills up toward the point where you get hunted down by your dojo master. It works on my system, so I figured I'd share.

PHP Formatted Code
// ==UserScript==
// @name           Improbable Truancy Meter
// @namespace      http://www.shadedraco.com/improbabletruancy
// @include        http://improbableisland.com/*
// ==/UserScript==

var CharInfo = document.evaluate("//table[@class='charinfo']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if (CharInfo) {
  var LevelRow = document.evaluate("//td[@class='charinfo']/b/span[@class='colLtWhite'][text()='Level']/../../..", CharInfo, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
  if (LevelRow) {
    var Level = new Number(LevelRow.cells[1].childNodes[0].childNodes[0].textContent);
    var ExperienceRow = LevelRow.parentNode.rows[LevelRow.rowIndex+1];
    var ExperienceMatch = ExperienceRow.cells[1].childNodes[0].childNodes[0].textContent.match(/^([\d,]+)\/([\d,]+)$/);
    var Experience = new Number(ExperienceMatch[1].replace(/,/g,''));
    var ExperienceNextLevel = new Number(ExperienceMatch[2].replace(/,/g,''));
    var ExperienceTable = {
      1 : 0,
      2 : 100,
      3 : 400,
      4 : 1002,
      5 : 1912,
      6 : 3140,
      7 : 4707,
      8 : 6641,
      9 : 8985,
      10 : 11795,
      11 : 15143,
      12 : 19121,
      13 : 23840,
      14 : 29437,
      15 : 36071,
      16 : 43930,
      17 : 43930, // Doesn't actually exist, but I needed to put something here
    };
    var DKs = (ExperienceNextLevel - ExperienceTable[Level+1]) / Level / 25;
    var ExperienceThisLevel = ExperienceTable[Level] + ((Level-1) * DKs * 25);
    var ExperienceTruancy = ExperienceTable[Level+2] + ((Level+1) * DKs * 25);
    var TruancyBarWidth = ((Experience - ExperienceNextLevel) / (ExperienceTruancy - ExperienceNextLevel)) * 100;
    if (TruancyBarWidth < 0) TruancyBarWidth = 0;
    if (TruancyBarWidth > 100) TruancyBarWidth = 100;
    var RemainderWidth = 100 - TruancyBarWidth;
    ExperienceRow.cells[1].innerHTML +=
      "<span class='colLtYellow'>" +
      "<table style='border: solid 1px #000000;' bgcolor='red'  cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='"+TruancyBarWidth+"%' bgcolor='"+(Experience>=ExperienceTruancy?'blue':'white')+"'></td><td width='"+RemainderWidth+"%'></td></tr></table>" +
      "</span>";
  }
}


 
Profile Email
Quote
bl0b
 Monday, August 16 2010 @ 03:20 AM UTC  
Forum Contender
Contender

Status: offline

Registered: 06/19/10
Posts: 66

Umm, not working for me. Don't know what I might be doing wrong.
Got Greasemonkey, restarted firefox, saved the script as test.user.js , opened it and greasemonkey recognised it. Went under Tools -> Greasemonkey to check it's enabled and the script is running and restarted firefox again.
Running fresh-from-the-box ubuntu 10, so it might need a bit of tweaking first, but javascript seems to be working ok.
Going to try windows later and report on results


 
Profile Email
Quote
Devin
 Monday, August 16 2010 @ 04:58 AM UTC  
Forum Contestant
Contestant

Status: offline

Registered: 06/17/10
Posts: 30

Probably some node or another not quite where it expects it - the whole thing's a bit of a house of cards with the way it navigates around the document. Let me know if you see anything in the Error Console, that'll probably be a big hint for where we're different.

Oh also, if you're not accessing II through http://improbableisland.com/ (like if you have a www), you might have to add your preferred prefix to the Included Pages section.


 
Profile Email
Quote
tehdave
 Monday, August 16 2010 @ 05:51 AM UTC  
Forum Improbable Badass
Improbable Badass

Status: offline

Registered: 12/17/09
Posts: 429

for those of us using www.improbableisland.com, add the line

// @include http://www.improbableisland.com/*

in the heading of it. And if anyone's running Ubuntu and doesn't know where the scripts are, they're in ~/.mozilla/firefox/{userid}/gm_scripts
For a fresh greasemonkey install, you can just add a folder named (whatever you want to name the script) and save the code as .user.js

Also: nifty addition, thanks Devin. Saves having to doublecheck my spreadsheet if I'm actually trying to optimize truancy Big Grin


Isn't sanity just a one-trick pony anyway? All you get is one trick: rational thinking. But when you're good and crazy, oooh, oooh, the sky's the limit.
 
Profile Email
Quote
bl0b
 Monday, August 16 2010 @ 07:54 AM UTC  
Forum Contender
Contender

Status: offline

Registered: 06/19/10
Posts: 66

This.

Quote by: DevinOh also, if you're not accessing II through http://improbableisland.com/ (like if you have a www), you might have to add your preferred prefix to the Included Pages section.[/p]


Tools -> Greasemonkey -> Manage User Scripts...
Under included pages click add. Address is going to be of the page you're currently on, paste the address and it's sorted. No need to restart firefox either.
Thank you both for help.

The added bar looks good. Nice one.


 
Profile Email
Quote
Buddleia
 Wednesday, October 13 2010 @ 05:30 PM UTC  
Forum Improbable Badass
Improbable Badass

Status: offline

Registered: 04/23/10
Posts: 343

I downloaded Greasemonkey, set up the script, and ... it's not working. The add-on is enabled, the script is enabled, there are no error messages, everything seems to be fine - but I have no second XP bar, before or after it goes blue.

I'm running Firefox 3.6.8 on Windows 7, and I've tried restarting it and restarting Windows and all sorts of nonsense.

What totally obvious thing have I missed?


Improbable Reference Links - goo.gl/MRBnb -------------- Land Registry (map of Places) ---- goo.gl/bpkRR
 
Profile Email Website
Quote
Maniak
 Wednesday, October 13 2010 @ 05:36 PM UTC  
Forum Improbable Badass
Improbable Badass

Status: offline

Registered: 10/11/10
Posts: 298

Quote by: Buddleia

I downloaded Greasemonkey, set up the script, and ... it's not working. The add-on is enabled, the script is enabled, there are no error messages, everything seems to be fine - but I have no second XP bar, before or after it goes blue.

I'm running Firefox 3.6.8 on Windows 7, and I've tried restarting it and restarting Windows and all sorts of nonsense.

What totally obvious thing have I missed?



Do you access Improbable Island on http://www.improbableisland.com or on http://improbableisland.com? Read the other posts in this thread, there is something relating to that. I got it working here after adding the extra www.


http://maniak.cu.cc/
 
Profile Email Website
Quote
Devin
 Wednesday, October 13 2010 @ 06:38 PM UTC  
Forum Contestant
Contestant

Status: offline

Registered: 06/17/10
Posts: 30

Quote by: Maniak

Do you access Improbable Island on http://www.improbableisland.com or on http://improbableisland.com? Read the other posts in this thread, there is something relating to that. I got it working here after adding the extra www.



Yeah, that's what it most commonly is. Here's a fixed version that defaults to using both:
http://gist.github.com/624609

I've been thinking about compressing the extra bar into a different-colored layer over the first, like Reverb suggested on the other thread. Maybe a nice cyan over the darker blue.


 
Profile Email
Quote
Buddleia
 Wednesday, October 13 2010 @ 08:32 PM UTC  
Forum Improbable Badass
Improbable Badass

Status: offline

Registered: 04/23/10
Posts: 343

I use www, but I've got both in the script header, with T'Dave's extra line. Like so


Improbable Reference Links - goo.gl/MRBnb -------------- Land Registry (map of Places) ---- goo.gl/bpkRR
 
Profile Email Website
Quote
Maniak
 Wednesday, October 13 2010 @ 09:39 PM UTC  
Forum Improbable Badass
Improbable Badass

Status: offline

Registered: 10/11/10
Posts: 298

Quote by: Devin



Yeah, that's what it most commonly is. Here's a fixed version that defaults to using both:
http://gist.github.com/624609

I've been thinking about compressing the extra bar into a different-colored layer over the first, like Reverb suggested on the other thread. Maybe a nice cyan over the darker blue.



Could you also be as awesome to add the number for the next level to it as well? Sometimes I'm really close to truancy and I'd like to know if I can do 1 or 2 more jungle fights and use the Dojo for healing. Staring at one or two pixels on the bar is rather unclear. A fixed number is more obvious.

And thanks for making this awesome script.


http://maniak.cu.cc/
 
Profile Email Website
Quote
Devin
 Wednesday, October 13 2010 @ 09:58 PM UTC  
Forum Contestant
Contestant

Status: offline

Registered: 06/17/10
Posts: 30

Quote by: Buddleia

I use www, but I've got both in the script header, with T'Dave's extra line. Like so



Hmm. Well, if it was originally installed without the extra line, it may still not have it under Included Pages on the Manage User Scripts page. If it is there, I'm not sure. Does it show up at the top of the menu when you right click the GreaseMonkey icon, or does it say nothing's installed?


 
Profile Email
Quote
Buddleia
 Thursday, October 14 2010 @ 09:48 AM UTC  
Forum Improbable Badass
Improbable Badass

Status: offline

Registered: 04/23/10
Posts: 343

Well, whatdoyaknow, it's working now. I right-clicked on the icon, it said Greasemonkey is enabled and the truancy meter was ticked for enabled, and nothing happened. But then I left-clicked, the icon turned brown instead of grey, and suddenly I has new XP bar. I don't understand, but then, with computers, do you ever? It's working! Thank you!


Improbable Reference Links - goo.gl/MRBnb -------------- Land Registry (map of Places) ---- goo.gl/bpkRR
 
Profile Email Website
Quote
tehdave
 Thursday, October 14 2010 @ 03:33 PM UTC  
Forum Improbable Badass
Improbable Badass

Status: offline

Registered: 12/17/09
Posts: 429

Quote by: Buddleia

Well, whatdoyaknow, it's working now. I right-clicked on the icon, it said Greasemonkey is enabled and the truancy meter was ticked for enabled, and nothing happened. But then I left-clicked, the icon turned brown instead of grey, and suddenly I has new XP bar. I don't understand, but then, with computers, do you ever? It's working! Thank you!



Yeah, greasemonkey was enabled but was toggled off. The monkey's gotta be in color (He's B&W sad if he's not being used)


Isn't sanity just a one-trick pony anyway? All you get is one trick: rational thinking. But when you're good and crazy, oooh, oooh, the sky's the limit.
 
Profile Email
Quote
Tahvohck
 Wednesday, November 10 2010 @ 08:50 AM UTC  
Forum Contender
Contender

Status: offline

Registered: 10/15/10
Posts: 65

Awesome, finally found a GM script that works with Improbable Island. Anyone know of any others?


 
Profile Email
Quote
Devin
 Tuesday, November 16 2010 @ 05:52 PM UTC  
Forum Contestant
Contestant

Status: offline

Registered: 06/17/10
Posts: 30

I haven't gotten around to dinking with the truancy meter again (I do like the ideas for enhancing it), but to help assuage my guilt, here's another script I've been using privately for quite a while. It adds a "what danquest are you on, and have you finished it" section to your stats without putting the load on the server like a php solution would. It recognizes nearly every quest-related event (I think it might be missing one or two varieties of you-found-an-item still). The name of the quest critter will be bold if it's the Big Bad Guy of the chain.

https://gist.github.com/702161


 
Profile Email
Quote
Maniak
 Tuesday, November 16 2010 @ 09:11 PM UTC  
Forum Improbable Badass
Improbable Badass

Status: offline

Registered: 10/11/10
Posts: 298

Nice. Glad that this exists now.

One small suggestion. It won't pick up my current quest. Not even after visiting the PSK.


You decide to ask Dan if he has heard any rumors.

He stares at you for a moment.

"What?" Dan leans over the bar towards you. "Did I hear you correctly? You want me to set you off on another crazy adventure, when you've not even finished the one you're already on?"
He smirks. "I'll bet you've not even gone to AceHigh yet."

Feeling kind of embarrassed, you wonder if you should ask Dan if you can start another mission, or if you should get on with the one that you're already on.


Another suggestion, or more a question. Does this show if you've collected your reward or not? Would be great if it could tell me that the quest is finished but that there is still a reward waiting.


http://maniak.cu.cc/
 
Profile Email Website
Quote
Tahvohck
 Tuesday, November 16 2010 @ 09:14 PM UTC  
Forum Contender
Contender

Status: offline

Registered: 10/15/10
Posts: 65

Here's my own modifications to the Truancy script:

PHP Formatted Code
// ==UserScript==
// @name Improbable Island Xp Bar
// @namespace http://www.shadedraco.com/improbabletruancy
// @include http://*improbableisland.com/*
// ==/UserScript==

var CharInfo = document.evaluate("//table[@class='charinfo']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if (CharInfo) {
  var LevelRow = document.evaluate("//td[@class='charinfo']/b/span[@class='colLtWhite'][text()='Level']/../../..", CharInfo, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
  if (LevelRow) {
    var Level = new Number(LevelRow.cells[1].childNodes[0].childNodes[0].textContent);
    var ExperienceRow = LevelRow.parentNode.rows[LevelRow.rowIndex+1];
    var ExperienceMatch = ExperienceRow.cells[1].childNodes[0].childNodes[0].textContent.match(/^([\d,]+)\/([\d,]+)$/);
    var Experience = new Number(ExperienceMatch[1].replace(/,/g,''));
    var ExperienceNextLevel = new Number(ExperienceMatch[2].replace(/,/g,''));
    var ExperienceTable = {
      1  : 0,
      2  : 100,
      3  : 400,
      4  : 1002,
      5  : 1912,
      6  : 3140,
      7  : 4707,
      8  : 6641,
      9  : 8985,
      10 : 11795,
      11 : 15143,
      12 : 19121,
      13 : 23840,
      14 : 29437,
      15 : 36071,
      16 : 43930,
      17 : 43930, // Doesn't actually exist, but I needed to put something here
    };
    var DKs = (ExperienceNextLevel - ExperienceTable[Level+1]) / Level / 25;
   
    //The various bars.------------------------------------------------
        //Truancy
    var ExperienceThisLevel = ExperienceTable[Level] + ((Level-1) * DKs * 25);
    var ExperienceTruancy = ExperienceTable[Level+2] + ((Level+1) * DKs * 25);
    var TruancyBarWidth = ((Experience - ExperienceNextLevel) / (ExperienceTruancy - ExperienceNextLevel)) * 100;
    if (TruancyBarWidth < 0) TruancyBarWidth = 0;
    if (TruancyBarWidth > 100) TruancyBarWidth = 100;
    var RemainderWidth = 100 - TruancyBarWidth;   
  if(Experience >= ExperienceNextLevel) {
    ExperienceRow.cells[1].innerHTML +=
      "<span class='colLtYellow'>" +
      "<table style='border: solid 1px #000000;' bgcolor='black' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='"+TruancyBarWidth+"%' bgcolor='"+(Experience>=ExperienceTruancy?'#00D000':'white')+"'></td><td width='"+RemainderWidth+"%'></td></tr></table>" +
      "</span>";}
       
        /*//Overall
        var ExperienceWin = ExperienceTable[15] + (14 * DKs * 25);
        var OverallWidth = (Experience / (ExperienceWin)) * 100;
        var OverRemaining = 100 - OverallWidth;
    LevelRow.cells[1].innerHTML +=
      "<span class='colLtYellow'>" +
      "<table style='border: solid 1px #000000;' bgcolor='red' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='"+OverallWidth+"%' bgcolor='"+(Experience>=ExperienceWin?'#00D000':'white')+"'></td><td width='"+OverRemaining+"%'></td></tr></table>" +
      "<br/></span>";
    //alert(ExperienceWin);*/

  }
}


I ended up adding a bit to it so it only shows the second bar if you've gone past what you need for the level you're on, and fiddled with the colors. The part commented out near the bottom--/*//Overall...Win);*/--adds a bar below your level number, showing you how far you have to go to level 15. Just remove the /* and */ to turn that part on.


 
Profile Email
Quote
Devin
 Tuesday, November 16 2010 @ 11:14 PM UTC  
Forum Contestant
Contestant

Status: offline

Registered: 06/17/10
Posts: 30

Quote by: Maniak

Nice. Glad that this exists now.

One small suggestion. It won't pick up my current quest. Not even after visiting the PSK.

Another suggestion, or more a question. Does this show if you've collected your reward or not? Would be great if it could tell me that the quest is finished but that there is still a reward waiting.



Yeah, I could add the picking up the current quest location after the first installation (going to the PSK would be the only way to get that info though). To your second question, yep, it'll show the quest with the status as "Completed" until you turn it in, after which it'll show no quest until you get a new one.


 
Profile Email
Quote
tehdave
 Wednesday, November 17 2010 @ 06:00 AM UTC  
Forum Improbable Badass
Improbable Badass

Status: offline

Registered: 12/17/09
Posts: 429

Quote by: Devin

I haven't gotten around to dinking with the truancy meter again (I do like the ideas for enhancing it), but to help assuage my guilt, here's another script I've been using privately for quite a while. It adds a "what danquest are you on, and have you finished it" section to your stats without putting the load on the server like a php solution would. It recognizes nearly every quest-related event (I think it might be missing one or two varieties of you-found-an-item still). The name of the quest critter will be bold if it's the Big Bad Guy of the chain.

https://gist.github.com/702161



Is there a way to transfer data between two computers? So I can track it back and forth from work and home?


Isn't sanity just a one-trick pony anyway? All you get is one trick: rational thinking. But when you're good and crazy, oooh, oooh, the sky's the limit.
 
Profile Email
Quote
Devin
 Wednesday, November 17 2010 @ 04:44 PM UTC  
Forum Contestant
Contestant

Status: offline

Registered: 06/17/10
Posts: 30

Quote by: tehdave

Is there a way to transfer data between two computers? So I can track it back and forth from work and home?



I wish there was, I have a similar issue. All the GM data is stored with other browser settings in prefs.js (A.K.A. about:config), so if you find a good way to synchronize that, this'll go along with it, but I haven't come across any really good solutions.


 
Profile Email
Quote
Content generated in: 1.66 seconds
New Topic Post Reply



 All times are UTC. The time is now 11:15 AM.

Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content