Skip to content
This repository
Browse code

Move convert2RegExp into a module.

Also:
* Add GM_ prefix.
* Separate into "third-party" and restore the original license notice.
  • Loading branch information...
commit ada8e86ad7b4a1b1c27ca9541f2dc48d65ed7c4b 1 parent bde6904
arantius arantius authored
1  components/greasemonkey.js
@@ -209,7 +209,6 @@ function startup() {
209 209 loader.loadSubScript("chrome://greasemonkey/content/scriptrequire.js");
210 210 loader.loadSubScript("chrome://greasemonkey/content/scriptresource.js");
211 211 loader.loadSubScript("chrome://greasemonkey/content/scripticon.js");
212   - loader.loadSubScript("chrome://greasemonkey/content/convert2RegExp.js");
213 212 loader.loadSubScript("chrome://greasemonkey/content/miscapis.js");
214 213 loader.loadSubScript("chrome://greasemonkey/content/xmlhttprequester.js");
215 214 loader.loadSubScript("chrome://greasemonkey/content/scriptdownloader.js");
4 content/script.js
... ... @@ -1,3 +1,5 @@
  1 +Components.utils.import("resource://greasemonkey/third-party/convert2RegExp.js");
  2 +
1 3 function Script(configNode) {
2 4 this._observers = [];
3 5
@@ -38,7 +40,7 @@ Script.prototype.matchesURL = function(url) {
38 40 return false;
39 41 }
40 42
41   - return convert2RegExp(glob).test(url);
  43 + return GM_convert2RegExp(glob).test(url);
42 44 }
43 45
44 46 return GM_isGreasemonkeyable(url)
37 content/convert2RegExp.js → modules/third-party/convert2RegExp.js
... ... @@ -1,6 +1,37 @@
  1 +/* ***** BEGIN LICENSE BLOCK *****
  2 + * Version: MPL 1.1
  3 + *
  4 + * The contents of this file are subject to the Mozilla Public License Version
  5 + * 1.1 (the "License"); you may not use this file except in compliance with
  6 + * the License. You may obtain a copy of the License at
  7 + * http://www.mozilla.org/MPL/
  8 + *
  9 + * Software distributed under the License is distributed on an "AS IS" basis,
  10 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11 + * for the specific language governing rights and limitations under the
  12 + * License.
  13 + *
  14 + * The Original Code is AdBlock for Mozilla.
  15 + *
  16 + * The Initial Developer of the Original Code is
  17 + * Henrik Aasted Sorensen.
  18 + * Portions created by the Initial Developer are Copyright (C) 2002
  19 + * the Initial Developer. All Rights Reserved.
  20 + *
  21 + * Contributor(s):
  22 + * Henrik Aasted Sorensen <henrik@aasted.org>
  23 + * Stefan Kinitz <mcmurmel.blah@gmx.de>
  24 + * Rue <quill@ethereal.net>
  25 + *
  26 + * ***** END LICENSE BLOCK ***** */
  27 +
  28 +var EXPORTED_SYMBOLS = ['GM_convert2RegExp'];
  29 +
  30 +Components.utils.import("resource://greasemonkey/utils.js");
  31 +
  32 +
1 33 // Converts a pattern in this programs simple notation to a regular expression.
2   -// thanks AdBlock! http://www.mozdev.org/source/browse/adblock/adblock/
3   -function convert2RegExp( pattern ) {
  34 +function GM_convert2RegExp( pattern ) {
4 35 var s = new String(pattern);
5 36 var res = new String("^");
6 37
@@ -47,4 +78,4 @@ function convert2RegExp( pattern ) {
47 78 }
48 79 return new RegExp(res + "$", "i");
49 80 }
50   -convert2RegExp = GM_memoize(convert2RegExp);
  81 +GM_convert2RegExp = GM_memoize(GM_convert2RegExp);

0 comments on commit ada8e86

Please sign in to comment.
Something went wrong with that request. Please try again.