Export thread

Greasemonkey script for resizing forum avatars

#1

Jake

Jake

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


#2

Jake

Jake

Could someone let me know whether this link installs the script for you? Assuming you have Firefox and Greasemonkey, of course.


#3





Jake said:
Could someone let me know whether this link installs the script for you? Assuming you have Firefox and Greasemonkey, of course.
I just installed it. Is there an avatar to test it on?


#4

sixpackshaker

sixpackshaker

Chazwozel


#5





I just installed it and my own avatar still shows at 150x150.


#6

Jake

Jake

Edrondol said:
Jake said:
Could someone let me know whether this link installs the script for you? Assuming you have Firefox and Greasemonkey, of course.
I just installed it. Is there an avatar to test it on?
Yours, actually.

EDIT: Did you refresh?


#7

Shakey

Shakey

Didn't resize anything for me either.


#8

Jake

Jake

Did refreshing help? Is this working for anyone but me?


#9

Krisken

Krisken

Jake said:
Did refreshing help? Is this working for anyone but me?
Sorry. :(


#10

Jake

Jake

Krisken said:
Jake said:
Did refreshing help? Is this working for anyone but me?
Sorry. :(
Fucker! Yours is resized, too, I swear!


#11

Calleja

Calleja

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 :( )


#12

Jake

Jake

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?


#13

Krisken

Krisken



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.


#14

Shakey

Shakey

Got this if it helps any.


#15

Jake

Jake

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


#16

Calleja

Calleja

Umm.. how would one proceed to add it manually, exactly?


#17

Jake

Jake

Okay, this should work. Grab this zip file, extract, and open the extracted file with your browser.

*updated below*


#18

Calleja

Calleja

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?


#19

Shakey

Shakey

Worked for me too


#20

Krisken

Krisken

Well done, sir!


#21

Jake

Jake

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.


#22

Krisken

Krisken

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?


#23

Jake

Jake

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


#24

Krisken

Krisken

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!


#25

Jake

Jake

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]


Top