Rounded Forms

By Peter Farmer Last update Jul 25, 2008 — Installed 431 times.
// ==UserScript==
// @name                 Rounded Forms
// @namespace            http://userscripts.org
// @description          Rounds corners and adjusted appearance of textarea, select, and input fields
// @include              http://*
// @include              https://*
// @exception_handling   http://addons.mozilla.com/*, https://addons.mozilla.com/*
// @author               Pete Farmer  <pfarmer at collaboros.com>
// @updated              25-Jul-08
// @version              1.06
// ==/UserScript==

// Updated 25-Jul-08 (v1.06). Further minor tweaking (-1px) of height of textarea, select, and input fields

// Updated again on 23-Jul-08 (v1.05).  Creates exception for Firefox add-on site.
//   Thanks to Joe Simmons at http://userscripts.org/users/23652 !!

// Updated 23-Jul-08 (v1.04).  Added 1px on top and bottom margin and on top, left, and right padding of input, textarea, and select
//   fields, which seems to work better when rendering with Linux.  Also reorganized the script to make it easier to understand.

// Updated 12-Jul-08 (v1.03) -- More tweaks.  Damn, it's tough to get spacing right when the site already has established height and padding
//   for 'select' fields!  But Eureka!  Discovered that some nasty sites (e.g. American Express) were trying to make Firefox *not*
//   comply with CSS (i.e., mock IE 6's non-compliance) by inserting a '-moz-box-sizing: border-box' statement in their CSS for
//   'select' fields.  By reversing this with '-moz-box-sizing: content-box', 'select' boxes now seem to come out right.  This cheers
//   my obsesso-compulso soul.

// Updated 11-Jul-08 (v1.02) -- A series of minor tweaks so that it behaves better with regard to margins and widths

// Updated 10-Jul-08 (v1.01) to improve readability

// Loaded 9-Jul-08 (v1.0)

(function() {
	var cssGlobal = ' ' +
	'/* Input, textarea and select fields: Background colors (if not already set) and borders */' +
		'input:' +
			'not([type=\"button\"]):' +
			'not([type=\"checkbox\"]):' +
			'not([type=\"file\"]):' +
			'not([type=\"image\"]):' +
			'not([type=\"password\"]):' +
			'not([type=\"radio\"]):' +
			'not([type=\"reset\"]):' +
			'not([type=\"submit\"]), ' +
		'textarea, ' +
		'select ' +
		'{ ' +
			'background-color: #FEFBEB;' +
			'color: #000; ' +
			'min-height: 19px !important; ' +
			'margin-top: 3px; ' +
			'margin-bottom: 3px; ' +
			'padding-top: 2px !important;' +
			'padding-bottom: 0px; ' +
			'padding-left: 6px; ' +
			'padding-right: 6px; ' +
			'vertical-align: middle; ' +
			'border: 2px double #E3E3E9 !important;' +
			'-moz-border-radius: 0.95em !important;' +
			'-moz-outline: 1px solid #CCC !important;' +
			'-moz-outline-radius: 0.8em !important;' +
			'-moz-outline-offset: -3px !important;' +
			'-moz-box-sizing: content-box !important;' +
		'} ' +
	'/* Change input, textarea, and select fields when in focus or hovered */ ' +
		'input:' +
			'not([type=\"button\"]):' +
			'not([type=\"checkbox\"]):' +
			'not([type=\"file\"]):' +
			'not([type=\"image\"]):' +
			'not([type=\"password\"]):' +
			'not([type=\"radio\"]):' +
			'not([type=\"reset\"]):' +
			'not([type=\"submit\"]):focus, ' +
		'textarea:focus, ' +
		'select:focus, ' +
		'input:' +
			'not([type=\"button\"]):' +
			'not([type=\"checkbox\"]):' +
			'not([type=\"file\"]):' +
			'not([type=\"image\"]):' +
			'not([type=\"password\"]):' +
			'not([type=\"radio\"]):' +
			'not([type=\"reset\"]):' +
			'not([type=\"submit\"]):hover, ' +
		'textarea:hover, ' +
		'select:hover ' +
		'{ ' +
			'background-color: #FBFBD5;' +
			'border: 2px solid #CCD !important;' +
			'-moz-outline: #DFE3D6 solid 1px !important; ' +
			'-moz-outline-offset: -4px !important; ' +
		'} ' +
	'/* Password fields: Background color and borders */ ' +
		'input[type=\"password\"] ' +
		'{ ' +
			'background-color: #FFE6D6 !important;  ' +
			'color: #000 !important; ' +
			'min-height: 19px !important; ' +
			'margin-top: 3px; ' +
			'margin-bottom: 3px; ' +
			'padding-top: 2px !important;' +
			'padding-bottom: 0px; ' +
			'padding-left: 6px; ' +
			'padding-right: 6px; ' +
			'vertical-align: middle; ' +
			'border: 2px double #E3E3E9 !important;' +
			'-moz-border-radius: 0.95em !important;' +
			'-moz-outline: 1px solid #CCC !important;' +
			'-moz-outline-radius: 0.8em !important;' +
			'-moz-outline-offset: -3px !important;' +
			'-moz-box-sizing: content-box !important;' +
		'} ' +
	'/* Change password fields when in focus or hovered */ ' +
		'input[type=\"password\"]:focus, ' +
		'input[type=\"password\"]:hover ' +
		'{ ' +
			'background-color: #FFD9C9 !important;  ' +
			'border: 2px solid #CCD !important;' +
			'-moz-outline: #D9DAD6 solid 1px !important; ' +
			'-moz-outline-offset: -4px !important; ' +
		'} ' +
	'/* Buttons:Background (if not already set) and borders */ ' +
		'input[type=\"button\"], ' +
		'input[type=\"reset\"], ' +
		'input[type=\"submit\"], ' +
		'button ' +
		'{ ' +
			'background-color: #DFE6E6; ' +
			'color: #333; ' +
			'min-height: 19px; ' +
			'margin: 2px; ' +
			'padding-top: 2px !important;' +
			'padding-bottom: 1px; ' +
			'padding-left: 8px; ' +
			'padding-right: 8px; ' +
			'vertical-align: middle; ' +
			'border: 2px solid #88A !important; ' +
			'-moz-border-radius: 1.5em !important; ' +
			'-moz-outline: #CCE solid 1px !important; ' +
			'-moz-outline-radius: 1em !important; ' +
			'-moz-outline-offset: -4px !important; ' +
			'-moz-box-sizing: content-box !important;' +
		'} ' +
	'/* Change buttons when hovered */ ' +
		'input[type=\"button\"]:hover, ' +
		'input[type=\"reset\"]:hover, ' +
		'input[type=\"submit\"]:hover, ' +
		'button:hover ' +
		'{ ' +
			'background-color: #D0DADA; ' +
			'color: #000; ' +
			'border: 2px solid #668 !important; ' +
			'-moz-outline: #BBC solid 1px !important; ' +
			'-moz-outline-offset: -4px !important; ' +
		'} ' ;

// Make changes specific to Firefox add-ons site
	var cssFFaddons = ' ' +
		'#search-form #category ' +
			'{ ' +
				'padding: 3px 6px !important; ' +
			'} ' +
		'.html-ltr #search-form #search-query label ' +
			'{ ' +
				'padding: 9px 6px 0px 30px !important; ' +
			'} ' +
		'.html-ltr #search-form #my-submit, ' +
		'.html-ltr #search-form #my-submit:hover ' +
			'{ ' +
				'border: 0px solid transparent !important; ' +
				'outline: 0px solid transparent !important; ' +
				'background-color: transparent !important; ' +
				'width: 20px !important; ' +
			'} ' +
		'.html-ltr #search-form #my-submit ' +
			'{ ' +
				'background-position: 2px 4px !important; ' +
			'} ' +
		'.html-ltr #search-form #my-submit:hover ' +
			'{ ' +
				'background-position: -36px 3px !important; ' +
			'} ';

if (typeof GM_addStyle != "undefined") {
	GM_addStyle(cssGlobal);

	if(location.href.indexOf('https://addons.mozilla.org') !== -1) {
		GM_addStyle(cssFFaddons);
	}
}

else if (typeof addStyle != "undefined") {
	addStyle(css);

	if(location.href.indexOf('https://addons.mozilla.org') !== -1) {
		addStyle(cssFFaddons);
	}
}

else {
	var heads = document.getElementsByTagName("head");
	if (heads.length > 0) {
		var node = document.createElement("style");
		node.type = "text/css";
		node.appendChild(document.createTextNode(cssGlobal));

		if(location.href.indexOf('https://addons.mozilla.org') !== -1) {
			node.appendChild(document.createTextNode(cssFFaddons));
		}
	}
}

})();