SpringRTS.com GreaseMonkey Scripts?
Moderator: Moderators
SpringRTS.com GreaseMonkey Scripts?
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.
[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.
Re: SpringRTS.com GreaseMonkey Scripts?
Make a script that deletes the location field if it doesnt have a valid country name. That would be useful.
Re: SpringRTS.com GreaseMonkey Scripts?
TradeMark wrote:Make a script that makes the avatar bigger if location field doesnt have a valid country name. That would be useful.
Re: SpringRTS.com GreaseMonkey Scripts?
YES!TradeMark wrote:Make a script that deletes the location field if it doesnt have a valid country name. That would be useful.
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];
}
}
Re: SpringRTS.com GreaseMonkey Scripts?
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";
}
}
Re: SpringRTS.com GreaseMonkey Scripts?
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 = ""
}
}
Re: SpringRTS.com GreaseMonkey Scripts?
may i ask why do you need to resize fixed size images larger? it will just make them blurred... or in worst case pixelized...
Re: SpringRTS.com GreaseMonkey Scripts?
This kind of falls apart when you realise the avatars are now fugly and pixelated.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: SpringRTS.com GreaseMonkey Scripts?
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"
}
}
Re: SpringRTS.com GreaseMonkey Scripts?
For visual adjustments, I prefer Stylish. Have you seen it?
Re: SpringRTS.com GreaseMonkey Scripts?

ADD
Code: Select all
GM_addStyle(".postbody img { max-width: none; }")
edit: apparently "none" is better to use then "100%"
Re: SpringRTS.com GreaseMonkey Scripts?
Another good one:
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)
this limits the length of postbody (you can choose your own size )...GM_addStyle("div.postbody { max-height: 200px; overflow:auto; }")
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)
Re: SpringRTS.com GreaseMonkey Scripts?
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>";
}