From b5bb57ff01f88bd9de411e1d963cfae2e285c82a Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Mon, 10 Sep 2018 10:12:33 -0400 Subject: Gray out button on URL schemes the Wayback Machine doesn’t index MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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://). --- background.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'background.js') 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()], + }, + ]); + }); +}); -- cgit v1.2.3