--- autolink.original.user.js 2005-08-29 20:14:36.000000000 +0200 +++ autolink.user.js 2005-08-29 21:48:08.000000000 +0200 @@ -30,6 +30,9 @@ Version history: + 2005-08-29 21:00: Scope filter parameter regexp added by Johan Sundström. See + http://ecmanaut.blogspot.com/2005/08/adopting-and-adapting-autolink.html + 2005-05-25 00:30: Fixed a bug where inserting a leaf made AutoLink re-examine the entire document from that leaf on. This slowed down the DHTML at http://www.tiddlywiki.com/, for example. @@ -59,7 +62,7 @@ I encourage you to create new filters in your copy of AutoLink. - Filters have three fields: + Filters have three (or four) fields: * name (string) Used for tooltip on created links, e.g. "Link added by AutoLink filter: Plain Text Links". @@ -74,7 +77,10 @@ Arguments: |match|, an output of regexp.exec. (May also treat RegExp.leftContext, etc. as inputs.) Returns: The URL to be used for a link, or |null| to cancel link creation. Must not use filter.regexp, but may use other regular expressions. - + + * scope (regular expression, optional field) + The filter will only be processed on pages matching the URL, if given. + This regular expression reference might be useful: http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:RegExp @@ -362,6 +370,10 @@ k=0; for (j = 0; filter = filters[j]; ++j) { + if (filter.scope && !filter.scope.test(location.href)) { + //GM_log( filter.name + ' filter does not apply to this URL.'); + continue; + } regexp = filter.regexp; if (regexp.test(source)) {