diff options
-rw-r--r-- | lib/main.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/main.js b/lib/main.js index 1de348f..0b66097 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,14 +1,21 @@ exports.main = function(options, callback) { require("tab-browser").whenContentLoaded( function(window) { - if (window.location.protocol == "https:" && - /bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(window.location.href)) { + if (onBugzillaPage(window)) { tweakBugzilla(window.document); } } ); }; +function onBugzillaPage(window) { + if ("window" in window) { + window = window.window; + } + return window.location.protocol == "https:" && + /bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(window.location.href); +} + function tweakBugzilla(d) { // run on both bugzilla.m.o and bugzilla-stage-tip.m.o if (!/bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(d.location.href)) @@ -72,6 +79,7 @@ function tweakBugzilla(d) { var style = d.getElementById("bztw_cc"); var ccMenuItem = contextMenu.Item({ label: "Toggle CC History", + context: onBugzillaPage, onClick: function() style.disabled = !style.disabled }); contextMenu.add(ccMenuItem); @@ -155,6 +163,7 @@ function tweakBugzilla(d) { message = message.textContent; var copyCheckinCommentItem = contextMenu.Item({ label: "Copy Check-in Comment", + context: onBugzillaPage, onClick: function() require("clipboard").set(message) }); contextMenu.add(copyCheckinCommentItem); |