changeset 0:d13d59494613

Initial revision
author Guido Berhoerster <guido+set-aside@berhoerster.name>
date Sat, 17 Nov 2018 10:44:16 +0100
parents
children b0827360b8e4
files COPYING Makefile NEWS README _locales/de/messages.json _locales/en/messages.json background.js icons/set-aside-action-dark.svg icons/set-aside-action-light.svg icons/set-aside-sidebar.svg icons/set-aside.svg manifest.json.in sidebar/images/defaultFavicon.svg sidebar/images/remove.svg sidebar/images/thumbnail-placeholder.svg sidebar/js/tab-collection-manager.js sidebar/style/photon-colors.css sidebar/style/tab-collection-manager.css sidebar/tab-collection-manager.html
diffstat 19 files changed, 1759 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/COPYING	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in 
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  This Source Code Form is subject to the terms of the Mozilla Public
+  License, v. 2.0. If a copy of the MPL was not distributed with this
+  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,82 @@
+#
+# Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+NAME =		set-aside
+VERSION =	1
+EXT_NAME =	$(subst -,_,$(NAME))-$(VERSION)
+
+INKSCAPE := 	inkscape
+INFOZIP :=	zip
+SED :=		sed
+
+BITMAP_ICONS =	icons/set-aside-16.png \
+		icons/set-aside-32.png \
+		icons/set-aside-48.png \
+		icons/set-aside-96.png \
+		icons/set-aside-action-dark-16.png \
+		icons/set-aside-action-dark-32.png \
+		icons/set-aside-action-light-16.png \
+		icons/set-aside-action-light-32.png \
+		icons/set-aside-sidebar-16.png \
+		icons/set-aside-sidebar-32.png
+DIST_FILES =	COPYING \
+		NEWS \
+		README \
+		background.js \
+		manifest.json \
+		sidebar/images/defaultFavicon.svg \
+		sidebar/images/remove.svg \
+		sidebar/images/thumbnail-placeholder.svg \
+		sidebar/js/tab-collection-manager.js \
+		sidebar/style/photon-colors.css \
+		sidebar/style/tab-collection-manager.css \
+		sidebar/tab-collection-manager.html \
+		$(wildcard _locales/*/messages.json) \
+		$(BITMAP_ICONS)
+
+.DEFAULT_TARGET = all
+
+.PHONY: all extension clean clobber
+
+all: extension
+
+extension: $(EXT_NAME).zip
+
+$(EXT_NAME).zip: $(DIST_FILES)
+	$(INFOZIP) $@ $^
+
+define generate-icon-rule
+$1: $(1:%-$(lastword $(subst -, ,$1))=%.svg)
+	size=$(lastword $(subst -, ,$(basename $1))); \
+	    $(INKSCAPE) -w $$$${size} -h $$$${size} -e $$@ $$<
+endef
+
+$(foreach icon,$(BITMAP_ICONS),$(eval $(call generate-icon-rule,$(icon))))
+
+manifest.json: manifest.json.in
+	$(SED) 's|@VERSION@|$(VERSION)|g' $< >$@
+
+clean:
+	-rm -f $(BITMAP_ICONS) manifest.json
+
+clobber: clean
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NEWS	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,2 @@
+News
+====
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,56 @@
+Set Aside
+=========
+
+Set Aside is a Firefox Addon which can quickly set aside open tabs from the
+current window and restore them later.
+
+Usage
+-----
+
+Press the extension's button in the tab bar in order to set all currently open
+tabs aside.  Note that tabs which are set aside are closed, this may lead to a
+loss of data if e.g. there is unsubmitted form data.  Tabs with privileged
+protocols such as file:, moz-extension:, or about: cannot be set aside and
+will be left open because the extension would not be able to open them again
+due to browser security policy.
+
+Tabs which were set aside can be managed via the sidebar which shows the
+collections of tabs in the order of creation, including the number of tabs
+belonging to the collection, its creation date and time, as well as thumbnail
+previews of each tab.  Thumbnail previews are not available for tabs which had
+been discarded before being set aside or tabs synced from another device.
+
+Clicking on "Restore Tabs" will restore all tabs of the collection in the
+current window and subsequently remove the collection from the sidebar.
+Clicking on a tab thumbnail will restore that particular tab and subsequently
+remove it from the collection.
+
+Pressing the cross button above the tab thumbnails will remove all tabs
+belonging to the collection.  Pressing the cross button on a tab thumbnail
+will remove that particular tab from the collection.
+
+Contact
+-------
+
+Please send any feedback, translations or bug reports via email to
+<guido+set-aside@berhoerster.name>
+
+Bug Reports
+-----------
+
+When sending bug reports, please always mention the exact version of the addon
+with which the issue occurs as well as the version of Firefox and the operating
+system you are using and make sure that you provide sufficient information to
+reproduce the issue and include any error messages.
+
+License
+-------
+
+Except otherwise noted, all files are Copyright (C) 2018 Guido Berhoerster and
+distributed under the following license terms:
+
+Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+
+This Source Code Form is subject to the terms of the Mozilla Public
+License, v. 2.0. If a copy of the MPL was not distributed with this
+file, You can obtain one at http://mozilla.org/MPL/2.0/.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/_locales/de/messages.json	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,52 @@
+{
+    "extensionName": {
+        "message": "Set Aside",
+        "description": "Name of the extension."
+    },
+    "extensionDescription": {
+        "message": "Speichert offene Tabs in einer Sammlung für später.",
+        "description": "Description of the extension."
+    },
+    "defaultBrowserActionTitle": {
+        "message": "Speichere diese Tabs für später",
+        "description": "Title of the browser action button."
+    },
+    "defaultSidebarTitle": {
+        "message": "Für später gespeicherte Tabs",
+        "description": "Title of the sidebar action."
+    },
+    "showTabsMenuItem": {
+        "message": "Für später gespeicherte Tabs zeigen",
+        "description": "Title of the menu item for opening the sidebar action for managing tabs which were set aside."
+    },
+    "emptySidebarMessage": {
+        "message": "Noch nichts",
+        "description": "Message shown in the sidebar if there are no tab collections yet."
+    },
+    "collectionTitle": {
+        "message": "$NUMBER$ Tab(s)",
+        "description": "Title of the collection containing the number of tabs, the number placholder may refer to one or more tabs.",
+        "placeholders": {
+            "number": {
+                "content": "$1",
+                "example": "42"
+            }
+        }
+    },
+    "restoreTabsButtonTitle": {
+        "message": "Tabs Wiederherstellen",
+        "description": "Title of the button for restoring a tab collection."
+    },
+    "removeTabsButtonTitle": {
+        "message": "Tabs Entfernen",
+        "description": "Title of the button for removing a tab collection."
+    },
+    "removeTabTitle": {
+        "message": "Tab Entfernen",
+        "description": "Title of the button for removing a tab from a collection."
+    },
+    "incognitoModeMessage": {
+        "message": "Privates Surfen",
+        "description": "Message shown in the sidebar when in incognito mode."
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/_locales/en/messages.json	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,52 @@
+{
+    "extensionName": {
+        "message": "Set Aside",
+        "description": "Name of the extension."
+    },
+    "extensionDescription": {
+        "message": "Set open tabs aside in a collection and restore them later.",
+        "description": "Description of the extension."
+    },
+    "defaultBrowserActionTitle": {
+        "message": "Set these Tabs aside",
+        "description": "Title of the browser action button."
+    },
+    "defaultSidebarTitle": {
+        "message": "Tabs You've Set Aside",
+        "description": "Title of the sidebar action."
+    },
+    "showTabsMenuItem": {
+        "message": "Show Tabs You've Set Aside",
+        "description": "Title of the menu item for opening the sidebar action for managing tabs which were set aside."
+    },
+    "emptySidebarMessage": {
+        "message": "Nothing here yet",
+        "description": "Message shown in the sidebar if there are no tab collections yet."
+    },
+    "collectionTitle": {
+        "message": "$NUMBER$ Tab(s)",
+        "description": "Title of the collection containing the number of tabs, the number placholder may refer to one or more tabs.",
+        "placeholders": {
+            "number": {
+                "content": "$1",
+                "example": "42"
+            }
+        }
+    },
+    "restoreTabsButtonTitle": {
+        "message": "Restore Tabs",
+        "description": "Title of the button for restoring a tab collection."
+    },
+    "removeTabsButtonTitle": {
+        "message": "Remove Tabs",
+        "description": "Title of the button for removing a tab collection."
+    },
+    "removeTabTitle": {
+        "message": "Remove Tab",
+        "description": "Title of the button for removing a tab from a collection."
+    },
+    "incognitoModeMessage": {
+        "message": "Private Browsing",
+        "description": "Message shown in the sidebar when in incognito mode."
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/background.js	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,425 @@
+/*
+ * Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+'use strict';
+
+const SUPPORTED_PROTOCOLS = ['https:', 'http:', 'ftp:'];
+const GROUP_KEY_RE = /^collection:[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$/;
+const FIREFOX_VERSION_RE = /^(\d+(?:\.\d+)*)(?:([ab]|pre)(\d+))?$/;
+const FIREFOX_RELEASE_TYPES = {
+    'a': 'alpha',
+    'b': 'beta',
+    'pre': 'prerelease',
+    '': ''
+}
+const THUMBNAIL_WIDTH = 224;
+const THUMBNAIL_HEIGHT = 128;
+
+var tabCollectionsProxy;
+
+function generateUuidV4String() {
+    let uuid = new Uint8Array(16);
+    window.crypto.getRandomValues(uuid);
+    uuid[6] = (uuid[6] & 0x0f) | 0x40;
+    uuid[8] = (uuid[8] & 0x3f) | 0x80;
+
+    let result = [];
+    for (let i = 0; i < uuid.length; i++) {
+        if (i == 4 || i == 6 || i == 8 || i == 10) {
+            result.push('-');
+        }
+        result.push(uuid[i].toString(16).padStart(2, '0'));
+    }
+
+    return result.join('');
+}
+
+function parseFirefoxVersion(firefoxVersionString) {
+    let [, versionString, releaseTypeAbbrev = '', releaseNumberString = '0'] =
+            FIREFOX_VERSION_RE.exec(firefoxVersionString);
+
+    let releaseType = FIREFOX_RELEASE_TYPES[releaseTypeAbbrev];
+
+    let releaseNumber = parseInt(releaseNumberString);
+    let [major = 0, minor = 0, patch = 0] = versionString.split('.')
+            .map(x => parseInt(x));
+
+    return {
+        major,
+        minor,
+        patch,
+        releaseType,
+        releaseNumber,
+    };
+}
+
+class Tab {
+    static deserialize(object) {
+        return new Tab(object);
+    }
+
+    constructor({url, title, uuid = generateUuidV4String(), favIconUrl = null,
+            thumbnailUrl = null}) {
+        this.uuid = uuid;
+        this.url = url;
+        this.title = title;
+        this.favIconUrl = favIconUrl;
+        this.thumbnailUrl = thumbnailUrl;
+    }
+
+    serialize() {
+        return Object.assign({}, this);
+    }
+}
+
+class TabCollection {
+    static deserialize(object) {
+        object.tabs = Array.from(object.tabs,
+                ([, tab]) => [tab.uuid, Tab.deserialize(tab)]);
+        return new TabCollection(object);
+    }
+
+    constructor({tabs, uuid = generateUuidV4String(), date = new Date()}) {
+        this.uuid = uuid;
+        this.date = new Date(date);
+        this.tabs = new Map();
+        // allow any type which allows iteration
+        for (let [, tab] of tabs) {
+            this.tabs.set(tab.uuid, tab);
+        }
+    }
+
+    serialize() {
+        let serializedTabs = [];
+        for (let [tabUuid, tab] of this.tabs) {
+            serializedTabs.push([tab.uuid, tab.serialize()]);
+        }
+        return {
+            uuid: this.uuid,
+            date: this.date.toJSON(),
+            tabs: serializedTabs
+        };
+    }
+}
+
+class TabCollectionsStorageProxy {
+    constructor() {
+        this.tabCollections = new Map();
+        this.ports = new Set();
+        this.browserVersion = undefined;
+        this.messageQueue = [];
+        this.isInitialized = false;
+
+        browser.runtime.onConnect.addListener(this.onConnect.bind(this));
+    }
+
+    async init() {
+        let browserInfo = await browser.runtime.getBrowserInfo();
+        this.browserVersion = parseFirefoxVersion(browserInfo.version);
+
+        // get all tab collections and deserialize them in a Map
+        let storageEntries = Object.entries(await browser.storage.sync.get())
+                .filter(([key, value]) => GROUP_KEY_RE.test(key))
+                .map(([key, tabCollection]) =>
+                [tabCollection.uuid, TabCollection.deserialize(tabCollection)]);
+        this.tabCollections = new Map(storageEntries);
+        console.log('tab collections from storage');
+        console.table(this.tabCollections);
+        console.groupEnd();
+        browser.storage.onChanged.addListener(this.onStorageChanged.bind(this));
+
+        this.isInitialized = true;
+
+        while (this.messageQueue.length > 0) {
+            let [message, port] = this.messageQueue.pop();
+            if (this.ports.has(port)) {
+                this.onMessage(message, port);
+            }
+        }
+    }
+
+    async createTabThumbnail(tabId) {
+        let captureUrl = await browser.tabs.captureTab(tabId);
+        let thumbnailUrl = await new Promise((resolve, reject) => {
+            let image = new Image();
+            image.addEventListener('load', ev => {
+                let canvas = document.createElement('canvas');
+                canvas.width = THUMBNAIL_WIDTH;
+                canvas.height = THUMBNAIL_HEIGHT;
+                let dWidth = canvas.width;
+                let dHeight = dWidth * (image.height / image.width);
+
+                let ctx = canvas.getContext('2d');
+                ctx.fillStyle = '#fff';
+                ctx.fillRect(0, 0, canvas.width, canvas.height);
+                ctx.drawImage(image, 0, 0, dWidth, dHeight);
+
+                resolve(canvas.toDataURL('image/jpeg', 0.75));
+            });
+            image.addEventListener('error', e => {
+                reject(e);
+            });
+            image.src = captureUrl;
+        });
+        return thumbnailUrl;
+    }
+
+    async createTabCollection(windowId) {
+        let browserTabs = await browser.tabs.query({
+            windowId,
+            hidden: false,
+            pinned:false
+        });
+
+        // sanity check to prevent saving tabs from incognito windows
+        if (browserTabs.length === 0 || browserTabs[0].incognito) {
+            return;
+        }
+
+        // filter out tabs which cannot be restored
+        browserTabs = browserTabs.filter(browserTab =>
+                SUPPORTED_PROTOCOLS.includes(new URL(browserTab.url).protocol));
+        if (browserTabs.length === 0) {
+            return;
+        }
+
+        let tabs = browserTabs.map(browserTab => {
+            let tab = new Tab({
+                url: browserTab.url,
+                title: browserTab.title,
+                favIconUrl: browserTab.favIconUrl
+            });
+            return [tab.uuid, tab];
+        });
+
+        // create empty tab which becomes the new active tab
+        await browser.tabs.create({active: true});
+
+        // capture tabs, return null for discarded tabs since they can only be
+        // captured after they have been restored, e.g. through user
+        // interaction, and thus might hang the capture process indefinetly
+        let thumbnails = await Promise.all(browserTabs.map(browserTab =>
+                !browserTab.discarded ?
+                this.createTabThumbnail(browserTab.id) : null));
+        for (let [, tab] of tabs) {
+            tab.thumbnailUrl = thumbnails.shift();
+        }
+
+        let tabCollection = new TabCollection({tabs});
+        console.log('created tab collection:', tabCollection);
+
+        // store tab collection
+        console.log('storing tab collection:', tabCollection);
+        await browser.storage.sync.set({
+            [`collection:${tabCollection.uuid}`]: tabCollection.serialize()
+        });
+
+        // remove tabs
+        await browser.tabs.remove(browserTabs.map(browserTab => browserTab.id));
+    }
+
+    async removeTab(tabCollectionUuid, tabUuid) {
+        console.log('removing tab %s from collection %s', tabUuid,
+                tabCollectionUuid);
+        let tabCollection = this.tabCollections.get(tabCollectionUuid);
+        // create shallow clone
+        let newTabCollection = new TabCollection(tabCollection);
+        newTabCollection.tabs.delete(tabUuid);
+        // remove tab collection if there are no more tabs
+        if (newTabCollection.tabs.size === 0) {
+            return this.removeTabCollection(tabCollectionUuid);
+        }
+        await browser.storage.sync.set({
+            [`collection:${tabCollectionUuid}`]: newTabCollection.serialize()
+        });
+    }
+
+    async restoreTab(tabCollectionUuid, tabUuid, windowId) {
+        console.log('restoring tab %s from collection %s in window %d', tabUuid,
+                tabCollectionUuid, windowId);
+        let tab = this.tabCollections.get(tabCollectionUuid).tabs.get(tabUuid);
+        let tabProperties = {
+            active: false,
+            url: tab.url,
+            windowId
+        };
+        if (this.browserVersion.major >= 63) {
+            tabProperties.discarded = true;
+        }
+        await browser.tabs.create(tabProperties);
+        await this.removeTab(tabCollectionUuid, tabUuid);
+    }
+
+    async removeTabCollection(tabCollectionUuid) {
+        console.log('removing tab collection %s', tabCollectionUuid);
+        await browser.storage.sync.remove(`collection:${tabCollectionUuid}`);
+    }
+
+    async restoreTabCollection(tabCollectionUuid, windowId) {
+        console.log('restoring tab collection %s in window %s',
+                tabCollectionUuid, windowId);
+        let tabProperties = {
+            active: false,
+            windowId
+        };
+        if (this.browserVersion.major >= 63) {
+            tabProperties.discarded = true;
+        }
+        let creatingTabs =
+                Array.from(this.tabCollections.get(tabCollectionUuid).tabs,
+                ([, tab]) => browser.tabs.create(Object.assign({
+                    url: tab.url
+                }, tabProperties)));
+        await Promise.all(creatingTabs);
+        await this.removeTabCollection(tabCollectionUuid);
+    }
+
+    onStorageChanged(changes, areaName) {
+        if (areaName !== 'sync') {
+            return;
+        }
+
+        console.group('sync storage area changed:', changes);
+        console.table(Object.entries(changes)[0][1])
+        console.groupEnd();
+
+        let [key, {oldValue, newValue}] = Object.entries(changes)[0];
+        if (!GROUP_KEY_RE.test(key)) {
+            return;
+        }
+
+        let tabCollectionUuid = key.replace('collection:', '');
+        if (typeof oldValue === 'undefined') {
+            // a new collection was created
+            let newTabCollection = TabCollection.deserialize(newValue);
+            this.tabCollections.set(tabCollectionUuid, newTabCollection);
+
+            this.broadcastMessage({
+                type: 'tabCollectionCreated',
+                tabCollection: newTabCollection
+            });
+        } else if (typeof newValue === 'undefined') {
+            // a collection has been removed
+            this.tabCollections.delete(tabCollectionUuid);
+
+            this.broadcastMessage({
+                type: 'tabCollectionRemoved',
+                tabCollectionUuid
+            });
+        } else {
+            // a collection has changed
+            let newTabCollection = TabCollection.deserialize(newValue);
+            this.tabCollections.set(tabCollectionUuid, newTabCollection);
+
+            this.broadcastMessage({
+                type: 'tabCollectionChanged',
+                tabCollection: newTabCollection
+            });
+        }
+    }
+
+    broadcastMessage(message) {
+        for (let port of this.ports) {
+            port.postMessage(message);
+        }
+    }
+
+    onConnect(port) {
+        console.log('port connected:', port)
+        this.ports.add(port);
+        port.onMessage.addListener(this.onMessage.bind(this));
+        port.onDisconnect.addListener(this.onDisconnect.bind(this));
+    }
+
+    onDisconnect(port) {
+        if (port.error) {
+            console.log(`port connection error: ${port.error}\n`);
+        }
+        console.log('port disconnected:', port);
+        this.ports.delete(port);
+    }
+
+    onMessage(message, port) {
+        if (!this.isInitialized) {
+            console.log('queued message', message, 'from port', port);
+            this.messageQueue.push([message, port]);
+            return;
+        }
+
+        console.log('received message', message, 'on port', port);
+        switch (message.type) {
+            case 'getTabCollections':
+                port.postMessage({
+                    type: 'tabCollections',
+                    tabCollections: this.tabCollections
+                });
+                break;
+            case 'removeTab':
+                this.removeTab(message.tabCollectionUuid, message.tabUuid);
+                break;
+            case 'restoreTab':
+                this.restoreTab(message.tabCollectionUuid, message.tabUuid,
+                        message.windowId);
+                break;
+            case 'removeTabCollection':
+                this.removeTabCollection(message.tabCollectionUuid);
+                break;
+            case 'restoreTabCollection':
+                this.restoreTabCollection(message.tabCollectionUuid,
+                        message.windowId);
+                break;
+        }
+    }
+}
+
+// browser action context menu entry for opening the sidebar
+browser.menus.create({
+    contexts: ['browser_action'],
+    onclick: (info, tab) => browser.sidebarAction.open(),
+    title: browser.i18n.getMessage('showTabsMenuItem')
+});
+
+// disable the browser action for new incognito tabs
+browser.tabs.onCreated.addListener(tab => {
+    if (tab.incognito) {
+        // this does not work, it seems that the browser action is re-enabled
+        // on every update
+        browser.browserAction.disable(tab.id);
+    }
+});
+
+(async () => {
+    // disable the browser action for existing incognito tabs
+    let tabs = await browser.tabs.query({});
+    await Promise.all(tabs.filter(tab => tab.incognito)
+            .map(tab => browser.browserAction.disable(tab.id)))
+
+    tabCollectionsProxy = new TabCollectionsStorageProxy();
+    await tabCollectionsProxy.init();
+
+    browser.browserAction.onClicked.addListener(async targetTab => {
+        // prevent browser action from being activated while a collection is
+        // being created
+        let tabs = await browser.tabs.query({windowId: targetTab.windowId});
+        await Promise.all(tabs.map(tab =>
+                browser.browserAction.disable(tab.id)));
+
+        try {
+            await tabCollectionsProxy.createTabCollection(targetTab.windowId);
+        } catch (e) {
+            tabs = await browser.tabs.query({windowId: targetTab.windowId});
+            await Promise.all(tabs.map(tab =>
+                    browser.browserAction.enable(tab.id)));
+            throw e
+        }
+
+        tabs = await browser.tabs.query({windowId: targetTab.windowId});
+        await Promise.all(tabs.map(tab =>
+                browser.browserAction.enable(tab.id)));
+    });
+})();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/icons/set-aside-action-dark.svg	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,14 @@
+<!--
+Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+
+This Source Code Form is subject to the terms of the Mozilla Public
+License, v. 2.0. If a copy of the MPL was not distributed with this
+file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
+<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+  <g fill="none" opacity=".8" stroke="#0c0c0d" stroke-width="1">
+    <path d="m6 11v1c0 1.1 0.89 2 2 2h4c1.1 0 2-0.89 2-2v-8c0-1.1-0.89-2-2-2h-4c-1.1 0-2 0.89-2 2v4" stroke-width="2"/>
+    <path d="m6 5.5h8"/>
+    <path d="m1.5 9.5h9m-9 0 2 2m-2-2 2-2" stroke-linecap="round"/>
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/icons/set-aside-action-light.svg	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,14 @@
+<!--
+Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+
+This Source Code Form is subject to the terms of the Mozilla Public
+License, v. 2.0. If a copy of the MPL was not distributed with this
+file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
+<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+  <g fill="none" opacity=".8" stroke="#f9f9fa" stroke-width="1">
+    <path d="m6 11v1c0 1.1 0.89 2 2 2h4c1.1 0 2-0.89 2-2v-8c0-1.1-0.89-2-2-2h-4c-1.1 0-2 0.89-2 2v4" stroke-width="2"/>
+    <path d="m6 5.5h8"/>
+    <path d="m1.5 9.5h9m-9 0 2 2m-2-2 2-2" stroke-linecap="round"/>
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/icons/set-aside-sidebar.svg	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,16 @@
+<!--
+Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+
+This Source Code Form is subject to the terms of the Mozilla Public
+License, v. 2.0. If a copy of the MPL was not distributed with this
+file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
+<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+  <g fill="none" opacity=".8" stroke="#0c0c0d" stroke-width="1">
+    <path d="m6 4c0-1.1 0.89-2 2-2h4c1.1 0 2 0.89 2 2v5c0 1.1-0.89 2-2 2h-1"
+    stroke-width="2"/>
+    <path d="m10 5.5h4"/>
+    <rect x="2" y="5" width="8" height="9" rx="2" ry="2" stroke-width="2"/>
+    <path d="m2 8.5h8"/>
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/icons/set-aside.svg	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,15 @@
+<!--
+Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+
+This Source Code Form is subject to the terms of the Mozilla Public
+License, v. 2.0. If a copy of the MPL was not distributed with this
+file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
+<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+  <rect width="16" height="16" rx="3" ry="3" fill="#008ea4"/>
+  <g fill="none" stroke="#ffffff" stroke-width="1">
+    <path d="m6 11v1c0 1.1 0.89 2 2 2h4c1.1 0 2-0.89 2-2v-8c0-1.1-0.89-2-2-2h-4c-1.1 0-2 0.89-2 2v4" stroke-width="2"/>
+    <path d="m6 5.5h8"/>
+    <path d="m1.5 9.5h9m-9 0 2 2m-2-2 2-2" stroke-linecap="round"/>
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/manifest.json.in	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,52 @@
+{
+    "manifest_version": 2,
+    "name": "__MSG_extensionName__",
+    "version": "@VERSION@",
+    "description": "__MSG_extensionDescription__",
+    "author": "Guido Berhoerster",
+    "homepage_url": "https://code.guido-berhoerster.org/addons/firefox-addons/set-aside/",
+    "default_locale": "en",
+    "applications": {
+        "gecko": {
+            "id": "set-aside@code.guido-berhoerster.org",
+            "strict_min_version": "60.0"
+        }
+    },
+    "icons": {
+        "48": "icons/set-aside-48.png",
+        "96": "icons/set-aside-96.png"
+    },
+    "permissions": [
+        "tabs",
+        "storage",
+        "sessions",
+        "menus",
+        "<all_urls>"
+    ],
+    "background": {
+        "scripts": [ "background.js" ]
+    },
+    "browser_action": {
+        "default_area": "tabstrip",
+        "default_title": "__MSG_defaultBrowserActionTitle__",
+        "theme_icons": [{
+            "dark": "icons/set-aside-action-dark-16.png",
+            "light": "icons/set-aside-action-light-16.png",
+            "size": 16
+        }, {
+            "dark": "icons/set-aside-action-dark-32.png",
+            "light": "icons/set-aside-action-light-32.png",
+            "size": 32
+        }]
+    },
+    "sidebar_action": {
+        "browser_style": true,
+        "default_icon": {
+            "16": "icons/set-aside-sidebar-16.png",
+            "32": "icons/set-aside-sidebar-32.png"
+        },
+        "default_panel": "sidebar/tab-collection-manager.html",
+        "default_title": "__MSG_defaultSidebarTitle__",
+        "open_at_install": false
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sidebar/images/defaultFavicon.svg	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,8 @@
+<!-- This icon was created by the Mozilla Project and taken from
+     Firefox 65.0a1. -->
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
+  <path fill="context-fill" fill-opacity="context-fill-opacity" d="M8 0a8 8 0 1 0 8 8 8.009 8.009 0 0 0-8-8zm5.163 4.958h-1.552a7.7 7.7 0 0 0-1.051-2.376 6.03 6.03 0 0 1 2.603 2.376zM14 8a5.963 5.963 0 0 1-.335 1.958h-1.821A12.327 12.327 0 0 0 12 8a12.327 12.327 0 0 0-.156-1.958h1.821A5.963 5.963 0 0 1 14 8zm-6 6c-1.075 0-2.037-1.2-2.567-2.958h5.135C10.037 12.8 9.075 14 8 14zM5.174 9.958a11.084 11.084 0 0 1 0-3.916h5.651A11.114 11.114 0 0 1 11 8a11.114 11.114 0 0 1-.174 1.958zM2 8a5.963 5.963 0 0 1 .335-1.958h1.821a12.361 12.361 0 0 0 0 3.916H2.335A5.963 5.963 0 0 1 2 8zm6-6c1.075 0 2.037 1.2 2.567 2.958H5.433C5.963 3.2 6.925 2 8 2zm-2.56.582a7.7 7.7 0 0 0-1.051 2.376H2.837A6.03 6.03 0 0 1 5.44 2.582zm-2.6 8.46h1.549a7.7 7.7 0 0 0 1.051 2.376 6.03 6.03 0 0 1-2.603-2.376zm7.723 2.376a7.7 7.7 0 0 0 1.051-2.376h1.552a6.03 6.03 0 0 1-2.606 2.376z"/>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sidebar/images/remove.svg	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,11 @@
+<!--
+Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+
+This Source Code Form is subject to the terms of the Mozilla Public
+License, v. 2.0. If a copy of the MPL was not distributed with this
+file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
+<svg version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
+  <path d="m4.5 4.5 7 7m0 -7-7 7" stroke="#0c0c0d" stroke-opacity="1"
+  stroke-linecap="round" stroke-width="1.5"/>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sidebar/images/thumbnail-placeholder.svg	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,16 @@
+<!--
+Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+
+This Source Code Form is subject to the terms of the Mozilla Public
+License, v. 2.0. If a copy of the MPL was not distributed with this
+file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
+<svg version="1.1" viewBox="0 0 224 128" xmlns="http://www.w3.org/2000/svg">
+  <g fill="#ededf0">
+    <rect x="8" y="8" width="208" height="32" rx="4" ry="4"/>
+    <rect x="8" y="48" width="40" height="72" rx="4" ry="4"/>
+    <rect x="56" y="48" width="160" height="24" rx="4" ry="4"/>
+    <rect x="56" y="80" width="160" height="16" rx="4" ry="4"/>
+    <rect x="56" y="104" width="160" height="16" rx="4" ry="4"/>
+  </g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sidebar/js/tab-collection-manager.js	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+'use strict';
+
+var tabManager;
+
+class TabManager {
+    constructor() {
+        this.tabCollectionTemplate =
+                document.querySelector('#tab-collection-template');
+        this.tabItemTemplate = document.querySelector('#tab-item-template');
+        this.tabCollectionsElement = document.querySelector('#tab-collections');
+        this.port = browser.runtime.connect({name: 'tab-collection-manager'});
+        this.port.onMessage.addListener(this.onMessage.bind(this));
+        this.port.onDisconnect.addListener(this.onMessage.bind(this));
+        this.port.postMessage({type: 'getTabCollections'});
+        this.isInitialized = false;
+    }
+
+    initTabCollections(tabCollections) {
+        if (this.isInitialized) {
+            return;
+        }
+
+        for (let tabCollection of tabCollections.values()) {
+            this.prependTabCollection(tabCollection);
+        }
+        this.sortTabCollections();
+
+        document.querySelector('#message').textContent =
+                browser.i18n.getMessage('emptySidebarMessage');
+
+        document.body.addEventListener('click', this);
+
+        this.isInitialized = true;
+    }
+
+    createTabCollectionNode(tabCollection) {
+        let tabCollectionNode =
+                document.importNode(this.tabCollectionTemplate.content, true);
+
+        tabCollectionNode.querySelector('.tab-collection')
+                .dataset.tabCollectionUuid = tabCollection.uuid;
+
+        tabCollectionNode.querySelector('.tab-collection-title').textContent =
+                browser.i18n.getMessage('collectionTitle',
+                tabCollection.tabs.size);
+
+        let tabCollectionCtimeElement =
+                tabCollectionNode.querySelector('.tab-collection-ctime');
+        tabCollectionCtimeElement.dateTime = tabCollection.date.toISOString();
+        tabCollectionCtimeElement.textContent =
+                tabCollection.date.toLocaleString();
+
+        let tabCollectionRestoreElement =
+                tabCollectionNode.querySelector('.restore-tab-collection');
+        tabCollectionRestoreElement.title =
+                tabCollectionRestoreElement.textContent =
+                browser.i18n.getMessage('restoreTabsButtonTitle');
+        tabCollectionNode.querySelector('.remove-tab-collection').title =
+                browser.i18n.getMessage('removeTabsButtonTitle');
+
+        let tabListElement =
+                tabCollectionNode.querySelector('.tab-collection-tabs');
+        for (let tab of tabCollection.tabs.values()) {
+            let tabItemNode = document.importNode(this.tabItemTemplate.content,
+                    true);
+
+            tabItemNode.querySelector('.tab-item').dataset.tabUuid = tab.uuid;
+
+            let tabLinkElement = tabItemNode.querySelector('.tab-link');
+            tabLinkElement.href = tab.url;
+            tabLinkElement.title = tab.title;
+
+            if (tab.thumbnailUrl !== null) {
+                tabItemNode.querySelector('.tab-thumbnail').src =
+                        tab.thumbnailUrl;
+            }
+
+            if (tab.favIconUrl !== null) {
+                tabItemNode.querySelector('.tab-favicon').src = tab.favIconUrl;
+            }
+
+            tabItemNode.querySelector('.tab-title').textContent = tab.title;
+
+            tabItemNode.querySelector('.remove-tab').title =
+                    browser.i18n.getMessage('removeTabTitle');
+
+            tabListElement.append(tabItemNode);
+        }
+
+        return tabCollectionNode;
+    }
+
+    prependTabCollection(tabCollection) {
+        console.log('prepending tab collection', tabCollection,
+                'to tab collections');
+        this.tabCollectionsElement
+                .prepend(this.createTabCollectionNode(tabCollection));
+    }
+
+    replaceTabCollection(tabCollection) {
+        console.log('replacing tab collection', tabCollection);
+        this.tabCollectionsElement.querySelector(`[data-tab-collection-uuid=` +
+                `"${tabCollection.uuid}"]`)
+                .replaceWith(this.createTabCollectionNode(tabCollection));
+    }
+
+    removeTabCollection(tabCollectionUuid) {
+        console.log('removing tab collection %s', tabCollectionUuid);
+        this.tabCollectionsElement
+                .querySelector(`[data-tab-collection-uuid=` +
+                `"${tabCollectionUuid}"]`)
+                .remove();
+
+        if (this.tabCollectionsElement.childElementCount === 0) {
+            // remove any text nodes so that the :empty CSS selectora applies
+            while (this.tabCollectionsElement.firstChild !== null) {
+                this.tabCollectionsElement
+                        .removeChild(this.tabCollectionsElement.firstChild);
+            }
+        }
+    }
+
+    sortTabCollections() {
+        Array.from(this.tabCollectionsElement.children)
+                .map(element =>
+                [element.querySelector('.tab-collection-ctime').dateTime,
+                element])
+                .sort((a, b) => a[0] < b[0] ? 1 : a[0] > b[0] ? -1 : 0)
+                .forEach(([, element]) =>
+                this.tabCollectionsElement.append(element));
+    }
+
+    onMessage(message, port) {
+        console.log('received message', message, 'on port', port);
+        switch (message.type) {
+            case 'tabCollections':
+                this.initTabCollections(message.tabCollections);
+                break;
+            case 'tabCollectionCreated':
+                this.prependTabCollection(message.tabCollection);
+                break;
+            case 'tabCollectionRemoved':
+                this.removeTabCollection(message.tabCollectionUuid);
+                break;
+            case 'tabCollectionChanged':
+                this.replaceTabCollection(message.tabCollection);
+                break;
+        }
+        this.sortTabCollections();
+    }
+
+    handleEvent(ev) {
+        console.log('DOM event', ev);
+        if (ev.type === 'click') {
+            ev.preventDefault();
+            if (ev.target.classList.contains('restore-tab-collection')) {
+                // restore tab collection
+                let tabCollectionUuid = ev.target.closest('.tab-collection')
+                        .dataset.tabCollectionUuid;
+                this.port.postMessage({
+                    type: 'restoreTabCollection',
+                    tabCollectionUuid,
+                    windowId: browser.windows.WINDOW_ID_CURRENT
+                });
+            } else if (ev.target.classList.contains('remove-tab-collection')) {
+                // remove tab collection
+                let tabCollectionUuid = ev.target.closest('.tab-collection')
+                        .dataset.tabCollectionUuid;
+                this.port.postMessage({
+                    type: 'removeTabCollection',
+                    tabCollectionUuid
+                });
+            } else if (ev.target.classList.contains('remove-tab')) {
+                // remove tab from collection
+                let tabItemElement = ev.target.closest('.tab-item');
+                let tabCollectionUuid =
+                        tabItemElement.closest('.tab-collection')
+                        .dataset.tabCollectionUuid;
+                let tabUuid = tabItemElement.dataset.tabUuid;
+                this.port.postMessage({
+                    type: 'removeTab',
+                    tabCollectionUuid,
+                    tabUuid
+                });
+            } else {
+                let tabItemElement = ev.target.closest('.tab-item');
+                if (tabItemElement !== null) {
+                    // restore tab from collection
+                    let tabCollectionUuid =
+                            tabItemElement.closest('.tab-collection')
+                            .dataset.tabCollectionUuid;
+                    let tabUuid = tabItemElement.dataset.tabUuid;
+                    this.port.postMessage({
+                        type: 'restoreTab',
+                        tabCollectionUuid,
+                        tabUuid,
+                        windowId: browser.windows.WINDOW_ID_CURRENT
+                    });
+                }
+            }
+        }
+    }
+}
+
+browser.windows.getCurrent().then(currentWindow => {
+    // disable the sidebar for incognito windows
+    if (currentWindow.incognito) {
+        document.querySelector('#message').textContent =
+                browser.i18n.getMessage('incognitoModeMessage');
+        return;
+    }
+
+    tabManager = new TabManager();
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sidebar/style/photon-colors.css	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,91 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* Photon Colors CSS Variables v3.2.0 */
+
+:root {
+  --magenta-50: #ff1ad9;
+  --magenta-60: #ed00b5;
+  --magenta-70: #b5007f;
+  --magenta-80: #7d004f;
+  --magenta-90: #440027;
+
+  --purple-30: #c069ff;
+  --purple-40: #ad3bff;
+  --purple-50: #9400ff;
+  --purple-60: #8000d7;
+  --purple-70: #6200a4;
+  --purple-80: #440071;
+  --purple-90: #25003e;
+
+  --blue-40: #45a1ff;
+  --blue-50: #0a84ff;
+  --blue-50-a30: rgba(10, 132, 255, 0.3);
+  --blue-60: #0060df;
+  --blue-70: #003eaa;
+  --blue-80: #002275;
+  --blue-90: #000f40;
+
+  --teal-50: #00feff;
+  --teal-60: #00c8d7;
+  --teal-70: #008ea4;
+  --teal-80: #005a71;
+  --teal-90: #002d3e;
+
+  --green-50: #30e60b;
+  --green-60: #12bc00;
+  --green-70: #058b00;
+  --green-80: #006504;
+  --green-90: #003706;
+
+  --yellow-50: #ffe900;
+  --yellow-60: #d7b600;
+  --yellow-70: #a47f00;
+  --yellow-80: #715100;
+  --yellow-90: #3e2800;
+
+  --red-50: #ff0039;
+  --red-60: #d70022;
+  --red-70: #a4000f;
+  --red-80: #5a0002;
+  --red-90: #3e0200;
+
+  --orange-50: #ff9400;
+  --orange-60: #d76e00;
+  --orange-70: #a44900;
+  --orange-80: #712b00;
+  --orange-90: #3e1300;
+
+  --grey-10: #f9f9fa;
+  --grey-10-a10: rgba(249, 249, 250, 0.1);
+  --grey-10-a20: rgba(249, 249, 250, 0.2);
+  --grey-10-a40: rgba(249, 249, 250, 0.4);
+  --grey-10-a60: rgba(249, 249, 250, 0.6);
+  --grey-10-a80: rgba(249, 249, 250, 0.8);
+  --grey-20: #ededf0;
+  --grey-30: #d7d7db;
+  --grey-40: #b1b1b3;
+  --grey-50: #737373;
+  --grey-60: #4a4a4f;
+  --grey-70: #38383d;
+  --grey-80: #2a2a2e;
+  --grey-90: #0c0c0d;
+  --grey-90-a05: rgba(12, 12, 13, 0.05);
+  --grey-90-a10: rgba(12, 12, 13, 0.1);
+  --grey-90-a20: rgba(12, 12, 13, 0.2);
+  --grey-90-a30: rgba(12, 12, 13, 0.3);
+  --grey-90-a40: rgba(12, 12, 13, 0.4);
+  --grey-90-a50: rgba(12, 12, 13, 0.5);
+  --grey-90-a60: rgba(12, 12, 13, 0.6);
+  --grey-90-a70: rgba(12, 12, 13, 0.7);
+  --grey-90-a80: rgba(12, 12, 13, 0.8);
+  --grey-90-a90: rgba(12, 12, 13, 0.9);
+
+  --ink-70: #363959;
+  --ink-80: #202340;
+  --ink-90: #0f1126;
+
+  --white-100: #ffffff;
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sidebar/style/tab-collection-manager.css	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+@import url("chrome://browser/content/extension.css");
+@import url("photon-colors.css");
+
+:root {
+  --box-shadow-border: inset 0 0 0 1px var(--grey-90-a10);
+  --button-highlight-color: var(--grey-90-a10);
+  --secondary-text-color: var(--grey-50);
+  --font-size-display-20: 36px;
+  --font-size-title-20: 17px;
+  --font-size-body-20: 15px;
+  --font-size-body-10: 13px;
+
+  --thumbnail-width: 224px;
+  --thumbnail-height: 128px;
+  --thumbnail-shadow: var(--box-shadow-border), 0 1px 4px var(--grey-90-a30);
+  --thumbnail-shadow-highlight: var(--thumbnail-shadow),
+      0 0 0 5px var(--grey-30);
+
+  --remove-tab-collection-image-width: 16px;
+  --remove-tab-collection-image-height:
+      var(--remove-tab-collection-image-width);
+  --remove-tab-collection-padding: 2px;
+  --remove-tab-collection-width: calc(2 * var(--remove-tab-collection-padding) +
+      var(--remove-tab-collection-image-width));
+  --remove-tab-collection-height: var(--remove-tab-collection-width);
+
+  --favicon-image-width: 32px;
+  --favicon-padding: 4px;
+  --favicon-width: calc(2 * var(--favicon-padding) +
+      var(--favicon-image-width));
+  --favicon-height: var(--favicon-width);
+  --favicon-overlap: 6px;
+
+  --remove-tab-image-width: 16px;
+  --remove-tab-image-height: var(--remove-tab-image-width);
+  --remove-tab-padding: 4px;
+  --remove-tab-width: calc(var(--remove-tab-padding) * 2 +
+      var(--remove-tab-image-width));
+  --remove-tab-height: var(--remove-tab-width);
+  --remove-tab-overlap: calc(var(--remove-tab-width) / 2);
+}
+
+:any-link {
+  text-decoration: none;
+  color: inherit;
+}
+
+body {
+  font-size: var(--font-size-body-20);
+  font-weight: 400;
+}
+
+figure {
+  margin: 0;
+}
+
+#message {
+  margin-top: 1em;
+  color: var(--secondary-text-color);
+  font-size: var(--font-size-display-20);
+  font-weight: 300;
+  text-align: center;
+}
+
+#tab-collections:not(:empty) ~ #message {
+  display: none;
+}
+
+#tab-collections {
+  display: flex;
+  flex-direction: column;
+}
+
+.tab-collection {
+  margin: 16px 0;
+}
+
+.tab-collection-header {
+  display: flex;
+  flex-wrap: wrap;
+  align-items: baseline;
+  margin: 4px;
+}
+
+.tab-collection-title {
+  font-size: var(--font-size-title-20);
+  font-weight: 500;
+}
+
+.tab-collection-title,
+.tab-collection-ctime {
+  white-space: nowrap;
+  margin: 0 0 0 6px;
+}
+
+.tab-collection-ctime {
+  font-size: var(--font-size-body-10);
+  color: var(--secondary-text-color);
+}
+
+.tab-collection-actions,
+.tab-collection-tabs {
+  display: flex;
+  padding-left: 0;
+  margin: 0;
+  list-style: none;
+  overflow: auto;
+}
+
+.tab-collection-actions {
+  font-size: var(--font-size-body-10);
+  justify-content: flex-end;
+  white-space: nowrap;
+  margin: 4px 8px;
+  align-items: center;
+}
+
+.tab-collection-actions > li + li {
+  margin-left: 8px;
+}
+
+.remove-tab-collection {
+  width: var(--remove-tab-collection-width);
+  height: var(--remove-tab-collection-height);
+  background: url(../images/remove.svg) var(--remove-tab-collection-padding)/var(--remove-tab-collection-image-width) no-repeat;
+  border-radius: 2px;
+}
+
+.remove-tab-collection:hover {
+  background-color: var(--grey-90-a10);
+}
+
+.restore-tab-collection {
+  cursor: pointer;
+}
+
+.restore-tab-collection:hover {
+  text-decoration: underline;
+}
+
+.tab-collection-tabs {
+  margin: 4px 0 0 0;
+}
+
+.tab-item {
+  display: block;
+  position: relative;
+  width: var(--thumbnail-width);
+  margin: var(--remove-tab-overlap) var(--remove-tab-overlap) 4px
+      var(--remove-tab-overlap);
+}
+
+.tab-link:any-link:hover .tab-thumbnail,
+.tab-link:any-link:focus .tab-thumbnail,
+.tab-link:any-link:active .tab-thumbnail {
+  box-shadow: var(--thumbnail-shadow-highlight);
+}
+
+.tab-thumbnail {
+  display: block;
+  margin: 0;
+  border-radius: 6px;
+  box-shadow: var(--thumbnail-shadow);
+  transition: box-shadow 150ms;
+}
+
+.tab-title {
+  font-size: var(--font-size-body-10);
+  white-space: nowrap;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  min-width: 0;
+  margin: calc(var(--favicon-overlap) + 2px) 0 0 0;
+}
+
+.tab-favicon {
+  position: absolute;
+  top: calc(var(--thumbnail-height) - var(--favicon-height) +
+       var(--favicon-overlap));
+  right: calc(-1 * var(--favicon-overlap));
+  width: var(--favicon-width);
+  height: var(--favicon-height);
+  padding: var(--favicon-padding);
+  background-color: var(--white-100);
+  border-radius: 6px;
+  box-shadow: inset 0 0 0 1px var(--grey-90-a10);
+  cursor: pointer;
+}
+
+.remove-tab {
+  position: absolute;
+  top: calc(-1 * var(--remove-tab-overlap));
+  right: calc(-1 * var(--remove-tab-overlap));
+  width: var(--remove-tab-width);
+  height: var(--remove-tab-height);
+  background: url(../images/remove.svg)
+      var(--remove-tab-padding)/var(--remove-tab-image-width) no-repeat
+      var(--white-100);
+  border-radius: 100%;
+  box-shadow: var(--box-shadow-border);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sidebar/tab-collection-manager.html	Sat Nov 17 10:44:16 2018 +0100
@@ -0,0 +1,49 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+<!--
+   Copyright (C) 2018 Guido Berhoerster <guido+set-aside@berhoerster.name>
+
+   This Source Code Form is subject to the terms of the Mozilla Public
+   License, v. 2.0. If a copy of the MPL was not distributed with this
+   file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
+    <script src="js/tab-collection-manager.js" defer></script>
+    <link rel="stylesheet" href="style/tab-collection-manager.css">
+  </head>
+  <body>
+    <template id="tab-collection-template">
+      <div class="tab-collection" data-tab-collection-uuid="">
+        <div class="tab-collection-header">
+          <h2 class="tab-collection-title"></h2>
+          <time class="tab-collection-ctime" datetime=""></time>
+        </div>
+        <ul class="tab-collection-actions">
+          <li><div class="restore-tab-collection" title=""></div></li>
+          <li><div class="remove-tab-collection" title=""></div></li>
+        </ul>
+        <ul class="tab-collection-tabs">
+        </ul>
+      </div>
+    </template>
+    <template id="tab-item-template">
+      <li class="tab-item" data-tab-uuid="">
+        <a class="tab-link" href="" title="">
+          <figure>
+            <img class="tab-thumbnail" width="224" height="128"
+            src="images/thumbnail-placeholder.svg" alt="">
+            <figcaption class="tab-title"></figcaption>
+          </figure>
+          <img class="tab-favicon" width="32" height="32"
+          src="images/defaultFavicon.svg" alt="">
+        </a>
+        <div class="remove-tab" href="" title=""></div>
+      </li>
+    </template>
+    <div id="tab-collections"><!-- leave empty so that the :empty CSS selector
+    applies --></div>
+    <div id="message">
+    </div>
+  </body>
+</html>