aboutsummaryrefslogtreecommitdiffhomepage
path: root/background.js
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2018-09-10 10:12:33 -0400
committerGravatar Benjamin Barenblat <bbaren@google.com>2018-09-10 10:12:33 -0400
commitb5bb57ff01f88bd9de411e1d963cfae2e285c82a (patch)
treed26c7ca2fa56ad6e48d791e8b169cf3186fbbc9f /background.js
parent6842b33e8157bfab60096001355c76ac06b63e6b (diff)
Gray out button on URL schemes the Wayback Machine doesn’t indexv1.0.1
Switch from a browser action to a page action, and disable the page action on some pages clearly not accessible through the Wayback Machine (e.g., pages under chrome://).
Diffstat (limited to 'background.js')
-rw-r--r--background.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/background.js b/background.js
index 30d924a..6beab65 100644
--- a/background.js
+++ b/background.js
@@ -12,6 +12,20 @@
// License for the specific language governing permissions and limitations under
// the License.
-chrome.browserAction.onClicked.addListener(function(tab) {
+chrome.pageAction.onClicked.addListener(function(tab) {
chrome.tabs.update(null, {url: 'https://web.archive.org/web/*/' + tab.url});
});
+
+chrome.runtime.onInstalled.addListener(function() {
+ chrome.declarativeContent.onPageChanged.removeRules(null, function() {
+ chrome.declarativeContent.onPageChanged.addRules([
+ {
+ conditions: [
+ new chrome.declarativeContent.PageStateMatcher(
+ {pageUrl: {schemes: ['ftp', 'http', 'https']}}),
+ ],
+ actions: [new chrome.declarativeContent.ShowPageAction()],
+ },
+ ]);
+ });
+});