Page 1 of 1
SpringRTS.com GreaseMonkey Scripts?
Posted: 10 Feb 2011, 14:58
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.
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 10 Feb 2011, 17:35
by TradeMark
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?
Posted: 10 Feb 2011, 17:55
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.
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 10 Feb 2011, 18:24
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
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 10 Feb 2011, 19:36
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";
}
}
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 10 Feb 2011, 20:33
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 = ""
}
}
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 10 Feb 2011, 20:59
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...
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 10 Feb 2011, 22:32
by AF
This kind of falls apart when you realise the avatars are now fugly and pixelated.
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 10 Feb 2011, 22:58
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"
}
}
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 11 Feb 2011, 02:28
by MidKnight
For visual adjustments, I prefer
Stylish. Have you seen it?
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 11 Feb 2011, 20:21
by SinbadEV
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%"
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 23 Feb 2011, 17:05
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)
Re: SpringRTS.com GreaseMonkey Scripts?
Posted: 04 Mar 2011, 23:00
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>";
}