From 2b4ce1c26b5eee5d4864d088657119c58b97e856 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Thu, 1 Sep 2011 11:15:44 +0200 Subject: Use regular expressions instead of long long array of URLs. Yes, I know https://groups.google.com/d/topic/alt.religion.emacs/DR057Srw5-c/discussion (actually, also http://regex.info/blog/2006-09-15/247 :)) --- lib/main.js | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/main.js b/lib/main.js index 1d97e81..3ca736e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -123,15 +123,12 @@ var contentScriptLibraries = [ self.data.url("lib/bzpage.js") ]; +var mainPMRE = new RegExp("http[s]?:\\/\\/bug(zilla|s)\\.[^\\/]*?" + + "\\/show_bug.cgi\\?id=.*"); libbz.initialize(libbz.config, function() { pageMod.PageMod({ - include : [ - "https://bugzilla.redhat.com/show_bug.cgi?id=*", - "https://bugzilla.mozilla.org/show_bug.cgi?id=*", - "https://bugs.freedesktop.org/show_bug.cgi?id=*", - "https://bugzilla.gnome.org/show_bug.cgi?id=*" - ], + include : [ mainPMRE ], contentScriptWhen : 'ready', contentScriptFile : contentScriptLibraries, onAttach : function onAttach(worker, msg) { @@ -149,22 +146,11 @@ libbz.initialize(libbz.config, function() { }); }); +var skipPGRE = new RegExp("http[s]?:\\/\\/bug(zilla|s)\\.[^\\/]*?" + + "\\/(process_bug|post_bug|attachment).cgi"); pageMod.PageMod({ - include : [ - "https://bugzilla.redhat.com/process_bug.cgi", - "https://bugzilla.redhat.com/post_bug.cgi", - "https://bugzilla.redhat.com/attachment.cgi", - "https://bugs.freedesktop.org/process_bug.cgi", - "https://bugs.freedesktop.org/post_bug.cgi", - "https://bugs.freedesktop.org/attachment.cgi", - "https://bugzilla.mozilla.org/process_bug.cgi", - "https://bugzilla.mozilla.org/post_bug.cgi", - "https://bugzilla.mozilla.org/attachment.cgi", - "https://bugzilla.gnome.org/process_bug.cgi", - "https://bugzilla.gnome.org/post_bug.cgi", - "https://bugzilla.gnome.org/attachment.cgi" - ], + include : [ skipPGRE ], contentScriptWhen : 'ready', contentScriptFile : self.data.url("lib/skip-bug.js") }); -- cgit