From 46263764a0749dff7cc84386e6ac08ef4c95c657 Mon Sep 17 00:00:00 2001 From: Andy McKay Date: Fri, 12 Feb 2016 16:47:21 -0800 Subject: [PATCH 1/3] a tabs example --- tabs-tabs-tabs/README.md | 8 +++++++ tabs-tabs-tabs/manifest.json | 17 +++++++++++++++ tabs-tabs-tabs/tabs.html | 17 +++++++++++++++ tabs-tabs-tabs/tabs.js | 42 ++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 tabs-tabs-tabs/README.md create mode 100644 tabs-tabs-tabs/manifest.json create mode 100644 tabs-tabs-tabs/tabs.html create mode 100644 tabs-tabs-tabs/tabs.js diff --git a/tabs-tabs-tabs/README.md b/tabs-tabs-tabs/README.md new file mode 100644 index 0000000..9bacd34 --- /dev/null +++ b/tabs-tabs-tabs/README.md @@ -0,0 +1,8 @@ +# tabs, tabs, tabs + +This extension includes: + +* a browser action +* a page "tabs.html" with a script "tabs.js" + +It shows a list of tab methods that you can perform on the active tab. diff --git a/tabs-tabs-tabs/manifest.json b/tabs-tabs-tabs/manifest.json new file mode 100644 index 0000000..14f3e25 --- /dev/null +++ b/tabs-tabs-tabs/manifest.json @@ -0,0 +1,17 @@ +{ + "manifest_version": 2, + "name": "Tabs, tabs, tabs", + "version": "0.1", + "applications": { + "gecko": { + "id": "tabs-tabs-tabs@mozilla.org" + } + }, + "browser_action": { + "default_title": "Tabs, tabs, tabs", + "default_popup": "tabs.html" + }, + "permissions": [ + "tabs" + ] +} diff --git a/tabs-tabs-tabs/tabs.html b/tabs-tabs-tabs/tabs.html new file mode 100644 index 0000000..2e99556 --- /dev/null +++ b/tabs-tabs-tabs/tabs.html @@ -0,0 +1,17 @@ + + + + + + + + + Move active tab to the beginning of the window
+ Move active tab to the end of the window
+ Duplicate active tab
+ Reload active tab
+ Remove active tab
+ + + + diff --git a/tabs-tabs-tabs/tabs.js b/tabs-tabs-tabs/tabs.js new file mode 100644 index 0000000..38919e6 --- /dev/null +++ b/tabs-tabs-tabs/tabs.js @@ -0,0 +1,42 @@ +document.addEventListener("click", function(e) { + function callOnActiveTab(callback) { + chrome.tabs.query({}, function(tabs) { + for (var tab of tabs) { + if (tab.active) { + callback(tab); + } + } + }); + } + + if (e.target.id === "tabs-move-beginning") { + callOnActiveTab((tab) => { + chrome.tabs.move([tab.id], {index: 0}); + }); + } + + if (e.target.id === "tabs-move-end") { + callOnActiveTab((tab) => { + chrome.tabs.move([tab.id], {index: -1}); + }); + } + + else if (e.target.id === "tabs-duplicate") { + callOnActiveTab((tab) => { + chrome.tabs.duplicate(tab.id); + }); + } + + else if (e.target.id === "tabs-reload") { + callOnActiveTab((tab) => { + chrome.tabs.reload(tab.id); + }); + } + + else if (e.target.id === "tabs-remove") { + callOnActiveTab((tab) => { + chrome.tabs.remove(tab.id); + }); + } + +}); From 38cb7bb0e7dfb40ccc9dbe9e291d2b4ed6042246 Mon Sep 17 00:00:00 2001 From: Andy McKay Date: Mon, 15 Feb 2016 11:21:16 -0800 Subject: [PATCH 2/3] feedback from wil --- tabs-tabs-tabs/manifest.json | 14 +++++++------- tabs-tabs-tabs/tabs.css | 3 +++ tabs-tabs-tabs/tabs.html | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 tabs-tabs-tabs/tabs.css diff --git a/tabs-tabs-tabs/manifest.json b/tabs-tabs-tabs/manifest.json index 14f3e25..50668c3 100644 --- a/tabs-tabs-tabs/manifest.json +++ b/tabs-tabs-tabs/manifest.json @@ -1,17 +1,17 @@ { - "manifest_version": 2, - "name": "Tabs, tabs, tabs", - "version": "0.1", "applications": { "gecko": { - "id": "tabs-tabs-tabs@mozilla.org" + "id": "tabs-tabs-tabs@mozilla.org", + "strict_min_version": "47.0.0" } }, "browser_action": { "default_title": "Tabs, tabs, tabs", "default_popup": "tabs.html" }, - "permissions": [ - "tabs" - ] + "description": "A list of methods you can perform on a tab.", + "homepage_url": "https://github.com/mdn/webextensions-examples/tree/master/tabs-tabs-tabs", + "manifest_version": 2, + "name": "Tabs, tabs, tabs", + "version": "1.0" } diff --git a/tabs-tabs-tabs/tabs.css b/tabs-tabs-tabs/tabs.css new file mode 100644 index 0000000..8620216 --- /dev/null +++ b/tabs-tabs-tabs/tabs.css @@ -0,0 +1,3 @@ +html, body { + width: 350px; +} diff --git a/tabs-tabs-tabs/tabs.html b/tabs-tabs-tabs/tabs.html index 2e99556..f398378 100644 --- a/tabs-tabs-tabs/tabs.html +++ b/tabs-tabs-tabs/tabs.html @@ -3,6 +3,7 @@ + From c5e1b8991cafd7a64cc692059c68cfd2860db072 Mon Sep 17 00:00:00 2001 From: Andy McKay Date: Wed, 17 Feb 2016 09:41:29 -0800 Subject: [PATCH 3/3] update version --- tabs-tabs-tabs/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs-tabs-tabs/manifest.json b/tabs-tabs-tabs/manifest.json index 50668c3..6877e80 100644 --- a/tabs-tabs-tabs/manifest.json +++ b/tabs-tabs-tabs/manifest.json @@ -2,7 +2,7 @@ "applications": { "gecko": { "id": "tabs-tabs-tabs@mozilla.org", - "strict_min_version": "47.0.0" + "strict_min_version": "47.0a1" } }, "browser_action": {