SpringRTS.com GreaseMonkey Scripts?

SpringRTS.com GreaseMonkey Scripts?

Post just about everything that isn't directly related to Spring here!

Moderator: Moderators

Post Reply
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

SpringRTS.com GreaseMonkey Scripts?

Post by SinbadEV »

I was feeling creative and made a userscript for making people's avatars bigger...

[code]// ==UserScript==
// @name SpringRTS-PHPBB
// @namespace http://localhost
// @include http://springrts.com/phpbb/viewtopic.php*
// ==/UserScript==

var allAvatars, thisAvatar;
allAvatars = document.getElementsByTagName('img');
for (var i = 0; i < allAvatars.length; i++) {
thisAvatar = allAvatars;
// do something with thisAvatar
if (thisAvatar.alt == "User avatar")
{
thisAvatar.width="135"
thisAvatar.height="135"
}
}[/code]


And then I got to thinking maybe there are other people who have made userscripts for this site they might want to share.
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: SpringRTS.com GreaseMonkey Scripts?

Post by TradeMark »

Make a script that deletes the location field if it doesnt have a valid country name. That would be useful.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: SpringRTS.com GreaseMonkey Scripts?

Post by knorke »

TradeMark wrote:Make a script that makes the avatar bigger if location field doesnt have a valid country name. That would be useful.
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: SpringRTS.com GreaseMonkey Scripts?

Post by SinbadEV »

TradeMark wrote:Make a script that deletes the location field if it doesnt have a valid country name. That would be useful.
YES!

Code: Select all

var allSpans, thisSpan, thisLocation;
allSpans = document.evaluate(
    "//span[@class='postdetails']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
for (var i = 0; i < allSpans.snapshotLength; i++) {
    thisSpan = allSpans.snapshotItem(i);
    // do something with thisDiv
	thisLocation = thisSpan.innerHTML.split("<b>Location:</b>");
	if ((thisLocation[1].indexOf("Finland") != -1) || (thisLocation[1].indexOf("Canada") != -1) || (thisLocation[1].indexOf("Sweden") != -1) || (thisLocation[1].indexOf("America") != -1))
		{
			thisSpan.innerHTML = thisLocation[0]+"<b>Location:</b>"+thisLocation[1];
		}
	else 
		{
			thisSpan.innerHTML = thisLocation[0];
		}
}
but you'll have to modify it to allow all of the other countries
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: SpringRTS.com GreaseMonkey Scripts?

Post by SinbadEV »

I realized that my script was screwing up the aspect ratio on images so I improved it:

Code: Select all

var allAvatars, thisAvatar;
allAvatars = document.getElementsByTagName('img');
for (var i = 0; i < allAvatars.length; i++) {
    thisAvatar = allAvatars[i];
    // do something with thisAvatar
	if (thisAvatar.alt == "User avatar")
		{
			theImage = new Image()
			theImage.src = thisAvatar.src;
			iWidth = theImage.width;
			iHeight = theImage.height;
			newRatio = 80;
			if (iWidth < 80){
				newRatio = iWidth;
			}

			thisAvatar.width = (iWidth/newRatio)*120;
			thisAvatar.height = (iHeight/newRatio)*120;
			//thisAvatar.height="120";

			
		}
}

User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: SpringRTS.com GreaseMonkey Scripts?

Post by SinbadEV »

it's dirty and it doesn't put the header in the right place but if you ever wanted posts to take up the full width of the browser the following works for me:

Code: Select all

var allStuff, thisStuff;
allStuff = document.getElementsByTagName('*');
for (var i = 0; i < allStuff.length; i++) {
    thisStuff = allStuff[i];
	if (thisStuff.width > 600)
		{
			thisStuff.width = ""
		}
}
User avatar
TradeMark
Posts: 4867
Joined: 17 Feb 2006, 15:58

Re: SpringRTS.com GreaseMonkey Scripts?

Post by TradeMark »

may i ask why do you need to resize fixed size images larger? it will just make them blurred... or in worst case pixelized...
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: SpringRTS.com GreaseMonkey Scripts?

Post by AF »

This kind of falls apart when you realise the avatars are now fugly and pixelated.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: SpringRTS.com GreaseMonkey Scripts?

Post by Forboding Angel »

More or less perfect for anyone at 1920 x xxx resolution.

Code: Select all

// ==UserScript==
// @name           SpringRTS-wider-PHPBB
// @namespace      http://localhost
// @include        http://springrts.com/phpbb/*
// ==/UserScript==

var allStuff, thisStuff;
allStuff = document.getElementsByTagName('*');
for (var i = 0; i < allStuff.length; i++) {
    thisStuff = allStuff[i];
   if (thisStuff.width > 600)
      {
         thisStuff.width = "1000"
      }
}
User avatar
MidKnight
Posts: 2652
Joined: 10 Sep 2008, 03:11

Re: SpringRTS.com GreaseMonkey Scripts?

Post by MidKnight »

For visual adjustments, I prefer Stylish. Have you seen it?
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: SpringRTS.com GreaseMonkey Scripts?

Post by SinbadEV »

Image

ADD

Code: Select all

GM_addStyle(".postbody img { max-width: none; }")
to a script to remove the image size limitation... you can change "none" to a specific "px" or "%" value too.

edit: apparently "none" is better to use then "100%"
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: SpringRTS.com GreaseMonkey Scripts?

Post by SinbadEV »

Another good one:
GM_addStyle("div.postbody { max-height: 200px; overflow:auto; }")
this limits the length of postbody (you can choose your own size )...

good for all you TL;DRers out there.

you can also use codecontent or quotecontent to limit the size of code or quote blocks (looks silly on nested quotes though)
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: SpringRTS.com GreaseMonkey Scripts?

Post by SinbadEV »

This very bad code get's rid of the extra spacing around the post body.

Code: Select all

allPostBody = document.evaluate(
    "//div[@class='postbody']",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
allTargets = document.evaluate(
    "//div[@class='postbody']/ancestor::*[5]",
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
for (var i = 0; i < allPostBody.snapshotLength; i++) {
    thisPostBody = allPostBody.snapshotItem(i);
	thisTarget = allTargets.snapshotItem(i);
	//thisPostBody.innerHTML="test";
	thisInside=thisPostBody.innerHTML;
	thisTarget.innerHTML="<div class='postbody'>"+thisInside+"</div>";
}
Post Reply

Return to “Off Topic Discussion”