Changeset 679
- Timestamp:
- 03/14/08 07:29:03 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/config-service/src/chrome/chromeFiles/content/browser.js
r678 r679 440 440 } 441 441 442 function scriptsMatching(urls) { 443 var allScripts = GM_getConfig().scripts; 444 var scripts = []; 445 446 for (var i = 0, script; script = allScripts[i]; i++) { 447 for (var j = 0; j < urls.length; j++) { 448 if (script.matchUrl(urls[j])) { 449 scripts.push(script); 450 break; 451 } 452 } 453 } 454 455 return scripts; 456 } 442 function scriptsMatching(urls) 443 GM_getConfig().getMatchingScripts( 444 function(script) urls.some(function(url) script.matchesURL(url)) 445 ); 457 446 458 447 function appendScriptToPopup(script) { branches/config-service/src/chrome/chromeFiles/content/config.js
r678 r679 372 372 }, 373 373 374 get scripts() { 375 return this._scripts.concat(); 376 } 374 get scripts() this._scripts.concat(), 375 getMatchingScripts: function(testFunc) this._scripts.filter(testFunc) 377 376 }; 378 377 … … 401 400 402 401 Script.prototype = { 403 matchUrl: function(url) { 404 var scripts = []; 405 406 for (var j = 0, include; include = this._includes[j]; j++) { 407 if (convert2RegExp(include).test(url)) { 408 for (var k = 0, exclude; exclude = this._excludes[k]; k++) { 409 if (convert2RegExp(exclude).test(url)) { 410 return false; 411 } 412 } 413 return true; 414 } 415 } 416 417 return false; 402 matchesURL: function(url) { 403 function test(page) convert2RegExp(page).test(url); 404 return this._includes.some(test) && !this._excludes.some(test); 418 405 }, 419 406 branches/config-service/src/components/greasemonkey.js
r678 r679 231 231 232 232 initScripts: function(url) { 233 var allScripts = GM_getConfig().scripts; 234 var scripts = []; 235 236 for (var i = 0, script; script = allScripts[i]; i++) { 237 if (script.enabled && script.matchUrl(url)) { 238 scripts.push(script); 239 } 240 } 241 242 log("* number of matching scripts: " + scripts.length); 243 return scripts; 233 return GM_getConfig().getMatchingScripts( 234 function (script) script.enabled && script.matchesURL(url) 235 ); 244 236 }, 245 237
