BreadCrumbs: Greasemonkey

Greasemonkey

From Luke Jackson

(Difference between revisions)
Jump to: navigation, search

Revision as of 10:14, 28 February 2008

Examples

Multiple Select Options with CSV

// NOTE : Once you are on a webpage, you can invoke
//		  this script by pressing CTRL+SHIFT+F




// ================================ Set data here ============================= //



// Values for the fieldnames above, in the exact array order
//select = [6, 7, 8, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 72, 73, 74, 75, 76, 77, 79, 81, 82, 83, 84, 85, 87, 88, 89, 90, 91, 92, 93, 94, 95, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 162, 163, 164, 166, 167, 168, 169, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202];
//select = new Array ( '6', '7', '8', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '40', '41', '42', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '72', '73', '74', '75', '76', '77', '79', '81', '82', '83', '84', '85', '87', '88', '89', '90', '91', '92', '93', '94', '95', '97', '98', '99', '100', '101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '115', '116', '117', '118', '119', '120', '121', '122', '123', '124', '125', '126', '127', '128', '129', '130', '131', '134', '135', '136', '138', '139', '140', '141', '142', '143', '144', '145', '146', '147', '148', '149', '150', '151', '152', '153', '154', '155', '156', '162', '163', '164', '166', '167', '168', '169', '173', '174', '175', '176', '177', '178', '179', '180', '181', '182', '183', '184', '185', '186', '187', '188', '189', '190', '191', '192', '193', '194', '195', '196', '197', '198', '199', '200', '201', '202' );
select = [48, 109, 121, 144, 171, 175, 210, 221, 288, 347];
// ================================= No need to alter below ==================== //


function doAutoFill() {

var allFields, currentField, fieldName, splitFields, test, luke;
allFields = document.getElementsByTagName('select');

//producttype_id[]
//productcolor_id[]

if(allFields.length > 1) {
	alert(allFields.length);
	alert(allFields[2].name);

}

//luke = allFields[3].name;

for (var h = 0; h < allFields[2].options.length; h++) {

for (var i = 0; i < select.length; i++) {
	
	if(allFields[2].options[h].value == select[i]) {
		allFields[2].options[h].selected = true;
		break;
	}
}
	
}

}

// =============================

// Track keypresses
function keyDown(e) {	
	if (e.shiftKey&&e.ctrlKey) {
		switch (e.keyCode) {
			case 70: // CTRL+SHIFT+F
				doAutoFill();
				break;
		}
	}
}

// =============================

// Add a handler for the keyboard shortcut
window.addEventListener("keydown", keyDown, true);

Personal tools