rem: case "includes": case "excludes": script[match[1]].push(match[2]); 
add: case "include": case "exclude": script[match[1]+"s"].push(match[2]); 
context: function ScriptDownloader(url) {	var dm = Components.classes["@mozilla.org/download-manager;1"].getService(Components.interfaces.nsIDownloadManager)	var ioservice = Components.classes["@mozilla.org/network/io-service;1"].getService();	var sourceUri = ioservice.newURI(url, null, null);	var targetFile = getTempFile();	var targetUri = ioservice.newFileURI(targetFile)	var persist = makeWebBrowserPersist();		var sysListener = null;	var download = null;	var self = this;	var timerId = null;	this.start = function() {		try {			dm.addDownload(0, sourceUri, targetUri, parseScriptName(sourceUri), null, null, null, persist)			dm.open(window._content, targetFile.path)			download = dm.getDownload(targetFile.path);			download.persist = persist;			persist.saveURI(sourceUri, null, null, null, null, targetFile);			// this seems like a huge hack, but it was actually the most reliable			// way I could find to determine when downloading is complete			timerId = window.setInterval(checkLoad, 200);		}		catch (e) {			handleErrors(e);		}	}	function checkLoad() {		// if the download is complete, stop.		if (download.percentComplete == 100) {			window.clearInterval(timerId);			handleLoad();		}		// if not complete yet, double-check that somebody hasn't cancelled it		else if (dm.getDownload(targetFile.path) == null) {			// the download is no longer active			window.clearInterval(timerId);			return;		}		// otherwise, do nothing. downloading continues.	}	function handleLoad() {		closeDownloadManager();		// validate that we downloaded ok		if (!targetFile.exists() || targetFile.fileSize == 0) {			alert("The file does not exist or was removed.");			return;		}		// initialize a new script object		var script = new Script();		script.id = targetFile.leafName;		script.enabled = true;		script.includes = [];		script.excludes = [];		// crack open the file so we can look for metadata in the comments		var fileStream = Components.classes["@mozilla.org/network/file-input-stream;1"]						.createInstance(Components.interfaces.nsIFileInputStream);		fileStream.init(targetFile, 1, 0, false);		// read one line at a time looking for start meta delimiter or EOF		var lineStream = fileStream.QueryInterface(Components.interfaces.nsILineInputStream);		var result = {};		var foundMeta = false;		while (lineStream.readLine(result)) {			if (result.value.indexOf("// ==UserScript==") == 0) {				foundMeta = true;				break;			}		}		// gather up meta lines		if (foundMeta) {			while (lineStream.readLine(result)) {				if (result.value.indexOf("// ==/UserScript==") == 0) {					break;				}				var match = result.value.match(/\/\/ \@(\S+)\s+([^\n]+)/);				if (match != null) {					switch (match[1]) {						case "name":						case "namespace":						case "description":							script[match[1]] = match[2];							break;						case "includes":						case "excludes":							script[match[1]].push(match[2]);							break;					}				}			}		}		fileStream.close();		// if no meta info, default to reasonable values		if (script.name == null) {			script.name = parseScriptName(sourceUri);		}		if (script.namespace == null) {			script.namespace = sourceUri.host;		}		if (script.includes.length == 0) {			script.includes.push("*");		}		// open install dialog		var result = {};		window.openDialog("chrome://greasemonkey/content/install.xul", 			"manager", "resizable,centerscreen,modal", script, targetFile, result);		closeDownloadManager();		if (result.value) {			alert("Success! Refresh page to see changes.");		}	}	function handleErrors(e) {		//todo: need to handle this somehow. perhaps nsIUriChecker?		//if (e.name == "NS_ERROR_FILE_NOT_FOUND") {		//	alert("User script could not be found. Please check the name and try again.");		//	window.status = defaultStatus;		//}		//else {			alert("Could not download user script\n\n" + e.toString());		//}	}	function closeDownloadManager() {		var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator); 		var en = wm.getEnumerator(""); 		var n = 0; 		var dlm = null;				while (en.hasMoreElements()) { 			var w = en.getNext(); 			if (w.location.href == "chrome://mozapps/content/downloads/downloads.xul") {				dlm = w;				break;			}		}		if (dlm != null) {			dlm.close();		}	}}
meta: 4585	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/4585/f43e0e5ab0d6da87a43b50ac4d258a8a0bc90dc7/greasemonkey.js/buggy/src/content/greasemonkey.js