Greasemonkey script for resizing forum avatars

Status
Not open for further replies.
Disclaimer: this is my first Greasemonkey script and I don't know Java or the other scripting languages it uses, but it seems to work. Any tips would be appreciated (like how to ease the install, for starters).

Code:
// ==UserScript==
// @name          ScaleAvatars
// @namespace     [url]http://jake.org[/url]
// @description   scale forum avatars to 120px width
// @include       [url]http://forum.halforum.com/*[/url]
// ==/UserScript==

var allImg, thisImg;
allImg = document.evaluate(
    \"//img[@alt='User avatar']\",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
for (var i = 0; i < allImg.snapshotLength; i++) {
    thisImg = allImg.snapshotItem(i);
    if (thisImg.width>120){
        thisImg.height = thisImg.height/thisImg.width*120;
        thisImg.width = 120;
    }
}
 
Dude, if this worked you'd be a fucking hero. I hope you can work the kinks out.


(by that I mean I do have and use Greasemonkey quite a bit, I installed your script and it didn't work :( )
 
Dammit! Why, God?

Before:



After:


-- Thu Jul 02, 2009 4:58 pm --

Could someone confirm whether going to Greasemonkey>Manage User Scripts>ScaleAvatars shows "http://forum.halforum.com/*" in the Included Pages?

-- Thu Jul 02, 2009 5:05 pm --

Okay, I just booted into Windows 7 and installed the script in a virginal Firefox 3.5 and it works for me (tested it previously under XP and Firefox 3.0).

WTF?
 


I even added the Halforum site specifically just in case that was the problem. As you can see, Greasemonkey is enabled. Unless there is something I'm missing yet.

Edit: It's hard to read, but says
Code:
http://forum.halforum.com/*
in the enabled column.
 
Wow, installed it on my home machine and it's a bunch of shit instead of the script. If you can add it manually from the code in my initial post, it should work. For some reason, I can't attach .js files to posts (with good reason, I imagine).
 
Okay, this should work. Grab this zip file, extract, and open the extracted file with your browser.

*updated below*
 
IT WORKS!

-- less than a minute ago --

Oh man, this is awesome.

For your next trick... make a script that makes the forum dark! That way we can have all the awesomeness of, say, AcidTech (by far the best theme on the forum) with all the functionality of subsilver!!




It can be done, right?
 
Sweet. I guess the "free file hosting" site I tried at first got me exactly what I payed for. :eek:rly:

Calleja said:
For your next trick... make a script that makes the forum dark! That way we can have all the awesomeness of, say, AcidTech (by far the best theme on the forum) with all the functionality of subsilver!!

It can be done, right?
I guess anything is possible, in theory. But you must understand that my programming style is basically to throw poorly understood pieces of code together and bang on the mess with a rock till it works.
 
Jake said:
Sweet. I guess the "free file hosting" site I tried at first got me exactly what I payed for. :eek:rly:

Calleja said:
For your next trick... make a script that makes the forum dark! That way we can have all the awesomeness of, say, AcidTech (by far the best theme on the forum) with all the functionality of subsilver!!

It can be done, right?
I guess anything is possible, in theory. But you must understand that my programming style is basically to throw poorly understood pieces of code together and bang on the mess with a rock till it works.
So it's like Windows?
 
Krisken said:
Jake said:
Sweet. I guess the "free file hosting" site I tried at first got me exactly what I payed for. :eek:rly:

Calleja said:
For your next trick... make a script that makes the forum dark! That way we can have all the awesomeness of, say, AcidTech (by far the best theme on the forum) with all the functionality of subsilver!!

It can be done, right?
I guess anything is possible, in theory. But you must understand that my programming style is basically to throw poorly understood pieces of code together and bang on the mess with a rock till it works.
So it's like Windows?
No, I said "works".
 
Jake said:
Krisken said:
Jake said:
Sweet. I guess the "free file hosting" site I tried at first got me exactly what I payed for. :eek:rly:

Calleja said:
For your next trick... make a script that makes the forum dark! That way we can have all the awesomeness of, say, AcidTech (by far the best theme on the forum) with all the functionality of subsilver!!

It can be done, right?
I guess anything is possible, in theory. But you must understand that my programming style is basically to throw poorly understood pieces of code together and bang on the mess with a rock till it works.
So it's like Windows?
No, I said "works".
You owe me for that set up!
 
I noticed that long avatars can make one-line posts take up half a damned page, so I modified the script so that you can specify the maximum width and height you'd like to restrict avatars to. When you install the updated script, just modify (Manage User Scripts>ScaleAvatars>Edit) maxWidth and maxHeight to your liking. They're set pretty small right now, fyi.

[attachment=0:3sblirqj]new script.zip[/attachment:3sblirqj]
 
Status
Not open for further replies.
Top