User Functions
Don't have an account yet? Sign up as a New User
Lost your password?
|
Enquirer Home Page | Twitter | Back to Improbable Island
Anonymous: blob |
 |
Saturday, November 27 2010 @ 10:45 AM UTC |
|
|
|
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.
|
|
|
|
Tahvohck |
 |
Saturday, November 27 2010 @ 07:26 PM UTC |
|
|

Contender
Status: offline
Registered: 10/15/10
Posts: 65
|
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.
|
|
|
|
Anonymous: blob |
 |
Monday, November 29 2010 @ 11:29 AM UTC |
|
|
|
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 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.
|
|
|
|
Matthew |
 |
Tuesday, November 30 2010 @ 03:15 AM UTC |
|
|

Improbable Badass
 Status: offline
Registered: 08/26/10
Posts: 578
|
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.
|
|
|
|
Matthew |
 |
Tuesday, November 30 2010 @ 08:20 AM UTC |
|
|

Improbable Badass
 Status: offline
Registered: 08/26/10
Posts: 578
|
Hahaha NEVERMIND
See, it's funny, because... eh... heeeeeeeeeeeh.
Yes... right.
|
|
|
|
Tahvohck |
 |
Tuesday, December 07 2010 @ 03:40 PM UTC |
|
|

Contender
Status: offline
Registered: 10/15/10
Posts: 65
|
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>';
}
}
|
|
|
|
Buddleia |
 |
Sunday, December 12 2010 @ 01:04 AM UTC |
|
|

Improbable Badass
 Status: offline
Registered: 04/23/10
Posts: 343
|
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?
Improbable Reference Links - goo.gl/MRBnb --------------
Land Registry (map of Places) ---- goo.gl/bpkRR
|
|
|
|
Matthew |
 |
Sunday, December 12 2010 @ 02:05 AM UTC |
|
|

Improbable Badass
 Status: offline
Registered: 08/26/10
Posts: 578
|
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.
|
|
|
|
Tahvohck |
 |
Sunday, December 12 2010 @ 05:51 AM UTC |
|
|

Contender
Status: offline
Registered: 10/15/10
Posts: 65
|
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.
|
|
|
|
Matthew |
 |
Sunday, December 12 2010 @ 05:57 AM UTC |
|
|

Improbable Badass
 Status: offline
Registered: 08/26/10
Posts: 578
|
Quote by: TahvohckHuh. 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.
|
|
|
|
Tahvohck |
 |
Sunday, December 12 2010 @ 06:09 AM UTC |
|
|

Contender
Status: offline
Registered: 10/15/10
Posts: 65
|
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.
|
|
|
|
Iriana |
 |
Sunday, December 12 2010 @ 06:10 AM UTC |
|
|

Improbable Badass
 Status: offline
Registered: 09/14/10
Posts: 250
|
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.
|
|
|
|
Tahvohck |
 |
Sunday, December 12 2010 @ 06:15 AM UTC |
|
|

Contender
Status: offline
Registered: 10/15/10
Posts: 65
|
Quote by: IrianaThen 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.
|
|
|
|
Matthew |
 |
Sunday, December 12 2010 @ 06:20 AM UTC |
|
|

Improbable Badass
 Status: offline
Registered: 08/26/10
Posts: 578
|
Quote by: TahvohckIt'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: Matthewedit 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.
|
|
|
|
Tahvohck |
 |
Sunday, December 12 2010 @ 06:29 AM UTC |
|
|

Contender
Status: offline
Registered: 10/15/10
Posts: 65
|
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.
|
|
|
|
Anonymous: blob |
 |
Sunday, December 12 2010 @ 07:02 AM UTC |
|
|
|
@ 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?
|
|
|
|
Tahvohck |
 |
Sunday, December 12 2010 @ 07:14 AM UTC |
|
|

Contender
Status: offline
Registered: 10/15/10
Posts: 65
|
|
|
|
|
Iriana |
 |
Sunday, December 12 2010 @ 08:36 AM UTC |
|
|

Improbable Badass
 Status: offline
Registered: 09/14/10
Posts: 250
|
:'D Clearly I need to look at what I'm installing next time.
Thanks, bl0b and Tahvohck! Everything works beautifully now.
|
|
|
|
Tahvohck |
 |
Sunday, December 12 2010 @ 10:34 AM UTC |
|
|

Contender
Status: offline
Registered: 10/15/10
Posts: 65
|
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?
|
|
|
|
Maniak |
 |
Sunday, December 12 2010 @ 11:46 AM UTC |
|
|

Improbable Badass
Status: offline
Registered: 10/11/10
Posts: 298
|
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.
http://maniak.cu.cc/
|
|
|
|
Content generated in: 1.58 seconds |
|
|