Subject: A Greasemonkey Script: Truancy Meter

Posted on: August 16 2010 @ 01:56 AM
By: Devin

Content:

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>";
  }
}



Replies:

Re: A Greasemonkey Script: Truancy Meter

Posted on: August 16 2010 @ 03:20 AM
By: bl0b

Content:

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


Re: A Greasemonkey Script: Truancy Meter

Posted on: August 16 2010 @ 04:58 AM
By: Devin

Content:

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.


Re: A Greasemonkey Script: Truancy Meter

Posted on: August 16 2010 @ 05:51 AM
By: tehdave

Content:

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


Re: A Greasemonkey Script: Truancy Meter

Posted on: August 16 2010 @ 07:54 AM
By: bl0b

Content:

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.


Re: A Greasemonkey Script: Truancy Meter

Posted on: October 13 2010 @ 05:30 PM
By: Buddleia

Content:

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?


Re: A Greasemonkey Script: Truancy Meter

Posted on: October 13 2010 @ 05:36 PM
By: Maniak

Content:

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.


Re: A Greasemonkey Script: Truancy Meter

Posted on: October 13 2010 @ 06:38 PM
By: Devin

Content:

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.


Re: A Greasemonkey Script: Truancy Meter

Posted on: October 13 2010 @ 08:32 PM
By: Buddleia

Content:

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


Re: A Greasemonkey Script: Truancy Meter

Posted on: October 13 2010 @ 09:39 PM
By: Maniak

Content:

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.


Re: A Greasemonkey Script: Truancy Meter

Posted on: October 13 2010 @ 09:58 PM
By: Devin

Content:

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?


Re: A Greasemonkey Script: Truancy Meter

Posted on: October 14 2010 @ 09:48 AM
By: Buddleia

Content:

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!


Re: A Greasemonkey Script: Truancy Meter

Posted on: October 14 2010 @ 03:33 PM
By: tehdave

Content:

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)


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 10 2010 @ 08:50 AM
By: Tahvohck

Content:

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


Another Greasemonkey Script: Quest Tracker

Posted on: November 16 2010 @ 05:52 PM
By: Devin

Content:

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


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 16 2010 @ 09:11 PM
By: Maniak

Content:

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.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 16 2010 @ 09:14 PM
By: Tahvohck

Content:

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.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 16 2010 @ 11:14 PM
By: Devin

Content:

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.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 17 2010 @ 06:00 AM
By: tehdave

Content:

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?


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 17 2010 @ 04:44 PM
By: Devin

Content:

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.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 17 2010 @ 04:47 PM
By: tehdave

Content:

Quote by: Devin

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.



Another downside is multiple characters doesn't work...unless you install the script twice (once for www.improbableisland.com/* and again for improbableisland.com/*) and use either one all the time for the given character. Otherwise the script saves the same quest info across the board.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 17 2010 @ 05:20 PM
By: Devin

Content:

Quote by: tehdave

Another downside is multiple characters doesn't work...unless you install the script twice (once for www.improbableisland.com/* and again for improbableisland.com/*) and use either one all the time for the given character. Otherwise the script saves the same quest info across the board.



That, I should be able to fix. At the very least, I can teach the script to store different values for www. and not (and any other subdomain you @include it on).


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 17 2010 @ 07:12 PM
By: blob

Content:

or you can use opera and firefox at the same time, one for each character.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 18 2010 @ 03:11 AM
By: Matthew

Content:

Just so you guys know, Chrome now supports Greasemonkey scripts natively. Tested and it works fine.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 18 2010 @ 05:38 PM
By: tehdave

Content:

Quote by: blob

or you can use opera and firefox at the same time, one for each character.



what if I'm RPing 6 characters at once? I need all 3 of my browsers to run them all!

(Note: this is not recommended for sanity's sake...)


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 18 2010 @ 07:40 PM
By: Tahvohck

Content:

Quote by: tehdave

Quote by: blob

or you can use opera and firefox at the same time, one for each character.



what if I'm RPing 6 characters at once? I need all 3 of my browsers to run them all!

(Note: this is not recommended for sanity's sake...)



Dave, I'm pretty sure that would cause badnav problems, no matter how you look at it.

As for separating characters, add a piece into the code that gives you a greasmonkey user script command to change the current character, and save the monster variables, etc. as whatever.charactername.variable. Note: I know this can be done, I don't know the specific code for it. Sorry.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 18 2010 @ 08:11 PM
By: tehdave

Content:

Quote by: Tahvohck

Quote by: tehdave

Quote by: blob

or you can use opera and firefox at the same time, one for each character.


what if I'm RPing 6 characters at once? I need all 3 of my browsers to run them all!
(Note: this is not recommended for sanity's sake...)


Dave, I'm pretty sure that would cause badnav problems, no matter how you look at it.



Not true. www.improbableisland.com and improbableisland.com are different sessions. that means you can log in on two different characters in the same browser. (but not more)

In other news, I like the idea of a separate saved variable file per character. Is there a way to automate that at all?


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 18 2010 @ 08:55 PM
By: Tahvohck

Content:

Quote by: tehdave

Not true. www.improbableisland.com and improbableisland.com are different sessions. that means you can log in on two different characters in the same browser. (but not more)

In other news, I like the idea of a separate saved variable file per character. Is there a way to automate that at all?
[/p]


Ohh, that's good to know.

And I can't think of a way to automate it, as there doesn't appear to be anywhere that an unchanging but character-specific code/line of text/thingie is on any of the pages, unless we can convince CMJ to add the character's name to the "Vital info" table. Like I said before, though, you could add a dropdown menu to change characters, or a script command to the same effect.

Oh, and you wouldn't have to install the script twice. Just install it for *improbableisland.com/* and it will automatically work for both.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 18 2010 @ 09:25 PM
By: tehdave

Content:

Quote by: Tahvohck

Quote by: tehdave
Not true. www.improbableisland.com and improbableisland.com are different sessions. that means you can log in on two different characters in the same browser. (but not more)
In other news, I like the idea of a separate saved variable file per character. Is there a way to automate that at all?

Ohh, that's good to know.

And I can't think of a way to automate it, as there doesn't appear to be anywhere that an unchanging but character-specific code/line of text/thingie is on any of the pages, unless we can convince CMJ to add the character's name to the "Vital info" table. Like I said before, though, you could add a dropdown menu to change characters, or a script command to the same effect.

Oh, and you wouldn't have to install the script twice. Just install it for *improbableisland.com/* and it will automatically work for both.



The only problem with *improbableisland.com/* is that the script would attempt to run on enquirer.improbableisland.com and labs.improbableisland.com

The only reason to install it twice would be to set up two different variable files for different characters (if you use the naked domain for one specifically, and the www domain for another) if the character switcher isn't implemented (in current form, for instance)


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 18 2010 @ 09:55 PM
By: Tahvohck

Content:

Ah, right, didn't think of it that way.

Alternatively, add an exclude line for those two, but at that point it's more trouble than it's worth. Though are there any nodes the script could attach to on the enquirer/labs?


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 19 2010 @ 06:46 PM
By: tehdave

Content:

Quote by: Tahvohck

Ah, right, didn't think of it that way.

Alternatively, add an exclude line for those two, but at that point it's more trouble than it's worth. Though are there any nodes the script could attach to on the enquirer/labs?



No idea, but why risk breaking something when it's just as much work either way?

On another note: Is there a way, with your change to the Truancy Script, to add markers to the "overall" bar at each level?
I'd do it myself, but I'm terrible at code.. one of those things I've always meant to try and pick up and run with...wonder if it could be designed maybe with just a bunch of bars sitting next to each other?


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 20 2010 @ 01:50 PM
By: Swede

Content:

Quote by: Matthew

Just so you guys know, Chrome now supports Greasemonkey scripts natively. Tested and it works fine.



Thanks. I didn't knew that and was running Firefox next to Chrome.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 20 2010 @ 08:01 PM
By: Tahvohck

Content:

Quote by: tehdave
On another note: Is there a way, with your change to the Truancy Script, to add markers to the "overall" bar at each level?
I'd do it myself, but I'm terrible at code.. one of those things I've always meant to try and pick up and run with...wonder if it could be designed maybe with just a bunch of bars sitting next to each other?[/p]


Short answer: Yes, but I'm lazy.

Long answer: Yes, and I'm probably going to add it at some point, but that will be a lot of coding, enough--at my current knowledge level--to double the length of the code, at least. As it stands, each "bar" is actually a table with two different colored columns, scaled to be the right sizes. So a broken bar would be at least 16 columns, each one having to be scaled per DK. Also, you may have noticed this by now, but the first 7 levels are only the first 10th of the bar, so it may not even be a good idea.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 21 2010 @ 01:54 AM
By: Devin

Content:

Quote by: tehdave

Quote by: blob

or you can use opera and firefox at the same time, one for each character.



what if I'm RPing 6 characters at once? I need all 3 of my browsers to run them all!

(Note: this is not recommended for sanity's sake...)



I've found that seasonone.improbableisland.com and seasontwo.improbableisland.com both work too. Mr. Green


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 21 2010 @ 11:27 AM
By: Maniak

Content:

Quote by: Devin

Quote by: tehdave

Quote by: blob

or you can use opera and firefox at the same time, one for each character.



what if I'm RPing 6 characters at once? I need all 3 of my browsers to run them all!

(Note: this is not recommended for sanity's sake...)



I've found that seasonone.improbableisland.com and seasontwo.improbableisland.com both work too. Mr. Green



Finally, 12 characters to roleplay simultaneous!


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 21 2010 @ 01:12 PM
By: Matthew

Content:

Quote by: Maniak

Finally, 12 characters to roleplay simultaneous!


I'd be pretty impressed, actually.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 23 2010 @ 11:28 AM
By: bl0b

Content:

Greasemonkey script that reduces the size of bars in your backpack. Useful if you have hundreds of cards for instance.
Let me know if you guys have any problems with it.


PHP Formatted Code
// ==UserScript==
// @name           freezingcold
// @description    reduce the backpack stretchiness
// @include        http://improbableisland.com/*
// @include        http://www.improbableisland.com/*
// ==/UserScript==



window.bytes_new_width = function()
{
        // Define new size. Each kg = 5
        var new_size = 50; //could even go all the way up to 1000
        // get the main table and reset its width
        var tbl = document.getElementsByTagName('table');
        var l = tbl.length;
        for (var i=0; i<l; i++)
        {
                //table hight of 5 is the one for backpacks
                if (tbl[i].getAttribute("height")==5){
                        if (tbl[i].getAttribute("width") > 100)
                        {
                                tbl[i].setAttribute("width", new_size);
                        }
                }
        }
}
window.addEventListener("load", window.bytes_new_width, false);


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 23 2010 @ 01:30 PM
By: Matthew

Content:

Quote by: bl0b

Greasemonkey script that reduces the size of bars in your backpack. Useful if you have hundreds of cards for instance.
Let me know if you guys have any problems with it.


It's like my prayers have been answered! This works perfectly, thank you. (Kind of funny timing, though; I'd just turned in my huge card hand. Oh well... I'll just assume it works for that, too.)


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 23 2010 @ 02:20 PM
By: bl0b

Content:

Should work for all bars with height attribute = 5, meaning all weight bars and even experience bar, midget rage bar and adrenaline pack bars and others that I can't remember now. So if you want, you can make those reeeeeeeeeeally tiny.

If you want bars a bit bigger, you'd have to fiddle with the numbers a bit for that.
If you change the number 50 and number 100 to 400, then the maximum bar length you get is the same as the length of 80 kg backpack, which should be just right. Or maybe change it to 500, to have the cap at 100 kg. Depending on personal preferences.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 27 2010 @ 12:28 AM
By: Tahvohck

Content:

Hey bl0b, just wondering, but what's the point of the for() loop? I don't see any reason for that to be there.

Also, if you don't mind, I'm going to add in a Greasemonkey command to change the bar length on the fly, so you don't have to edit the code to change the length.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 27 2010 @ 10:45 AM
By: blob

Content:

The way I understand it, function document.getElementsByTagName() returns an array of elements. In this case, elements of the array are tables, hence the attribute 'table'. The for-loop goes through each element in the array, as there will always be more than one table.
The document.get... grabs a list of elements, and then to weed out those elements, I use a for-loop.So, basically, where devin is using xpath, I'm using document.get, and where he's using document.evaluate, I'm using a for-loop.

The reason I'm saying people could change numbers is because I think they might prefer a different maximum length to the bars compared the way they are set up in the code. So, if you change numbers 50 and 100 to 500, that would mean maximum bar length you get to see is 100kg. Having a bigger backpack won't affect the length of the bar, it will just stay a constant.
One other thing I could perhaps add, is the @include lines should be replaced to look like this.
// @include http://improbableisland.com/inventory.php?items_context=*
// @include http://www.improbableisland.com/inventory.php?items_context=*
This will make sure the script only gets executed when looking the inventory. (a bit of testing is advised, but I think this should work)

If you can do something that alters the code on the fly, and if you can store those parameters as well, that would be awesome. Been trying to find a way to do that for a while now. Didn't even think userscripts allowed you to do that. From what I understand, you can only change temporary values, and even that, only for each window separately. But as I say, I don't really know much on userscripts. I'd love to see it, if you get it working.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 27 2010 @ 07:26 PM
By: Tahvohck

Content:

Ah, I see it now. Okay then, here's the new code:

PHP Formatted Code
// ==UserScript==
// @name           Improbable Island Bar Limiter
// @namespace     *
// @description    Bar Limiter. Credit to bl0b, modified by Tahvohck
// @include        http://*.improbableisland.com/*
// @exclude        http://enquirer.improbableisland.com/*
// @exclude        http://labs.improbableisland.com/*
// ==/UserScript==

function Changecutoff(){
    var change, err_c;
    err_c = 5 * prompt("Start limiting at how many kilograms?");
    if (err_c == null || err_c == ""){err_c = 250;}
    change = err_c;
    GM_setValue("Cutoff", change);
    alert("Bar will now cut off at " + change/5 + "kg.");
}
         
function Changelength(){
    var change, err_c;
    err_c = 5 * prompt("Limit to how many kilograms?");
    if (err_c == null || err_c == ""){err_c = 250;}
    change = err_c;
    GM_setValue("Length", change);
    alert("Bar will now be changed to " + change/5 + "kg long after cutoff.");
}

window.bytes_new_width = function(){
    // Define new size. Each kg = 5
    var new_size = GM_getValue("Length", 250); //could even go all the way up to 1000
    var cutoff = GM_getValue("Length", 250);
    // get the main table and reset its width
    var tbl = document.getElementsByTagName('table');
    var l = tbl.length;
    for (var i=0; i<l; i++){
                //table hight of 5 is the one for backpacks
                if (tbl[i].getAttribute("height")==5){
                        if (tbl[i].getAttribute("width") > cutoff){
                                tbl[i].setAttribute("width", new_size);
                        }
        }
    }
}
window.addEventListener("load", window.bytes_new_width, false);

GM_registerMenuCommand("Change length", Changelength,"","","l");
GM_registerMenuCommand("Change cutoff", Changecutoff,"","","c");
 


In order to change the bar length and cutoff, go to Greasemonkey(either in the tools menu or by right-clicking the monkey) > User Script Commands > appropriate command. The bar will update next time you load the page. Note that if you enter nothing into the prompts, they will default to 50kg, and if you don't run both prompts at least once after adding the script, it will also default to 50kg.

bl0b, the commands you're looking for to permanently store values(stored in about:config) are GM_setValue() and GM_getValue(). Also of note is GM_registerMenuCommand(), the code to add a User Command.

Damn, but that got long fast.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 29 2010 @ 11:29 AM
By: blob

Content:

Hmm. Apparently Opera doesn't do any GM_ functions by default.
There's an emulator for that though.

Stolen from this site:
(right-click, save in your Opera userscript folder)
http://www.howtocreate.co.uk/operaStuff/userjs/aagmfunctions.js

With that, most of scripts should work pretty sweet. There are some exceptions though.
The good part of it is that your values won't stay in your about:config forever Razz The bad part, when you clear cookies, values get deleted as well.

Then about the @include:
// @include http://improbableisland.com/inventory.php?items_*
// @include http://www.improbableisland.com/inventory.php?items_*

This should make sure to trigger the script only while looking the inventory, without exploding again when for instance transferring, discarding or using an item.

And now back to commenting the script.

When you're defining variables, you have:
var new_size = GM_getValue("Length", 250);
var cutoff = GM_getValue("Length", 250);

One of them should be "cutoff"

Then after that, add an if-statement Like so:

PHP Formatted Code
if (tbl[i].getAttribute("height")==5){
                if (tbl[i].getAttribute("width") > cutoff){
                        if (cutoff<new_size){new_size=cutoff};
                        tbl[i].setAttribute("width",new_size);
        }



The reason is so that if, for instance, limit is set to 10 kg, and 'cutoff' set to 50, your backpack doesn't instantly jump to 50 when having a backpack(bandolier) of 11kg.

Also, you might want to try and leave values unchanged, if user simply clicks ok on prompt without entering a value. That, and I think only one value is really needed, no need to use both. Loving modifications by the way.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 30 2010 @ 03:15 AM
By: Matthew

Content:

As per this thread here, I have a request.

I don't suppose a Greasemonkey script could hide the "Jungle" link on all the pages in which it appears, could it? It would be useful to temporarily install when you really want to avoid the Jungles but can't beat your habit of clicking it.

Edit: Or at least put it in flashing DON'T CLICK THIS colors. That'd help, too.


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 30 2010 @ 08:20 AM
By: Matthew

Content:

Hahaha NEVERMIND

See, it's funny, because... eh... heeeeeeeeeeeh.

Yes... right.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 07 2010 @ 03:40 PM
By: Tahvohck

Content:

Okay, sorry for the long response. Here's the updated code, that'll only execute at inventory, and only for inventory bars.

PHP Formatted Code
// ==UserScript==
// @name           Improbable Island Bar Limiter
// @description    Bar Limiter. Credit to bl0b, modified by Tahvohck
// @include        http://*.improbableisland.com/inventory.php?*
// @exclude        http://enquirer.improbableisland.com/*
// @exclude        http://labs.improbableisland.com/*
// ==/UserScript==

function Changecutoff(){
    var change, err_c;
    err_c = 5 * prompt("Start limiting at how many kilograms?");
    if (err_c == null || err_c == ""){err_c = 250;}
    change = err_c;
    GM_setValue("Cutoff", change);
    alert("Bar will now cut off at " + change/5 + "kg.");
    resize()
}
         
function Changelength(){
    var change, err_c;
    err_c = 5 * prompt("Limit to how many kilograms?");
    if (err_c == null || err_c == ""){err_c = 250;}
    change = err_c;
    GM_setValue("Length", change);
    alert("Bar will now be changed to " + change/5 + "kg long after cutoff.");
    resize()
}


function resize(){
    Content = document.evaluate("//td[@class='content']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
    if(Content){
        // Define new size. Each kg = 5
        var new_size = GM_getValue("Length", 250); //could even go all the way up to 1000
        var cutoff = GM_getValue("Cutoff", 250);
        // get the main table and reset its width
        var tbl = document.getElementsByTagName('table');
        var l = tbl.length;
        for (var i=0; i<l; i++){
            //table hight of 5 is the one for backpacks
            if (tbl[i].getAttribute("height")==5){
                if(cutoff<new_size){cutoff=new_size} //to keep from premature resizing
                if (tbl[i].getAttribute("width") > cutoff){
                    tbl[i].setAttribute("width", new_size);
                }
            }
        }
    }
}
window.addEventListener("load", resize, false);

GM_registerMenuCommand("Change length", Changelength,"","","l");
GM_registerMenuCommand("Change cutoff", Changecutoff,"","","c");
 


The if-statement is in there too, but a little higher than you suggested, since you misread the variables--"Cutoff" is the length it starts changing at, not what it changes to.

Okay, and as a brief reminder, here's the scripts we've discussed so far, just click to install.

Add a second experience bar for truancy:
Truancy Bar

Track your current quest:
Quest Tracker

Limit the size of your inventory bars:
Bar limiter

And one more of my own, it checks if you have mail and adds a small alert in the bottom-right of your browser if you do--I'd like feedback on this one:
Mail Check

And here's the source for that last one:
PHP Formatted Code
// ==UserScript==
// @name           Improbable Island Alert Checker
// @description    Checks to see if you have mail, and adds an alert if you do.
// @include        http://*improbableisland.com/*
// @exclude        http://labs.improbableisland.com/*
// @exclude        http://enquirer.improbableisland.com/*
// ==/UserScript==
var Mail;

var Havemail = document.evaluate("//a[@href='mail.php'][@class='hotmotd']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if (Havemail) {
    var Body = document.evaluate("//body", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
    if (Body){
        Body.innerHTML += '<div style="position:fixed; right:30px;bottom:30px; border-style:dotted; border-width:1px; background:url(http://improbableisland.com/templates/dragonleather/mainbg.jpg);"><a target="_blank" href="http://improbableisland.com/mail.php">You have mail!</a></div>';
    }
}
 


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 01:04 AM
By: Buddleia

Content:

I love these scripts. They make II so much more user-friendly, and thank you all for writing them. But, as of today, I seem to have three XP bars. The third appears to be a copy of the second, filling at the same rate. Wut?


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 02:05 AM
By: Matthew

Content:

For some reason, none of the inventory limiter scripts posted actually work for me. 90% of the time, they just refuse to hook into the page, and it mystifies me.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 05:51 AM
By: Tahvohck

Content:

Buddella:

I love these scripts. They make II so much more user-friendly, and thank you all for writing them. But, as of today, I seem to have three XP bars. The third appears to be a copy of the second, filling at the same rate. Wut?


Um...*checks source*....Yeeeaah. Shouldn't be happening. So. Do me a favor, go to where Firefox stores your scripts--C:\Users\[you]\AppData\Roaming\Mozilla\Firefox\Profiles\[numbers].[probably defualt]\gm_scripts, if you're on Win 7, I'll have to check if not--and find the script. It'll be in a folder called [something about XP or Truancy] and email a copy of the .user.js file inside, to [me]@gmail.com. I'll see if there's something wrong with it.


Matthew:
For some reason, none of the inventory limiter scripts posted actually work for me. 90% of the time, they just refuse to hook into the page, and it mystifies me.


Huh. First thought that comes to mind. You are running this on Firefox, latest version, right? (Assuming yes, stupid question, moving on.) Second thought. Go to your inventory. Open the Error console, Tools>Error Console. Clear it, reload the page, through one of the links. Post any errors it reports on here, specifically any that seem to be related to the script. And we'll go from there.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 05:57 AM
By: Matthew

Content:

Quote by: Tahvohck

Huh. First thought that comes to mind. You are running this on Firefox, latest version, right? (Assuming yes, stupid question, moving on.) Second thought. Go to your inventory. Open the Error console, Tools>Error Console. Clear it, reload the page, through one of the links. Post any errors it reports on here, specifically any that seem to be related to the script. And we'll go from there.



Actually, right now, I have to use SRWare Iron (chrome, basically) for the Island because the latest Firefox update made the Island run terribly for whatever reason.

edit: Chrome DOES natively support Greasemonkey scripts. I installed the same scripts on firefox, though, and they still don't work.

edit edit: Scratch that, it does work in Firefox, but not Chrome. Which is really weird, because the rest of the scripts - Truancy Bar, Mail Alert, etc - all work perfectly. Does the backpack limiter use a command that Firefox accepts but Chrome does not? And even if that were the case, that doesn't explain why it still does work in Chrome, rarely!

I am so confused.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 06:09 AM
By: Tahvohck

Content:

Okay then. Lesse. Here's the thing. Chrome does support Greasemonkey scripts, yeah, but not Greasemonkey-specific functions, like GM_setValue(), which the script uses to allow it to make on-the-fly changes. At least, the version I messed with. If you can edit the code--you should be able to, tell it to open with notepad/wordpad--try changing code to this:

PHP Formatted Code

Content = document.evaluate("//td[@class='content']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
    if(Content){
        // Define new size. Each kg = 5
        var new_size = 250; //could even go all the way up to 1000
        var cutoff = 250;
        // get the main table and reset its width
        var tbl = document.getElementsByTagName('table');
        var l = tbl.length;
        for (var i=0; i<l; i++){
            //table hight of 5 is the one for backpacks
            if (tbl[i].getAttribute("height")==5){
                if(cutoff<new_size){cutoff=new_size} //to keep from premature resizing
                if (tbl[i].getAttribute("width") > cutoff){
                    tbl[i].setAttribute("width", new_size);
                }
            }
        }
    }
 


It's basically the original code, but it's worth a shot. We'll see how it pans out.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 06:10 AM
By: Iriana

Content:

I installed the XP bar, the Quest tracker, and the inventory limiter. The XP bar works great! But the Quest tracker displayed "None", even though I doublechecked at the PSK and did have a quest. Then I abandoned that quest and now it displays the new one properly. (If there's any information that I should have recorded... sorry. Forgot. D: )

The inventory limiter won't install, period. That might just be my computer though.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 06:15 AM
By: Tahvohck

Content:

Quote by: Iriana

Then I abandoned that quest and now it displays the new one properly. (If there's any information that I should have recorded... sorry. Forgot. D: )

The inventory limiter won't install, period. That might just be my computer though.


Yeah, the quest tracker only activates when you get the quest. It pulls information from that page to tell it what your quest is.

As for the limiter...Hmm. Try right-clicking it, selecting "View Script source" and manually adding it through GM's "new script" function. Not sure what else to suggest.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 06:20 AM
By: Matthew

Content:

Quote by: Tahvohck

It's basically the original code, but it's worth a shot. We'll see how it pans out.


Yeah, this works, thank you. It still doesn't explain why the other would still work on Chrome on rare occasions, though... so I'm still pretty confused. Oh well, I guess I can't complain that it's working now!

Believe me, if I could still use FF for the Island, I most certainly would. Until a new update for it fixes the horrendous typing lag problem, though, I'm stuck. Still use FF for everything else, though.

reposting from the last page because you probably won't see it if I don't:
Quote by: Matthew

edit edit: Scratch that, it does work in Firefox, but not Chrome. Which is really weird, because the rest of the scripts - Truancy Bar, Mail Alert, etc - all work perfectly. Does the backpack limiter use a command that Firefox accepts but Chrome does not? And even if that were the case, that doesn't explain why it still does work in Chrome, rarely!

I am so confused.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 06:29 AM
By: Tahvohck

Content:

Good to hear, Matthew. And if you want to change the cutoff size, you'll have to change it manually, by changing the values:

PHP Formatted Code
var new_size = [number]
var cuttoff = [number]

Just remember to multiply the kilograms you want by five.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 07:02 AM
By: blob

Content:

@ tahvock
In the links you post, bar limiter links to the same script as truancy bar

@ buddlea
One of your scripts is a copy. Might have happened if you simpy installed what tahvock posted.
If that is the case, remove that one from your userscripts, then select one of the bar limiters posted in this thread and save it as .user.js and open it with firefox.

@iriana
That's how the quest script works. It doesn't detect the quest you're currently on when you first install it. Should work fine after that.. And for bar limiter, see above.

@Matthew
Tried Opera yet? Razz


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 07:14 AM
By: Tahvohck

Content:

Derp. *Facepalm* Well I feel like an idiot now. Here's the proper links.

Truancy Bar
Quest Tracker
Bar limiter
Mail Check


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 08:36 AM
By: Iriana

Content:

:'D Clearly I need to look at what I'm installing next time.

Thanks, bl0b and Tahvohck! Everything works beautifully now.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 10:34 AM
By: Tahvohck

Content:

So I'm gonna put this out there before even thinking about starting, but who would be interested in a rail pass calculator? As in, it reads the cards you have, and tells you how many rail passes you could get?


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 11:46 AM
By: Maniak

Content:

There are plenty of stations strategically placed throughout the island where you can get the information. You'll only dumb us down with such a script.

I do have a different train-related idea. When you're traveling first class, you can request a stop and you have to enter coordinates. Can you make a list of favorites to input? I'd love to be able to travel to my own dwelling without that pesky stuff of remembering and entering coords, or landing exactly on Pleasantville or Squat Hole without all that hard work of walking for 1 or 2 squares.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 12:00 PM
By: Matthew

Content:

Yes, I have to agree on both accounts. A rail pass counter seems a little bit pointless. And... perhaps there could be a way to view an Island map, with coordinates and all, from the Request Stop page?


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 07:09 PM
By: Tahvohck

Content:

Mm, Fair. Just an idea that passed through. As for the favorites...yeah, you could, but I have only half an idea how, and for adding a map...yeah, I should be able to do that, though I'd need to get another first-class to test both ideas properly, so those might be a while coming, unless someone else programs them. However, once I do get a first-class, expect the map quickly, cause that's something I'd want as well.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 08:06 PM
By: Maniak

Content:

Sent you a distraction, in case you need some cards.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 08:15 PM
By: Count+Sessine

Content:

Quote by: Tahvohck

Mm, Fair. Just an idea that passed through. As for the favorites...yeah, you could, but I have only half an idea how, and for adding a map...yeah, I should be able to do that, though I'd need to get another first-class to test both ideas properly, so those might be a while coming, unless someone else programs them. However, once I do get a first-class, expect the map quickly, cause that's something I'd want as well.

I know there are map copies easily available, lots of places on the web. Myself, I long ago did a Grab screen capture and saved the file locally -- in fact, mine is from early Season One. Still, technically, characters aren't supposed to have the official map unless they've paid their 10K... The only difference is that the live map in the game shows you coordinates in a tooltip on mouse-over.

Is the map a feature that would be worth adding to the game's request stop logic? Or is a Greasemonkey script sufficient?


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 08:20 PM
By: Buddleia

Content:

Quote by: blob

@ buddlea
One of your scripts is a copy. Might have happened if you simpy installed what tahvock posted.
If that is the case, remove that one from your userscripts, then select one of the bar limiters posted in this thread and save it as .user.js and open it with firefox.


If it is, then that's not fair. I hadn't installed any more scripts recently, and it just started doing this last night.

Anyway, in case that was the problem, I uninstalled all my scripts, and then got the lastest versions from

Quote by: Tahvohck

Derp. *Facepalm* Well I feel like an idiot now. Here's the proper links.

Truancy Bar
Quest Tracker
Bar limiter
Mail Check


This ... doesn't seem to have helped. I still have a pair of the extra XP bars. They're in the wrong place, too. The third one appears about a second after the second.





-----------------------------------------------------------------------------------------------------------------------------------

Moving on to another topic:

Quote by: Matthew

And... perhaps there could be a way to view an Island map, with coordinates and all, from the Request Stop page?


For this, maybe something like http://bitwise-guy.com/improbable/ci/map? I think it was Beeps made this, can't remember (sorry!).


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 08:27 PM
By: Tahvohck

Content:

Well, Sessine, I guess it depends on whether you only want those who've bought the map to be able to see it. If you do, then it'd be nice to have it built into the game, as a "you pull out your map to decide" sorta thing. If you don't care, then it wouldn't be that hard to do as a GM script: just take the HTML table for the map in-game, do a search for the appropriate spot to add it to, and "paste" it in. It could even be explained in-game: there's a map on the wall for just this occasion.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 12 2010 @ 11:06 PM
By: Iriana

Content:

I know many Rookies consider the map a pretty big deal and actually have to decide between buying higher-grade equipment or getting a map, so perhaps it should remain something you should have only if you've paid for it. Even though it's a very poorly kept secret that there are screenshots of it all over the place. It's the spirit of the thing, you know?

But it would be nice to have a way to view the map (if you've bought it) from the first-class stop selection screen, so you can pick coordinates more easily. It's not fun to misremember your stop and have to hike back to a station.


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 13 2010 @ 12:40 AM
By: Matthew

Content:

Quote by: Buddleia


For this, maybe something like http://bitwise-guy.com/improbable/ci/map? I think it was Beeps made this, can't remember (sorry!).

Goodness, that's the second time I've asked for something that someone else has already done.

Thank you!


Re: A Greasemonkey Script: Truancy Meter

Posted on: December 13 2010 @ 09:55 AM
By: Tahvohck

Content:

Buddleia, I can't find anything that would be causing that problem, so I honestly don't know what to say. And I couldn't do anything more without being able to see your version of the script (shouldn't be a problem if you got it from my link) or being able to go through your computer and look at things like the error console (ain't gonna happen, and probably wouldn't help anyway). Sorry.


Re: A Greasemonkey Script: Truancy Meter

Posted on: January 31 2011 @ 04:45 PM
By: Makiwa

Content:

I know this is an old thread, just took me a while to get round to trying the scripts.

A big thank you to those involved in providing/tuning the scripts. I'm using them with Chrome without issues.

Great stuff! Big Grin


Re: A Greasemonkey Script: Truancy Meter

Posted on: February 04 2011 @ 02:41 PM
By: Maniak

Content:

I tinkered with the Truancy Bar a bit. Don't you love open-source?

New features:
An extra truancy bar starts filling up after you filled the first truancy bar.
Mouse-over the truancy bar and it shows you how much experience is required to fill it.

Tinkered with the colors a bit. The truancy bar fills white on a red background, then turns green once it's filled. It's the same color green that is used for the stamina and health bar, to give it a more unified look.

Code below. Remove the /* */ to activate the Overall exp bar.

PHP Formatted Code

// ==UserScript==
// @name Improbable Island Xp Bar
// @namespace http://www.shadedraco.com/improbabletruancy
// @description    Improbable Island Truancy Meter. Credit to Devin, modified by Tahvohck and Maniak
// @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, //800
      3  : 400, // 1800
      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;' title='"+ExperienceTruancy+"' bgcolor='red' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='"+TruancyBarWidth+"%' bgcolor='"+(Experience>=ExperienceTruancy?'#00FF00':'white')+"'></td><td width='"+RemainderWidth+"%'></td></tr></table>" +
      "</span>";}
          
                //Next Truancy
        var ExperienceNextTruancy = ExperienceTable[Level+2] + ((Level+2) * DKs * 25);
        var ExperienceLevelAfterThat = ExperienceTable[Level+3] + ((Level+2) * DKs * 25);
        var NextTruancyBarWidth = ((Experience - ExperienceNextTruancy) / (ExperienceLevelAfterThat - ExperienceNextTruancy)) * 100;
        if (NextTruancyBarWidth < 0) NextTruancyBarWidth = 0;
    if (NextTruancyBarWidth > 100) NextTruancyBarWidth = 100;
  if(Experience >= ExperienceTruancy) {
      ExperienceRow.cells[1].innerHTML +=
      "<span class='colLtYellow'>" +
          "<table style='border: solid 1px #000000;' title='"+ExperienceLevelAfterThat+"' bgcolor='red' cellpadding='0' cellspacing='0' width='70' height='5'><tr><td width='"+NextTruancyBarWidth+"%' bgcolor='"+(Experience>=ExperienceLevelAfterThat?'#00FF00':'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;' title='"+ExperienceWin+"' 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);  */

  }
}


Re: A Greasemonkey Script: Truancy Meter

Posted on: February 07 2011 @ 02:51 PM
By: Tahvohck

Content:

Yes I do love open source, Maniak. I'd been trying to do exactly that but couldn't get it to scale the second bar properly. I'll add that to the cache I've got set up for them once I've got a few minutes of free time, as well as a sorta-in-beta script I've got that reads the newday page for important information and saves it. (I'd like feedback on that one, especially suggestions for other things it should read.) Also, I know someone was looking for a script that removed the dotted lines under player's names in the chat, but haven't found an efficient way--any way, really--to do that. Anyone know how?


Re: A Greasemonkey Script: Truancy Meter

Posted on: February 07 2011 @ 03:19 PM
By: Maniak

Content:

Quote by: Tahvohck

Yes I do love open source, Maniak. I'd been trying to do exactly that but couldn't get it to scale the second bar properly.



To be completely honest, neither could I. It's a bit wonky, and needs at least 4 monsters to properly kick in. It's incredibly weird, but somehow functional. I'll continue tinkering but I'm having trouble getting the needed exp at my current rank.

As for important info I always check and then forget:

Card messages. Is something off-kilter, or am I lucky?
Internal bleeding/regeneration.
How many days of extra stamina I have left over from WCG.

I consider the card message as the only one that's really important.


Re: A Greasemonkey Script: Truancy Meter

Posted on: February 07 2011 @ 07:30 PM
By: Tahvohck

Content:

Okay, new Truancy Bar is up, and so is the Newday Tracker, as usual at http://userpages.umbc.edu/~sq89891/Imp_Island/.

On the topic of your suggestions, Maniak:
Card messages: Done already.
Jokerstats: Will do, gonna need help due to not quite wanting to do a Joker run yet.
WCG: [Will do, should be simple enough.] Done.

Other things it has already:
Day count
Health (should be complete, might be missing something on the really low ends of hunger)
Fitness (basically only has fit, since I haven't gorged on cheeseburgers in forever)


Re: A Greasemonkey Script: Truancy Meter

Posted on: February 08 2011 @ 01:31 PM
By: Maniak

Content:

Some feedback:

NewDay
Day Unknown
Luck Normal
Strength Dying! Eat something!
Fitness Unknown
WCG days Unknown

Doesn't collect the Day properly, maybe because I was restored from the failboat.
Luck seems to be fine.
It says I should eat something, but I'm a robot. I think this bug would also apply to Jokers. You have an else statement, but I believe the text you're looking for is "you are slowly dying of malnutrition." For more lines, have a look at staminafood.php on github. Beware of spoilers.
Fitness, same with strength.
WCG days.. I don't know why it doesn't work.

Error console shows a pholder is null on line 42, which is about fitness. Probably nulls because I'm an organically challenged CPU-enhanced entity.

If you're willing to dive into the source of staminafood.php, you could even add Strength +10%, Fitness +5% to appropriate the results if you were so inclined.


Re: A Greasemonkey Script: Truancy Meter

Posted on: February 08 2011 @ 04:32 PM
By: Buddleia

Content:

Quote by: Devin

... 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


Uhm. I installed (yes, and enabled) this, and I've been through quite a few Damnquests since then. Sorry for such a stupid question, but where is the new section supposed to appear? I'm not seeing anything in the right-hand column, or in my bio.


Re: A Greasemonkey Script: Truancy Meter

Posted on: February 08 2011 @ 04:49 PM
By: Tahvohck

Content:

Yeah, the unknowns are default returns for if there's no value set. For those:

Day count: yeah, I'll check the failboat message.
Fitness: technically only has one thing that'll return anything anyway. Oops!
WCG: Are you sure you got a WCG message when newday rolled around? That's the only thing I can think of that would do that, it's working fine for me.

As for fitness/strength, yeah, I didn't even think about robos and Jokers when making this. I'll look into the github.

Good to hear luck works, though. Took me forever to actually notice when the proper message was there.


Re: A Greasemonkey Script: Truancy Meter

Posted on: February 19 2011 @ 01:18 PM
By: Derp+derp

Content:

There seems to be an extra experience bar for me next to level.


Re: A Greasemonkey Script: Truancy Meter

Posted on: February 19 2011 @ 06:20 PM
By: Maniak

Content:

That's most likely the Overall experience bar, that fills up to level 15. If you don't like it, you can take it away by commenting it out.

(somewhere near the end of the file)
On line 66 add /* before //Overall
On line 74 add */ after //alert(ExperienceWin);

Save file.


Re: A Greasemonkey Script: Truancy Meter

Posted on: April 05 2011 @ 05:48 AM
By: Buddleia

Content:

I'm finally switching over from Firefox to Chrome for playing II. Can anyone tell me how to get userscripts to behave, please? The Mail Checker and Quest Trackers work fine (once I reminded it to work on www as well as http), I've managed to hunt down the XP .js and give the new bars my preferred red background instead of black - but the Inventory Bar Limiter doesn't seem to be doing anything. I've tried changing the numbers, but nothing happens. And if there's a simple selection prompt anywhere, I don't see it.

Also ... since the Factory doesn't seem to be getting repaired ... are there by any chance any volunteers to make something that would show or say where the exit is? Instead of having to hunt through the page source for the elusive mred.gif in that sea of mblack.gifs and table attributes?


Re: A Greasemonkey Script: Truancy Meter

Posted on: April 05 2011 @ 03:05 PM
By: Maniak

Content:

Try fiddling with the @include part of the script. Mine is changed from

PHP Formatted Code
// ==UserScript==
// @name           Improbable Island Bar Limiter
// @description    Bar Limiter. Credit to bl0b, modified by Tahvohck
// @include        http://*.improbableisland.com/inventory.php?*
// @exclude        http://enquirer.improbableisland.com/*
// @exclude        http://labs.improbableisland.com/*
// ==/UserScript==


to
PHP Formatted Code
// ==UserScript==
// @name           Improbable Island Bar Limiter
// @description    Bar Limiter. Credit to bl0b, modified by Tahvohck
// @include        http://*improbableisland.com/inventory.php?*
// @exclude        http://enquirer.improbableisland.com/*
// @exclude        http://labs.improbableisland.com/*
// ==/UserScript==


I basically removed the dot in the 3rd line.

Abandoned Factory: I'd rather not spend 5 hours coding something that's a 5 minute fix for CMJ.


Re: A Greasemonkey Script: Truancy Meter

Posted on: April 07 2011 @ 03:36 AM
By: Beeps

Content:

I'm with Maniak on this one. Unless CMJ's uncovered deeper issues that he's just keeping quiet about, the cause has been known since November.


Re: A Greasemonkey Script: Truancy Meter

Posted on: April 07 2011 @ 04:24 AM
By: Tahvohck

Content:

Actually, (unless I'm lost) the problem with the bar limiter is that it was designed for Greasemonkey, and therefore has GM-specific code that doesn't work in Opera.


Re: A Greasemonkey Script: Truancy Meter

Posted on: April 07 2011 @ 03:09 PM
By: bl0b

Content:

Well, actually, the ones that are FF-only commands are the ones that start with GM_ with a few added to the bunch. So barely any script in this thread should work for Opera.
Using the script I posted earlier in the thread, it should fix most of the issues with opera. With this script added, I managed to run everything posted in this thread.
But from what I understand, Buddleia is using Chrome.

I'm guessing that Chrome should be better at supporting GM, but might still have some kinks. My guess is that it must be GM_registerMenuCommand function causing some problems.
Buddleia, try using the older version (page 2 in this thread). I don't run chrome though, so I can't really tell what's going on.

Ok, threw together another script. Activates when viewing inventory and when on a map square. What it will do is it will add a new window with a map in it under the donations button. Change the address to a map or any other web address of your choice.
Be careful though, you will reload the windowed webpage everytime you load the main page.

PHP Formatted Code

// ==UserScript==
// @name           map
// @include        http://*improbableisland.com/runmodule.php?module=worldmapen&*
// @include        http://*improbableisland.com/inventory.php?items_*
// @exclude        http://enquirer.improbableisland.com/*
// @exclude        http://labs.improbableisland.com/*
// ==/UserScript==


var getRef = document.getElementById("donator");

var makeIframe = document.createElement("iframe");

makeIframe.setAttribute("height", "350px");
makeIframe.setAttribute("width", "200px");
makeIframe.setAttribute("src", "http://fc02.deviantart.net/fs70/f/2009/342/a/4/Full_Improbable_Island_Map_by_betterwatchit.png");

var parentDiv = getRef.parentNode;
parentDiv.insertBefore(makeIframe, getRef);




Map was the first pic I found on google. If you want it to only pop up when you are doing a request stop, then you'll have to fiddle about with it (Change @include lines, as I don't know the address). If you really want a map, it's probably also easier to view it in another tab instead of in a small window, but hey, if nothing else, change the address, and you can send emails WHILE you play the game.


Re: A Greasemonkey Script: Truancy Meter

Posted on: April 07 2011 @ 03:48 PM
By: Count+Sessine

Content:

I don't use Greasemonkey, so possibly I'm missing the point, but... isn't this overthinking it?

Activates when viewing inventory and when on a map square. What it will do is it will add a new window with a map in it under the donations button. ... If you want it to only pop up when you are doing a request stop, then you'll have to fiddle about with it...
Why use the browser for this? The Island's map is a static graphic that hasn't changed since ... well, I was going to say, since the game began -- but at least since I started playing.

Is there any advantage to using a script, rather than doing a simple screen capture of the map and saving the file on your hard drive -- where you can look at it any time you want no matter what you're doing on the Island?


Re: A Greasemonkey Script: Truancy Meter

Posted on: April 07 2011 @ 04:30 PM
By: bl0b

Content:

Yeah, it's a big overkill. Problem is, I'm a bit lazy. That's also the reason it's under the donator button. It's the only 'div' with and 'id' on the page, if that makes any sense.
It's possible to add static images, but I'd need to play with it a bit.
Here's how you could do it
You'd need to convert the image first and stick it in the script itself. Might sit down in a few days and try and do it.
The difference between having it in the same window and having it open with a different program or in a different tab while requesting a stop is that it saves a second or so of looking back and forth between game and map. No real advantage there. Mainly I just wanted an excuse to have a script with an iframe for other potential scripts.


Re: A Greasemonkey Script: Truancy Meter

Posted on: April 07 2011 @ 09:36 PM
By: Tahvohck

Content:

Quote by: bl0b

Well, actually, the ones that are FF-only commands are the ones that start with GM_ with a few added to the bunch. So barely any script in this thread should work for Opera.



Yeah, that's what I was getting at. Guess I put it poorly.


Greasemonkey Scripts: Timed fighting and Butchery Guide

Posted on: November 15 2011 @ 02:39 AM
By: fledermaus

Content:

• Timed fighting turns the X seconds label into a countdown
• The butchery guide remembers the food values of everything
you carve up, and adds a tooltip of (C, H, T) to every
"Clean the carcass of X" link it knows the values for.

The butchery info is stored in the DOM local storage cache,
so it's tied to the URL - it won't carry over from www.ii to
ii, but it should be shared just fine between your alts
(assuming you get to ii via the same URL for your alts).

If you want to copy the data you can grab it from the
store (in firefox/iceweasel et al) by grabbing it
from the SQLite table in webappsstore.sqlite.

select * from main.webappsstore2 where key like 'ii/food/%'


Re: A Greasemonkey Script: Truancy Meter

Posted on: November 17 2011 @ 04:43 PM
By: sre

Content:

sweet jumping chili beans...
Eek!

i...uh...yes, pencil and pad of paper for me it looks like


Re: A Greasemonkey Script: Truancy Meter

Posted on: May 12 2012 @ 11:31 PM
By: Buddleia

Content:

There is now a wiki page for Greasemonkey scripts. Hopefully it's got all the details correct. Please post/update the wiki and/or this thread when new scripts are made!

Current list of scripts:



Many thanks to all who have written these pieces of magic! You guys are awesome. I enjoy the Island more for having some of these.


The Improbable Island Enquirer - Forum
http://enquirer.improbableisland.com/forum/viewtopic.php?showtopic=16773