User:Solune/User Scripts
From Cities
Contents |
to change the number of rows in the text area
// ==UserScript==
// @name text augmenter
// @description change the number of rows in the text area
// @include http://cities.totl.net/cgi-bin/game
var messages= document.getElementById("messages");
messages.rows+=5;
// ==/UserScript==
to show bebe's graphics
// ==UserScript==
// @name bebe
// @description sets the bebe CSS style even if you don't wear googles
// @include http://cities.totl.net/cgi-bin/game
var newlink=document.createElement("link");
newlink.rel="stylesheet";
newlink.media="screen";
newlink.href="/bebe.css";
newlink.type="text/css";
var head=document.getElementsByTagName("head")[0];
head.appendChild(newlink);
// ==/UserScript==
HealthBar (original script by jmb)
// ==UserScript==
// @name Cities Health bar
// @namespace http://hackery.net/cities/ui/healthbar
// @description Show health bar over player
// @include http://cities.totl.net/cgi-bin/game
// @version $Id: healthbar.user.js,v 1.1 2006/09/10 13:23:59 jmb Exp jmb $
// ==/UserScript==
// The health bar is a TD with background of a warning colour,
// with an image of green partly filling it from the left.
// as the bar reduces, the background changes from orange to red.
var hp_content = document.getElementById("hp");
var hpmax_content = document.getElementById("maxhp");
var hpval = hp_content.innerHTML;
var hpmaxval = hpmax_content.innerHTML;
var hp_per = ((hpval/hpmaxval)*100);
// The current player DIV is tagged with id="avatar"
var avatar = document.getElementById("avatar");
if (avatar) {
// Find the table row that contains the character info, add one after it
// Starter characters just have a text node, no table, so we need to
// create the table from scratch.
var avatar_tr = avatar.getElementsByTagName("tr")[0];
if (!avatar_tr) {
// there's no table - grab the existing name text and build one
var avatarName = avatar.innerHTML;
var avatarTABLE = document.createElement("table");
avatarTABLE.style.width = "100%";
var avatarNameTR = document.createElement("tr");
avatarTABLE.appendChild(avatarNameTR);
var avatarNameTD = document.createElement("td");
avatarNameTD.innerHTML = avatarName;
avatarNameTR.appendChild(avatarNameTD);
avatar.innerHTML = "";
avatar.appendChild(avatarTABLE);
avatar_tr = avatarNameTR;
}
var healthBarTR = document.createElement("tr");
healthBarTR.setAttribute("id", "healthbar");
// defer adding to document until last, to avoid rendering artifacts
var healthBarTD = document.createElement("td");
healthBarTR.appendChild(healthBarTD);
healthBarTD.setAttribute("colspan", "2");
var bgcolor = "white";
if (hp_per < 10)
bgcolor = "red";
else if (hp_per < 25)
bgcolor = "orange";
healthBarTD.setAttribute("bgcolor", bgcolor);
healthBarTD.style.border="solid 1px black";
var healthBarDIV = document.createElement("div");
healthBarTD.appendChild(healthBarDIV);
healthBarDIV.style.height = "8px";
healthBarDIV.style.width = "" + hp_per + "%";
healthBarDIV.style.background = "green";
healthBarDIV.style.fontSize="10px";
avatar_tr.parentNode.appendChild(healthBarTR);
}
