From 1b5e7e630443707f6998e77d2a951a54da7f0aa6 Mon Sep 17 00:00:00 2001 From: Will Bamberg Date: Fri, 13 Oct 2017 11:05:50 -0700 Subject: [PATCH] Review comments from andym --- session-state/README.md | 2 ++ session-state/background.js | 15 ++------------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/session-state/README.md b/session-state/README.md index 48e92e3..a92bc48 100644 --- a/session-state/README.md +++ b/session-state/README.md @@ -6,6 +6,8 @@ This extension adds a context menu item. When the user clicks the context menu i But the extension also uses `sessions.setTabValue` to store the fact that it has added a border to this page. If the user closes the page, then restores it, the extension will retrieve this fact using `sessions.getTabValue`, and use that to reapply the border. +Note: to restore a tab, press Control+Shift+T (or Command+Shift+T on a Mac). In Firefox you can also restore the tab from your "History->Recently Closed Tabs" menu. + ## What it shows This example demonstrates how you can use the [sessions](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/sessions) API to store and retrieve arbitrary state that you want to associate with a tab or window. Then if the tab/window is closed and subsequently restored, you can retrieve the state. diff --git a/session-state/background.js b/session-state/background.js index 6ec262f..1469434 100644 --- a/session-state/background.js +++ b/session-state/background.js @@ -2,8 +2,8 @@ * Add a context menu item to borderify the current tab. */ browser.menus.create({ - id: "borderify", - title: "borderify", + id: "borderify-current-tab", + title: "Borderify current tab", contexts: ["all"] }); @@ -49,14 +49,3 @@ browser.tabs.onCreated.addListener((tab) => { let thisBorderifyRestored = borderifyRestored.bind(null, tab.id); browser.tabs.onUpdated.addListener(thisBorderifyRestored); }); - -/* -browser.tabs.onUpdated.addListener((tabId) => { - console.log(tabId); - browser.sessions.getTabValue(tabId, "border-css").then(result => { - if (result) { - browser.tabs.insertCSS(tabId, {code: result, runAt: "document_end"}); - } - }); -}); -*/