Changeset 748
- Timestamp:
- 06/30/08 20:40:32 (5 months ago)
- Files:
-
- trunk/src/chrome/chromeFiles/content/config.js (modified) (7 diffs)
- trunk/src/components/greasemonkey.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/chrome/chromeFiles/content/config.js
r721 r748 88 88 script._resources.push(scriptResource); 89 89 break; 90 case "Unwrap": 91 script._unwrap = true; 92 break; 90 93 } 91 94 } … … 149 152 } 150 153 154 if (scriptObj._unwrap) { 155 scriptNode.appendChild(doc.createTextNode("\n\t\t")); 156 scriptNode.appendChild(doc.createElement("Unwrap")); 157 } 158 151 159 scriptNode.appendChild(doc.createTextNode("\n\t")); 152 160 … … 202 210 } 203 211 204 var match = result.match(/\/\/ \@(\S+)\s+([^\n]+)/); 205 if (match != null) { 206 switch (match[1]) { 212 var match = result.match(/\/\/ \@(\S+)(?:\s+([^\n]+))?/); 213 if (match === null) continue; 214 215 var header = match[1]; 216 var value = match[2]; 217 if (value) { // @header <value> 218 switch (header) { 207 219 case "name": 208 220 case "namespace": 209 221 case "description": 210 script["_" + match[1]] = match[2];222 script["_" + header] = value; 211 223 break; 212 224 case "include": 213 script._includes.push( match[2]);225 script._includes.push(value); 214 226 break; 215 227 case "exclude": 216 script._excludes.push( match[2]);228 script._excludes.push(value); 217 229 break; 218 230 case "require": 219 var reqUri = ioservice.newURI( match[2], null, uri);231 var reqUri = ioservice.newURI(value, null, uri); 220 232 var scriptRequire = new ScriptRequire(script); 221 233 scriptRequire._downloadURL = reqUri.spec; … … 223 235 break; 224 236 case "resource": 225 var res = match[2].match(/(\S+)\s+(.*)/);237 var res = value.match(/(\S+)\s+(.*)/); 226 238 if (res === null) { 227 239 // NOTE: Unlocalized strings 228 240 throw new Error("Invalid syntax for @resource declaration '" + 229 match[2]+ "'. Resources are declared like: " +241 value + "'. Resources are declared like: " + 230 242 "@resource <name> <url>."); 231 243 } … … 245 257 scriptResource._downloadURL = resUri.spec; 246 258 script._resources.push(scriptResource); 259 break; 260 } 261 } else { // plain @header 262 switch (header) { 263 case "unwrap": 264 script._unwrap = true; 247 265 break; 248 266 } … … 416 434 this._requires = []; 417 435 this._resources = []; 436 this._unwrap = false; 418 437 } 419 438 … … 444 463 get requires() { return this._requires.concat(); }, 445 464 get resources() { return this._resources.concat(); }, 465 get unwrap() { return this._unwrap; }, 446 466 447 467 get _file() { trunk/src/components/greasemonkey.js
r745 r748 126 126 127 127 startup: function() { 128 Cc["@mozilla.org/moz/jssubscript-loader;1"] 129 .getService(Ci.mozIJSSubScriptLoader) 130 .loadSubScript("chrome://global/content/XPCNativeWrapper.js"); 131 132 Cc["@mozilla.org/moz/jssubscript-loader;1"] 133 .getService(Ci.mozIJSSubScriptLoader) 134 .loadSubScript("chrome://greasemonkey/content/prefmanager.js"); 135 136 Cc["@mozilla.org/moz/jssubscript-loader;1"] 137 .getService(Ci.mozIJSSubScriptLoader) 138 .loadSubScript("chrome://greasemonkey/content/utils.js"); 139 140 Cc["@mozilla.org/moz/jssubscript-loader;1"] 141 .getService(Ci.mozIJSSubScriptLoader) 142 .loadSubScript("chrome://greasemonkey/content/config.js"); 143 144 Cc["@mozilla.org/moz/jssubscript-loader;1"] 145 .getService(Ci.mozIJSSubScriptLoader) 146 .loadSubScript("chrome://greasemonkey/content/convert2RegExp.js"); 147 148 Cc["@mozilla.org/moz/jssubscript-loader;1"] 149 .getService(Ci.mozIJSSubScriptLoader) 150 .loadSubScript("chrome://greasemonkey/content/miscapis.js"); 151 152 Cc["@mozilla.org/moz/jssubscript-loader;1"] 153 .getService(Ci.mozIJSSubScriptLoader) 154 .loadSubScript("chrome://greasemonkey/content/xmlhttprequester.js"); 155 156 Cc["@mozilla.org/moz/jssubscript-loader;1"] 157 .getService(Ci.mozIJSSubScriptLoader) 158 .loadSubScript("chrome://greasemonkey/content/updater.js"); 159 128 function load(urls) { 129 var loader = Cc["@mozilla.org/moz/jssubscript-loader;1"] 130 .getService(Ci.mozIJSSubScriptLoader); 131 for (var i = 0; i < arguments.length; i++) 132 loader.loadSubScript(arguments[i]); 133 } 134 135 load("chrome://global/content/XPCNativeWrapper.js", 136 "chrome://greasemonkey/content/prefmanager.js", 137 "chrome://greasemonkey/content/utils.js", 138 "chrome://greasemonkey/content/config.js", 139 "chrome://greasemonkey/content/convert2RegExp.js", 140 "chrome://greasemonkey/content/miscapis.js", 141 "chrome://greasemonkey/content/xmlhttprequester.js", 142 "chrome://greasemonkey/content/updater.js"); 160 143 //loggify(this, "GM_GreasemonkeyService"); 161 144 }, … … 310 293 contents + 311 294 "\n"; 312 if (!this.evalInSandbox(scriptSrc, url, sandbox, script)) 295 if (!script.unwrap) 296 scriptSrc = "(function(){"+ scriptSrc +"})()"; 297 if (!this.evalInSandbox(scriptSrc, url, sandbox, script) && script.unwrap) 313 298 this.evalInSandbox("(function(){"+ scriptSrc +"})()", 314 url, sandbox, script); 299 url, sandbox, script); // wrap anyway on early return 315 300 } 316 301 },
