[
  {
    "path": ".circleci/config.yml",
    "content": "version: 2.0\njobs:\n    package:\n        docker:\n            - image: circleci/node:8.9.4\n        steps:\n            - checkout\n            - restore_cache:\n                keys:\n                    - node-modules-\n            - run:\n                name: install\n                command: npm install\n            - run:\n                name: package\n                command: npm run package\n            - run:\n                name: test\n                command: npm test\n            - save_cache:\n                key: node-modules-\n                paths:\n                    - node_modules\n            - store_artifacts:\n                path: addon.xpi\n            - persist_to_workspace:\n                root: .\n                paths:\n                    - ./*\nworkflows:\n    version: 2\n    package:\n        jobs:\n            - package\n\n"
  },
  {
    "path": ".eslintignore",
    "content": "addon/build\nProfile\nweb-ext-artifacts\n"
  },
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n  \"env\": {\n    \"es6\": true,\n    \"webextensions\": true\n  },\n  \"extends\": [\n    \"eslint:recommended\",\n    \"plugin:mozilla/recommended\"\n  ],\n  \"parserOptions\": {\n    \"ecmaVersion\": 8,\n    \"sourceType\": \"module\"\n  },\n  \"plugins\": [\n    \"mozilla\"\n  ],\n  \"root\": true,\n  \"rules\": {\n    \"eqeqeq\": \"error\",\n    \"no-console\": \"warn\",\n    \"space-before-function-paren\": \"off\",\n    \"no-console\": [\"error\", {\"allow\": [\"error\", \"info\", \"trace\", \"warn\"]}]\n  }\n};\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\nweb-ext-artifacts\naddon*.xpi\naddon/build\naddon/manifest.json\n/addon/experiment/study\n/null-addon/addon/experiment\n.DS_Store\n/Profile\n"
  },
  {
    "path": ".stylelintrc",
    "content": "{\n  \"extends\": \"stylelint-config-standard\",\n  \"rules\": {\n    \"font-family-no-missing-generic-family-keyword\": null\n  }\n}"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "content": "# Community Participation Guidelines\n\nThis repository is governed by Mozilla's code of conduct and etiquette guidelines. \nFor more details, please read the\n[Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/). \n\n## How to Report\nFor more information on how to report violations of the Community Participation Guidelines, please read our '[How to Report](https://www.mozilla.org/about/governance/policies/participation/reporting/)' page.\n\n<!--\n## Project Specific Etiquette\n\nIn some cases, there will be additional project etiquette i.e.: (https://bugzilla.mozilla.org/page.cgi?id=etiquette.html).\nPlease update for your project.\n-->\n"
  },
  {
    "path": "LICENSE",
    "content": "Mozilla Public License Version 2.0\n==================================\n\n1. Definitions\n--------------\n\n1.1. \"Contributor\"\n    means each individual or legal entity that creates, contributes to\n    the creation of, or owns Covered Software.\n\n1.2. \"Contributor Version\"\n    means the combination of the Contributions of others (if any) used\n    by a Contributor and that particular Contributor's Contribution.\n\n1.3. \"Contribution\"\n    means Covered Software of a particular Contributor.\n\n1.4. \"Covered Software\"\n    means Source Code Form to which the initial Contributor has attached\n    the notice in Exhibit A, the Executable Form of such Source Code\n    Form, and Modifications of such Source Code Form, in each case\n    including portions thereof.\n\n1.5. \"Incompatible With Secondary Licenses\"\n    means\n\n    (a) that the initial Contributor has attached the notice described\n        in Exhibit B to the Covered Software; or\n\n    (b) that the Covered Software was made available under the terms of\n        version 1.1 or earlier of the License, but not also under the\n        terms of a Secondary License.\n\n1.6. \"Executable Form\"\n    means any form of the work other than Source Code Form.\n\n1.7. \"Larger Work\"\n    means a work that combines Covered Software with other material, in\n    a separate file or files, that is not Covered Software.\n\n1.8. \"License\"\n    means this document.\n\n1.9. \"Licensable\"\n    means having the right to grant, to the maximum extent possible,\n    whether at the time of the initial grant or subsequently, any and\n    all of the rights conveyed by this License.\n\n1.10. \"Modifications\"\n    means any of the following:\n\n    (a) any file in Source Code Form that results from an addition to,\n        deletion from, or modification of the contents of Covered\n        Software; or\n\n    (b) any new file in Source Code Form that contains any Covered\n        Software.\n\n1.11. \"Patent Claims\" of a Contributor\n    means any patent claim(s), including without limitation, method,\n    process, and apparatus claims, in any patent Licensable by such\n    Contributor that would be infringed, but for the grant of the\n    License, by the making, using, selling, offering for sale, having\n    made, import, or transfer of either its Contributions or its\n    Contributor Version.\n\n1.12. \"Secondary License\"\n    means either the GNU General Public License, Version 2.0, the GNU\n    Lesser General Public License, Version 2.1, the GNU Affero General\n    Public License, Version 3.0, or any later versions of those\n    licenses.\n\n1.13. \"Source Code Form\"\n    means the form of the work preferred for making modifications.\n\n1.14. \"You\" (or \"Your\")\n    means an individual or a legal entity exercising rights under this\n    License. For legal entities, \"You\" includes any entity that\n    controls, is controlled by, or is under common control with You. For\n    purposes of this definition, \"control\" means (a) the power, direct\n    or indirect, to cause the direction or management of such entity,\n    whether by contract or otherwise, or (b) ownership of more than\n    fifty percent (50%) of the outstanding shares or beneficial\n    ownership of such entity.\n\n2. License Grants and Conditions\n--------------------------------\n\n2.1. Grants\n\nEach Contributor hereby grants You a world-wide, royalty-free,\nnon-exclusive license:\n\n(a) under intellectual property rights (other than patent or trademark)\n    Licensable by such Contributor to use, reproduce, make available,\n    modify, display, perform, distribute, and otherwise exploit its\n    Contributions, either on an unmodified basis, with Modifications, or\n    as part of a Larger Work; and\n\n(b) under Patent Claims of such Contributor to make, use, sell, offer\n    for sale, have made, import, and otherwise transfer either its\n    Contributions or its Contributor Version.\n\n2.2. Effective Date\n\nThe licenses granted in Section 2.1 with respect to any Contribution\nbecome effective for each Contribution on the date the Contributor first\ndistributes such Contribution.\n\n2.3. Limitations on Grant Scope\n\nThe licenses granted in this Section 2 are the only rights granted under\nthis License. No additional rights or licenses will be implied from the\ndistribution or licensing of Covered Software under this License.\nNotwithstanding Section 2.1(b) above, no patent license is granted by a\nContributor:\n\n(a) for any code that a Contributor has removed from Covered Software;\n    or\n\n(b) for infringements caused by: (i) Your and any other third party's\n    modifications of Covered Software, or (ii) the combination of its\n    Contributions with other software (except as part of its Contributor\n    Version); or\n\n(c) under Patent Claims infringed by Covered Software in the absence of\n    its Contributions.\n\nThis License does not grant any rights in the trademarks, service marks,\nor logos of any Contributor (except as may be necessary to comply with\nthe notice requirements in Section 3.4).\n\n2.4. Subsequent Licenses\n\nNo Contributor makes additional grants as a result of Your choice to\ndistribute the Covered Software under a subsequent version of this\nLicense (see Section 10.2) or under the terms of a Secondary License (if\npermitted under the terms of Section 3.3).\n\n2.5. Representation\n\nEach Contributor represents that the Contributor believes its\nContributions are its original creation(s) or it has sufficient rights\nto grant the rights to its Contributions conveyed by this License.\n\n2.6. Fair Use\n\nThis License is not intended to limit any rights You have under\napplicable copyright doctrines of fair use, fair dealing, or other\nequivalents.\n\n2.7. Conditions\n\nSections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted\nin Section 2.1.\n\n3. Responsibilities\n-------------------\n\n3.1. Distribution of Source Form\n\nAll distribution of Covered Software in Source Code Form, including any\nModifications that You create or to which You contribute, must be under\nthe terms of this License. You must inform recipients that the Source\nCode Form of the Covered Software is governed by the terms of this\nLicense, and how they can obtain a copy of this License. You may not\nattempt to alter or restrict the recipients' rights in the Source Code\nForm.\n\n3.2. Distribution of Executable Form\n\nIf You distribute Covered Software in Executable Form then:\n\n(a) such Covered Software must also be made available in Source Code\n    Form, as described in Section 3.1, and You must inform recipients of\n    the Executable Form how they can obtain a copy of such Source Code\n    Form by reasonable means in a timely manner, at a charge no more\n    than the cost of distribution to the recipient; and\n\n(b) You may distribute such Executable Form under the terms of this\n    License, or sublicense it under different terms, provided that the\n    license for the Executable Form does not attempt to limit or alter\n    the recipients' rights in the Source Code Form under this License.\n\n3.3. Distribution of a Larger Work\n\nYou may create and distribute a Larger Work under terms of Your choice,\nprovided that You also comply with the requirements of this License for\nthe Covered Software. If the Larger Work is a combination of Covered\nSoftware with a work governed by one or more Secondary Licenses, and the\nCovered Software is not Incompatible With Secondary Licenses, this\nLicense permits You to additionally distribute such Covered Software\nunder the terms of such Secondary License(s), so that the recipient of\nthe Larger Work may, at their option, further distribute the Covered\nSoftware under the terms of either this License or such Secondary\nLicense(s).\n\n3.4. Notices\n\nYou may not remove or alter the substance of any license notices\n(including copyright notices, patent notices, disclaimers of warranty,\nor limitations of liability) contained within the Source Code Form of\nthe Covered Software, except that You may alter any license notices to\nthe extent required to remedy known factual inaccuracies.\n\n3.5. Application of Additional Terms\n\nYou may choose to offer, and to charge a fee for, warranty, support,\nindemnity or liability obligations to one or more recipients of Covered\nSoftware. However, You may do so only on Your own behalf, and not on\nbehalf of any Contributor. You must make it absolutely clear that any\nsuch warranty, support, indemnity, or liability obligation is offered by\nYou alone, and You hereby agree to indemnify every Contributor for any\nliability incurred by such Contributor as a result of warranty, support,\nindemnity or liability terms You offer. You may include additional\ndisclaimers of warranty and limitations of liability specific to any\njurisdiction.\n\n4. Inability to Comply Due to Statute or Regulation\n---------------------------------------------------\n\nIf it is impossible for You to comply with any of the terms of this\nLicense with respect to some or all of the Covered Software due to\nstatute, judicial order, or regulation then You must: (a) comply with\nthe terms of this License to the maximum extent possible; and (b)\ndescribe the limitations and the code they affect. Such description must\nbe placed in a text file included with all distributions of the Covered\nSoftware under this License. Except to the extent prohibited by statute\nor regulation, such description must be sufficiently detailed for a\nrecipient of ordinary skill to be able to understand it.\n\n5. Termination\n--------------\n\n5.1. The rights granted under this License will terminate automatically\nif You fail to comply with any of its terms. However, if You become\ncompliant, then the rights granted under this License from a particular\nContributor are reinstated (a) provisionally, unless and until such\nContributor explicitly and finally terminates Your grants, and (b) on an\nongoing basis, if such Contributor fails to notify You of the\nnon-compliance by some reasonable means prior to 60 days after You have\ncome back into compliance. Moreover, Your grants from a particular\nContributor are reinstated on an ongoing basis if such Contributor\nnotifies You of the non-compliance by some reasonable means, this is the\nfirst time You have received notice of non-compliance with this License\nfrom such Contributor, and You become compliant prior to 30 days after\nYour receipt of the notice.\n\n5.2. If You initiate litigation against any entity by asserting a patent\ninfringement claim (excluding declaratory judgment actions,\ncounter-claims, and cross-claims) alleging that a Contributor Version\ndirectly or indirectly infringes any patent, then the rights granted to\nYou by any and all Contributors for the Covered Software under Section\n2.1 of this License shall terminate.\n\n5.3. In the event of termination under Sections 5.1 or 5.2 above, all\nend user license agreements (excluding distributors and resellers) which\nhave been validly granted by You or Your distributors under this License\nprior to termination shall survive termination.\n\n************************************************************************\n*                                                                      *\n*  6. Disclaimer of Warranty                                           *\n*  -------------------------                                           *\n*                                                                      *\n*  Covered Software is provided under this License on an \"as is\"       *\n*  basis, without warranty of any kind, either expressed, implied, or  *\n*  statutory, including, without limitation, warranties that the       *\n*  Covered Software is free of defects, merchantable, fit for a        *\n*  particular purpose or non-infringing. The entire risk as to the     *\n*  quality and performance of the Covered Software is with You.        *\n*  Should any Covered Software prove defective in any respect, You     *\n*  (not any Contributor) assume the cost of any necessary servicing,   *\n*  repair, or correction. This disclaimer of warranty constitutes an   *\n*  essential part of this License. No use of any Covered Software is   *\n*  authorized under this License except under this disclaimer.         *\n*                                                                      *\n************************************************************************\n\n************************************************************************\n*                                                                      *\n*  7. Limitation of Liability                                          *\n*  --------------------------                                          *\n*                                                                      *\n*  Under no circumstances and under no legal theory, whether tort      *\n*  (including negligence), contract, or otherwise, shall any           *\n*  Contributor, or anyone who distributes Covered Software as          *\n*  permitted above, be liable to You for any direct, indirect,         *\n*  special, incidental, or consequential damages of any character      *\n*  including, without limitation, damages for lost profits, loss of    *\n*  goodwill, work stoppage, computer failure or malfunction, or any    *\n*  and all other commercial damages or losses, even if such party      *\n*  shall have been informed of the possibility of such damages. This   *\n*  limitation of liability shall not apply to liability for death or   *\n*  personal injury resulting from such party's negligence to the       *\n*  extent applicable law prohibits such limitation. Some               *\n*  jurisdictions do not allow the exclusion or limitation of           *\n*  incidental or consequential damages, so this exclusion and          *\n*  limitation may not apply to You.                                    *\n*                                                                      *\n************************************************************************\n\n8. Litigation\n-------------\n\nAny litigation relating to this License may be brought only in the\ncourts of a jurisdiction where the defendant maintains its principal\nplace of business and such litigation shall be governed by laws of that\njurisdiction, without reference to its conflict-of-law provisions.\nNothing in this Section shall prevent a party's ability to bring\ncross-claims or counter-claims.\n\n9. Miscellaneous\n----------------\n\nThis License represents the complete agreement concerning the subject\nmatter hereof. If any provision of this License is held to be\nunenforceable, such provision shall be reformed only to the extent\nnecessary to make it enforceable. Any law or regulation which provides\nthat the language of a contract shall be construed against the drafter\nshall not be used to construe this License against a Contributor.\n\n10. Versions of the License\n---------------------------\n\n10.1. New Versions\n\nMozilla Foundation is the license steward. Except as provided in Section\n10.3, no one other than the license steward has the right to modify or\npublish new versions of this License. Each version will be given a\ndistinguishing version number.\n\n10.2. Effect of New Versions\n\nYou may distribute the Covered Software under the terms of the version\nof the License under which You originally received the Covered Software,\nor under the terms of any subsequent version published by the license\nsteward.\n\n10.3. Modified Versions\n\nIf you create software not governed by this License, and you want to\ncreate a new license for such software, you may create and use a\nmodified version of this License if you rename the license and remove\nany references to the name of the license steward (except to note that\nsuch modified license differs from this License).\n\n10.4. Distributing Source Code Form that is Incompatible With Secondary\nLicenses\n\nIf You choose to distribute Source Code Form that is Incompatible With\nSecondary Licenses under the terms of this version of the License, the\nnotice described in Exhibit B of this License must be attached.\n\nExhibit A - Source Code Form License Notice\n-------------------------------------------\n\n  This Source Code Form is subject to the terms of the Mozilla Public\n  License, v. 2.0. If a copy of the MPL was not distributed with this\n  file, You can obtain one at http://mozilla.org/MPL/2.0/.\n\nIf it is not possible or desirable to put the notice in a particular\nfile, then You may include the notice in a location (such as a LICENSE\nfile in a relevant directory) where a recipient would be likely to look\nfor such a notice.\n\nYou may add additional accurate notices of copyright ownership.\n\nExhibit B - \"Incompatible With Secondary Licenses\" Notice\n---------------------------------------------------------\n\n  This Source Code Form is \"Incompatible With Secondary Licenses\", as\n  defined by the Mozilla Public License, v. 2.0.\n"
  },
  {
    "path": "README.md",
    "content": "# Side View\n\nAn experiment with opening mobile views of pages in the sidebar.\n\n[**Install from addons.mozilla.org**](https://addons.mozilla.org/en-US/firefox/addon/side-view/)\n\n## Installing\n\nUse `npm install`, then `npm start`.\n\n## Installing manually\n\nCheck out the repository. Go to `about:debugging` in Firefox, and select **Load Temporary Add-on**. Select a file in the `addon/` directory.\n\nOr: install [`web-ext`](https://github.com/mozilla/web-ext) (like `npm i -g web-ext`) and run `web-ext run -s addon/ --browser-console -f nightly`\n\n## Using\n\nThis adds a context menu item: **Open in sidebar** or **Open link in sidebar**. Select that, and the sidebar will be opened with a mobile view of the page.\n\n## Credits\n\n[Anthony_f](https://addons.mozilla.org/en-US/firefox/user/Anthony_f/)'s [Sidebar for Google Search](https://addons.mozilla.org/en-US/firefox/addon/sidebar-for-google-search/) inspired this add-on's approach.\n"
  },
  {
    "path": "addon/background.js",
    "content": "const FIREFOX_VERSION = /rv:([0-9.]+)/.exec(navigator.userAgent)[1];\n\nconst USER_AGENT = `Mozilla/5.0 (Android 14; Mobile; rv:${FIREFOX_VERSION}) Gecko/${FIREFOX_VERSION} Firefox/${FIREFOX_VERSION}`;\n// iOS:\n//   Mozilla/5.0 (iPhone; CPU iPhone OS 9_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/47.0.2526.70 Mobile/13C71 Safari/601.1.46\n// Firefox for Android:\n//   Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0\n// Chrome for Android:\n//   Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19\n\n// If you update DEFAULT_DESKTOP_SITES you should also increment DEFAULT_DESKTOP_VERSION\nconst DEFAULT_DESKTOP_SITES = [\n  \"www.youtube.com\",\n  \"www.metacafe.com\",\n  \"myspace.com\",\n  \"imgur.com\",\n  \"meet.google.com\",\n  \"meet.app.goo.gl\",\n];\n\nconst DEFAULT_DESKTOP_VERSION = 2;\n\nconst MAX_RECENT_TABS = 5;\nlet sidebarUrl;\nlet hasSeenPrivateWarning = false;\n\nbrowser.contextMenus.create({\n  id: \"open-in-sidebar\",\n  title: \"Open in Side View\",\n  contexts: [\"page\", \"tab\", \"bookmark\"],\n  documentUrlPatterns: [\"<all_urls>\"],\n});\n\nbrowser.contextMenus.create({\n  id: \"open-link-in-sidebar\",\n  title: \"Open link in Side View\",\n  // FIXME: could add \"bookmark\", but have to fetch by info.bookmarkId\n  contexts: [\"link\"],\n  documentUrlPatterns: [\"<all_urls>\"],\n});\n\nbrowser.contextMenus.onClicked.addListener(async (info, tab) => {\n  let url;\n  let favIconUrl;\n  let title;\n  let incognito = tab && tab.incognito;\n  await browser.sidebarAction.open();\n  if (info.linkUrl) {\n    url = info.linkUrl;\n  } else if (info.bookmarkId) {\n    let bookmarkInfo = await browser.bookmarks.get(info.bookmarkId);\n    url = bookmarkInfo[0].url;\n  } else {\n    url = tab.url;\n    title = tab.title;\n    favIconUrl = tab.favIconUrl;\n  }\n  if (title && !incognito) {\n    // In cases when we can't get a good title and favicon, we just don't bother saving it as a recent tab\n    addRecentTab({url, favIconUrl, title});\n  }\n  openUrl(url);\n});\n\nbrowser.pageAction.onClicked.addListener((async (tab) => {\n  let url = tab.url;\n  if (!tab.incognito) {\n    addRecentTab({url, favIconUrl: tab.favIconUrl, title: tab.title});\n  }\n  await browser.sidebarAction.open();\n  openUrl(url);\n}));\n\nasync function openUrl(url) {\n  sidebarUrl = url;\n  let hostname = (new URL(url)).hostname;\n  let isDesktop = !!desktopHostnames[hostname];\n  browser.runtime.sendMessage({\n    type: \"isDesktop\",\n    isDesktop,\n  }).catch((error) => {\n    // If the popup is not open this gives an error, but we don't care\n  });\n  browser.sidebarAction.setPanel({panel: url});\n}\n\n/* eslint-disable consistent-return */\n// Because this dispatches to different kinds of functions, its return behavior is inconsistent\nbrowser.runtime.onMessage.addListener(async (message) => {\n  if (message.type === \"toggleDesktop\") {\n    toggleDesktop();\n  } else if (message.type === \"openUrl\") {\n    openUrl(message.url);\n    let windowInfo = await browser.windows.getCurrent();\n    if (!windowInfo.incognito) {\n      addRecentTab(message);\n    }\n  } else if (message.type === \"dismissTab\") {\n    dismissRecentTab(message.index);\n  } else if (message.type === \"getRecentAndDesktop\") {\n    let isDesktop = false;\n    if (sidebarUrl) {\n      let hostname = (new URL(sidebarUrl)).hostname;\n      isDesktop = !!desktopHostnames[hostname];\n    }\n    let currentWindow = await browser.windows.getCurrent();\n    return Promise.resolve({\n      recentTabs,\n      isDesktop,\n      hasSeenPrivateWarning,\n      incognito: currentWindow.incognito,\n    });\n  } else if (message.type === \"turnOffPrivateWarning\") {\n    turnOffPrivateWarning();\n  } else {\n    console.error(\"Unexpected message to background:\", message);\n  }\n});\n/* eslint-enable consistent-return */\n\n// This is a RequestFilter: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/RequestFilter\n// It matches tabs that aren't attached to a normal location (like a sidebar)\n// It only matches embedded iframes\nlet requestFilter = {\n  tabId: -1,\n  types: [\"main_frame\"],\n  urls: [\"http://*/*\", \"https://*/*\"],\n};\n\nlet desktopHostnames = {};\n\nasync function toggleDesktop() {\n  if (!sidebarUrl) {\n    console.warn(\"Got toggle desktop with no known sidebar URL\");\n    return;\n  }\n  let hostname = (new URL(sidebarUrl)).hostname;\n  let isDesktop = !desktopHostnames[hostname];\n  if (isDesktop) {\n    desktopHostnames[hostname] = true;\n  } else {\n    delete desktopHostnames[hostname];\n  }\n  // We can't trigger a real reload without changing the URL, so we change it to blank and then\n  // back to the previous URL:\n  browser.sidebarAction.setPanel({panel: \"about:blank\"});\n  openUrl(sidebarUrl);\n  await browser.storage.local.set({desktopHostnames, defaultDesktopVersion: DEFAULT_DESKTOP_VERSION});\n}\n\nlet recentTabs = [];\n\nasync function addRecentTab(tabInfo) {\n  recentTabs = recentTabs.filter((item) => item.url !== tabInfo.url);\n  recentTabs.unshift(tabInfo);\n  recentTabs.splice(MAX_RECENT_TABS);\n  try {\n    await browser.runtime.sendMessage({\n      type: \"updateRecentTabs\",\n      recentTabs,\n    });\n  } catch (error) {\n    if (String(error).includes(\"Could not establish connection\")) {\n      // We're just speculatively sending messages to the popup, it might not be open,\n      // and that is fine\n    } else {\n      console.error(\"Got updating recent tabs:\", String(error), error);\n    }\n  }\n  await browser.storage.local.set({recentTabs});\n}\n\nasync function dismissRecentTab(tab_index) {\n  recentTabs.splice(tab_index, 1);\n  try {\n    await browser.runtime.sendMessage({\n      type: \"updateRecentTabs\",\n      recentTabs,\n    });\n\n  } catch (error) {\n    if (String(error).includes(\"Could not establish connection\")) {\n      // popup speculation, as in addRecentTab()\n    } else {\n      console.error(\"Got updating recent tabs:\", String(error), error);\n    }\n  }\n  await browser.storage.local.set({recentTabs});\n}\n\n// Add a mobile header to outgoing requests\nbrowser.webRequest.onBeforeSendHeaders.addListener(function (info) {\n  let hostname = (new URL(info.url)).hostname;\n  if (desktopHostnames[hostname]) {\n    return {};\n  }\n  let headers = info.requestHeaders;\n  for (let i = 0; i < headers.length; i++) {\n    let name = headers[i].name.toLowerCase();\n    if (name === \"user-agent\") {\n      headers[i].value = USER_AGENT;\n      return {\"requestHeaders\": headers};\n    }\n  }\n  return {};\n}, requestFilter, [\"blocking\", \"requestHeaders\"]);\n\nfunction privateWarningOnUpdated(tabId, changeInfo, tab) {\n  if (tab.incognito) {\n    browser.browserAction.setBadgeText({text: \"!\", tabId: tab.id});\n  }\n}\n\nasync function turnOffPrivateWarning() {\n  hasSeenPrivateWarning = true;\n  browser.tabs.onUpdated.removeListener(privateWarningOnUpdated);\n  let win = await browser.windows.getCurrent({populate: true});\n  for (let tab of win.tabs) {\n    browser.browserAction.setBadgeText({text: null, tabId: tab.id});\n  }\n  await browser.storage.local.set({hasSeenPrivateWarning});\n}\n\nfunction showOnboardingBadge() {\n  browser.browserAction.setIcon({path: \"side-view-onboarding.svg\"});\n  function onBrowserActionClick() {\n    browser.browserAction.setPopup({popup: \"intro.html\"});\n    browser.browserAction.openPopup();\n    browser.browserAction.onClicked.removeListener(onBrowserActionClick);\n    browser.browserAction.setIcon({path: \"side-view.svg\"});\n    browser.storage.local.set({hasBeenOnboarded: true});\n    browser.browserAction.setPopup({popup: \"popup.html\"});\n  }\n  // This disables the default popup action and lets us intercept the clicks:\n  browser.browserAction.setPopup({popup: \"\"});\n  browser.browserAction.onClicked.addListener(onBrowserActionClick);\n}\n\nasync function init() {\n  const result = await browser.storage.local.get([\"desktopHostnames\", \"defaultDesktopVersion\", \"recentTabs\", \"hasSeenPrivateWarning\", \"hasBeenOnboarded\"]);\n  if (!result.desktopHostnames) {\n    desktopHostnames = {};\n  } else {\n    desktopHostnames = result.desktopHostnames;\n  }\n  if (!result.defaultDesktopVersion || result.defaultDesktopVersion < DEFAULT_DESKTOP_VERSION) {\n    for (let hostname of DEFAULT_DESKTOP_SITES) {\n      desktopHostnames[hostname] = true;\n    }\n  }\n  recentTabs = result.recentTabs || [];\n  hasSeenPrivateWarning = result.hasSeenPrivateWarning;\n  if (!hasSeenPrivateWarning) {\n    browser.tabs.onUpdated.addListener(privateWarningOnUpdated);\n  }\n  if (!result.hasBeenOnboarded) {\n    showOnboardingBadge();\n  }\n}\n\ninit();\n"
  },
  {
    "path": "addon/buildSettings.js.tmpl",
    "content": "var buildSettings = {\n  NODE_ENV: \"{{NODE_ENV}}\",\n};\n"
  },
  {
    "path": "addon/intro.css",
    "content": ":root {\n  --blue-40: #45a1ff;\n  --blue-50: #0a84ff;\n  --blue-50-a30: rgba(10, 132, 255, 0.3);\n  --blue-60: #0060df;\n  --blue-70: #003eaa;\n  --blue-80: #002275;\n  --blue-90: #000f40;\n}\n\n#container {\n  display: flex;\n  flex-direction: column;\n  width: 100%;\n  font: message-box;\n  font-size: 16px;\n}\n\n.slide {\n  width: 480px;\n  flex-direction: column;\n  align-items: center;\n}\n\n.slide-image {\n  width: 480px;\n  flex: 0 0 270px;\n  border-bottom: 1px solid #ddd;\n}\n\n.slide p {\n  line-height: 1.5em;\n  margin: 0;\n  padding: 0 32px;\n  text-align: center;\n  height: 84px;\n  display: flex;\n  align-items: center;\n  color: black;\n  background: white;\n}\n\n.slide-displayed {\n  display: flex;\n}\n\n.slide-hidden {\n  display: none;\n}\n\n#slide-controls {\n  align-items: center;\n  padding: 0 16px 16px;\n  display: grid;\n  grid-template-columns: 120px 1fr 120px;\n  justify-content: center;\n}\n\nbutton {\n  align-items: center;\n  background: #f2f2f2;\n  border-radius: 2px;\n  border: 0;\n  display: flex;\n  font-size: 14px;\n  height: 32px;\n  justify-content: center;\n  padding: 5px;\n  flex: 1;\n}\n\n.button-hidden {\n  display: none;\n}\n\n.button-invisible {\n  visibility: hidden;\n}\n\n#next,\n#done {\n  grid-column: 3 / -1;\n}\n\n.button-primary {\n  background: var(--blue-50);\n  color: white;\n}\n\n.button-primary:hover,\n.button-primary:focus {\n  background: var(--blue-60);\n}\n\n.button-primary:active {\n  background: var(--blue-70);\n}\n"
  },
  {
    "path": "addon/intro.html",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"UTF-8\">\n    <link rel=\"stylesheet\" href=\"popup.css\">\n    <link rel=\"stylesheet\" href=\"intro.css\">\n  </head>\n  <body>\n    <div id=\"container\">\n      <div id=\"slide-container\">\n        <!-- Slides go in here. If you add a slide, add a button in the controls as well -->\n        <div class=\"slide slide-displayed\" id=\"slide-0\">\n          <img class=\"slide-image\" src=\"images/side-view-tour-1.jpg\" alt=\"\"/>\n          <p>Introducing Side View,<br/> a new way to multitask with Firefox.</p>\n        </div>\n        <div class=\"slide slide-hidden\" id=\"slide-1\">\n          <img class=\"slide-image\" src=\"images/side-view-tour-2.jpg\" alt=\"\" />\n          <p>Side View lets you send websites to your Firefox sidebar.</p>\n        </div>\n        <div class=\"slide slide-hidden\" id=\"slide-2\">\n          <img class=\"slide-image\" src=\"images/side-view-tour-3.jpg\" alt=\"\" />\n          <p>By default, Side View displays mobile sites to keep everything looking good in a narrow window.</p>\n        </div>\n        <div class=\"slide slide-hidden\" id=\"slide-3\">\n          <img class=\"slide-image\"\n          src=\"images/side-view-tour-4.jpg\" alt=\"\" />\n          <p>You can also right click to open links in Side View.</p>\n        </div>\n      </div>\n\n      <div id=\"slide-controls\">\n        <button id=\"previous\" class=\"button-invisible button-secondary\">Previous</button>\n        <button id=\"next\" class=\"button-primary\">Next</button>\n        <button id=\"done\" class=\"button-hidden button-primary\">Done</button>\n      </div>\n\n    </div>\n    <script src=\"intro.js\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "addon/intro.js",
    "content": "let foundSlides = 0;\nlet currentSlide = 0;\n\nfunction selectSlide(num) {\n  for (let i = 0; i < foundSlides; i++) {\n    let el = document.querySelector(`#slide-${i}`);\n    if (i === num) {\n      el.classList.add(\"slide-displayed\");\n      el.classList.remove(\"slide-hidden\");\n    } else {\n      el.classList.remove(\"slide-displayed\");\n      el.classList.add(\"slide-hidden\");\n    }\n  }\n  previous.disabled = num === 0;\n  next.disabled = num === foundSlides - 1;\n}\n\nfor (let el of document.querySelectorAll(\".slide\")) {\n  let num = parseInt(el.id.replace(/[^\\d]/g, \"\"), 10);\n  foundSlides = Math.max(foundSlides + 1, num);\n}\n\nlet previous = document.querySelector(\"#previous\");\nlet next = document.querySelector(\"#next\");\nlet done = document.querySelector(\"#done\");\n\nprevious.addEventListener(\"click\", () => {\n  currentSlide = Math.max(0, currentSlide - 1);\n  if (currentSlide === 0) {\n    previous.classList.add(\"button-invisible\");\n  }\n  if (currentSlide === foundSlides - 2) {\n    next.classList.remove(\"button-hidden\");\n    done.classList.add(\"button-hidden\");\n  }\n  selectSlide(currentSlide);\n});\n\nnext.addEventListener(\"click\", () => {\n  currentSlide = Math.min(foundSlides - 1, currentSlide + 1);\n  if (currentSlide === 1) {\n    previous.classList.remove(\"button-invisible\");\n  }\n  if (currentSlide === foundSlides - 1) {\n    next.classList.add(\"button-hidden\");\n    done.classList.remove(\"button-hidden\");\n  }\n  selectSlide(currentSlide);\n});\n\ndone.addEventListener(\"click\", () => {\n  location.href = \"popup.html\";\n});\n\nselectSlide(currentSlide);\n"
  },
  {
    "path": "addon/manifest.json.tmpl",
    "content": "{\n    \"manifest_version\": 2,\n    \"name\": \"Side View\",\n    \"version\": \"{{version}}\",\n    \"description\": \"{{description}}\",\n    \"icons\": {\n      \"48\": \"side-view.png\",\n      \"96\": \"side-view.png\"\n    },\n    \"author\": \"{{{author}}}\",\n    \"homepage_url\": \"{{{homepage}}}\",\n    \"browser_specific_settings\": {\n      \"gecko\": {\n        \"id\": \"side-view@mozilla.org\",\n        \"strict_min_version\": \"62.0\"\n      }\n    },\n    \"background\": {\n      \"scripts\": [\n        \"build/buildSettings.js\",\n        \"background.js\"\n      ]\n    },\n    \"browser_action\": {\n      \"default_icon\": \"side-view.svg\",\n      \"default_popup\": \"popup.html\",\n      \"default_title\": \"Open Side View\",\n      \"browser_style\": true\n    },\n    \"sidebar_action\": {\n      \"default_icon\": \"side-view.svg\",\n      \"default_title\": \"Side View\",\n      \"default_panel\": \"sidebar.html\",\n      \"browser_style\": false\n    },\n    \"page_action\": {\n      \"default_icon\": \"side-view.svg\",\n      \"default_title\": \"Open Side View\",\n      \"show_matches\": [\"http://*/*\", \"https://*/*\"],\n      \"browser_style\": true\n    },\n    \"web_accessible_resources\": [\n    ],\n    \"permissions\": [\n      \"activeTab\",\n      \"tabs\",\n      \"<all_urls>\",\n      \"storage\",\n      \"contextMenus\",\n      \"webRequest\",\n      \"webRequestBlocking\",\n      \"bookmarks\",\n      \"management\"\n    ]\n  }\n"
  },
  {
    "path": "addon/popup.css",
    "content": "body,\nhtml {\n  font: message-box;\n  overflow: hidden;\n}\n\n:root {\n  --dark-theme-background-color: #4a4a4f;\n  --dark-theme-highlight-color: #6d6d6f;\n  --dark-theme-superhighlight-color: hsla(0, 0%, 80%, 0.45);\n  --dark-theme-color: #fff;\n  --dark-theme-links: #45a1ff;\n}\n\n* {\n  box-sizing: border-box;\n}\n\nbody {\n  height: 100%;\n  margin: 0;\n  min-width: 320px;\n  overflow: hidden !important;\n}\n\n#panel {\n  background: #fff;\n  display: flex;\n  flex-direction: column;\n  justify-content: space-between;\n  max-width: 440px;\n  min-width: 320px;\n  width: 100%;\n}\n\n#panel,\n.tabs-section__title,\n.tab {\n  font: menu;\n}\n\n.separator {\n  background: hsla(210, 4%, 10%, 0.14);\n  height: 1px;\n  margin: 6px 0;\n}\n\n.tabs-wrapper {\n  display: flex;\n  flex-direction: column;\n  flex: 1;\n}\n\n.tabs-section {\n  display: flex;\n  flex-direction: column;\n  max-height: 300px;\n  flex: 1 1;\n}\n\n.tabs-section__title {\n  align-items: center;\n  color: GrayText;\n  display: flex;\n  font-weight: normal;\n  height: 24px;\n  margin: 0;\n  padding: 4px 12px;\n}\n\n.tabs-section:first-child .tabs-section__title {\n  margin-top: 6px;\n}\n\n.tabs-section__list {\n  list-style: none;\n  margin: 0;\n  padding: 0;\n}\n\n#open-tabs-list {\n  flex: 1;\n  overflow-y: auto;\n}\n\n.tab__parent {\n  display: flex;\n  width: 100%;\n  background: #fff;\n  height: 26.5px;\n}\n\n.tab {\n  align-items: center;\n  border: 0;\n  width: 100%;\n  background: transparent;\n  font-weight: normal;\n  padding-inline-start: 18px;\n  padding: 4px 12px;\n  display: flex;\n  overflow: hidden;\n}\n\n.tab__parent:hover,\n.tab__parent:focus {\n  background: #ededf0;\n}\n\n.tab__image,\n.tab__text {\n  pointer-events: none;\n}\n\n.tab__image {\n  background-size: 16px 16px;\n  flex: 0 0 16px;\n  height: 16px;\n  margin-inline-end: 8px;\n}\n\n.tab__dismiss {\n  border: 0;\n  background: transparent;\n  margin-top: 3.25px;\n  margin-left: auto;\n  margin-right: 10px;\n  border-radius: 10%;\n  opacity: 0;\n  height: 20px;\n  padding: 2px;\n}\n\n.tab__dismiss:hover,\n.tab__dismiss:focus {\n  background: rgba(224, 224, 225, 0.9);\n}\n\n.tab__dismiss:hover,\n.tab__dismiss:focus,\n.tab:hover + .tab__dismiss,\n.tab:focus + .tab__dismiss,\n.tab__parent:hover .tab__dismiss,\n.tab__parent:focus .tab__dismiss {\n  opacity: 100;\n}\n\n.tab__dismiss::after {\n  content: url(images/close-16.svg);  /* close symbol */\n}\n\n/* this is a hack if, for any reason, a site does not\nsupply a favicon */\n\n.tab__image[style*=undefined] {\n  background-image: url(images/globe.svg) !important;\n}\n\n.tab__text {\n  margin-top: 1px;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n}\n\n.panel-footer {\n  border-top: 1px solid hsla(210, 4%, 10%, 0.14);\n  display: flex;\n  flex: 0 0 41px;\n  margin: 6px 0 0;\n}\n\n.panel-footer.toggle-disabled {\n  grid-template-columns: 1fr;\n}\n\n.mobile-toggle {\n  border: 0;\n  align-items: center;\n  background: hsla(0, 0%, 80%, 0.3);\n  color: rgb(26, 26, 26);\n  cursor: default;\n  display: flex;\n  flex: 1;\n  font: menu;\n  justify-content: center;\n  margin-bottom: 0;\n  padding: 12px 4px;\n  text-decoration: none;\n}\n\n.toggle-disabled .mobile-toggle {\n  display: none;\n}\n\n.mobile-toggle:hover {\n  background: hsla(0, 0%, 80%, 0.4);\n}\n\n#getting-started {\n  display: none;\n  padding: 1em;\n}\n\n#private-warning {\n  background: #ededf0;\n  border-bottom: 1px dashed #d70022;\n  color: #d70022;\n  display: flex;\n}\n\n#close-private-warning-copy {\n  padding: 12px 0 12px 12px;\n}\n\n#close-private-warning {\n  align-items: center;\n  cursor: pointer;\n  display: flex;\n  flex: 0 0 24px;\n  height: 24px;\n  justify-content: center;\n}\n\n/* Dark theme */\n\n#panel.dark-theme,\n#panel.dark-theme .tab,\n#panel.dark-theme .tab__parent,\n#panel.dark-theme .tab__dismiss {\n  background-color: var(--dark-theme-background-color);\n  color: var(--dark-theme-color);\n}\n\n#panel.dark-theme .tab__parent:hover,\n#panel.dark-theme .tab__parent:focus,\n#panel.dark-theme .tab__parent:hover > *,\n#panel.dark-theme .tab__parent:focus > *,\n#panel.dark-theme .separator {\n  background-color: var(--dark-theme-highlight-color);\n}\n\n#panel.dark-theme .tab__dismiss:hover,\n#panel.dark-theme .tab__dismiss:focus {\n  background-color: var(--dark-theme-background-color);\n}\n\n#panel.dark-theme .tab__dismiss::after {\n  content: url(images/close-16-light.svg);\n}\n\n#panel.dark-theme .mobile-toggle {\n  background-color: var(--dark-theme-superhighlight-color);\n  color: var(--dark-theme-color);\n}\n\n#panel.dark-theme .mobile-toggle:hover {\n  background-color: hsla(0, 0%, 80%, 0.6);\n}\n\n#recent-tabs[style$=\"none;\"] + #open-tabs {\n  margin-top: 6px;\n}\n\n#recent-tabs[style$=\"none;\"] + #open-tabs .separator {\n  display: none !important;\n}\n"
  },
  {
    "path": "addon/popup.html",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"UTF-8\">\n    <title>Popup</title>\n    <link rel=\"stylesheet\" href=\"popup.css\"/>\n  </head>\n  <body>\n    <div id=\"panel\">\n      <div id=\"getting-started\">\n        To get started with Side View, open a website.\n      </div>\n      <div id=\"private-warning\" style=\"display: none\">\n        <div id=\"close-private-warning-copy\">Pages sent to Side View while browsing privately may appear in your browsing history.</div>\n        <div id=\"close-private-warning\" title=\"Dismiss\">✖</div>\n      </div>\n      <div class=\"tabs-wrapper\">\n        <section class=\"tabs-section\" id=\"recent-tabs\">\n          <h2 class=\"tabs-section__title\">Recent</h2>\n          <ul id=\"recent-tabs-list\" class=\"tabs-section__list\" role=\"navigation\">\n          </ul>\n        </section>\n        <section class=\"tabs-section\" id=\"open-tabs\">\n          <div class=\"separator\"></div>\n          <h2 class=\"tabs-section__title\">Current Tabs</h2>\n          <ul id=\"open-tabs-list\" class=\"tabs-section__list\" role=\"navigation\">\n          </ul>\n        </section>\n      </div>\n      <footer class=\"panel-footer toggle-enabled\">\n        <button class=\"mobile-toggle\" title=\"Ask for Desktop Site\"><span class=\"ask-for-desktop\">Ask for Desktop Site</span><span class=\"ask-for-mobile\" style=\"display: none\">Ask for Mobile Site</span></button>\n      </footer>\n    </div>\n    <script src=\"build/buildSettings.js\"></script>\n    <script src=\"popup.js\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "addon/popup.js",
    "content": "/* globals buildSettings */\nlet isDesktop = false;\nlet recentTabs = [];\nconst rerenderEvents = [\"onUpdated\", \"onRemoved\", \"onCreated\", \"onMoved\", \"onDetached\", \"onAttached\"];\n\nasync function displayPage({url, title, favIconUrl}) {\n  // Note this must be called in response to an event, so we can't call it in background.js:\n  await browser.sidebarAction.open();\n  renderTabListLastRendered = {};\n  for (let eventName of rerenderEvents) {\n    browser.tabs[eventName].removeListener(updateHome);\n  }\n  await browser.runtime.sendMessage({\n    type: \"openUrl\",\n    url,\n    title,\n    favIconUrl,\n  });\n  window.close();\n}\n\nasync function updateHome(event) {\n  if (event) {\n    // If this is called from an event, then often browser.windows.getCurrent() won't\n    // be updated, and will return stale information, so we'll rerender a second time\n    // very soon\n    setTimeout(updateHome, 50);\n    setTimeout(updateHome, 300);\n  }\n  const windowInfo = await browser.windows.getCurrent({populate: true});\n  let tabs = windowInfo.tabs.filter(tab => tab.url.startsWith(\"http\"));\n  if (tabs.length) {\n    element(\"#open-tabs\").style.display = \"flex\";\n    renderTabList(tabs, \"#open-tabs-list\", \"existing-tab\");\n  } else {\n    element(\"#open-tabs\").style.display = \"none\";\n  }\n  if (recentTabs.length) {\n    element(\"#recent-tabs\").style.display = \"flex\";\n    renderTabList(recentTabs, \"#recent-tabs-list\", \"recent-tab\");\n  } else {\n    element(\"#recent-tabs\").style.display = \"none\";\n  }\n  if (!tabs.length && !recentTabs.length) {\n    element(\"#getting-started\").style.display = \"flex\";\n  } else {\n    element(\"#getting-started\").style.display = \"none\";\n  }\n  let onElement = element(\".ask-for-desktop\");\n  let offElement = element(\".ask-for-mobile\");\n  if (isDesktop) {\n    [ onElement, offElement ] = [ offElement, onElement ];\n  }\n  element(\".mobile-toggle\").title = onElement.textContent;\n  onElement.style.display = \"\";\n  offElement.style.display = \"none\";\n}\n\nlet renderTabListLastRendered = {};\n\nfunction _onTabClick(event, tabs, url, favIconUrl, index, title, eventLabel) {\n  displayPage({\n    url,\n    favIconUrl,\n    title,\n  });\n}\n\nfunction renderTabList(tabs, containerSelector, eventLabel) {\n  let renderedInfo = \"\";\n  const tabList = element(containerSelector);\n  const newTabList = tabList.cloneNode();\n  tabs.forEach((tab, index) => {\n    let li = document.createElement(\"li\");\n    let parent = document.createElement(\"div\");\n    let image = document.createElement(\"span\");\n    let text = document.createElement(\"span\");\n    let dismiss = document.createElement(\"button\");\n    parent.classList.add(\"tab__parent\");\n    image.classList.add(\"tab__image\");\n    text.classList.add(\"tab__text\");\n    dismiss.classList.add(\"tab__dismiss\");\n    dismiss.setAttribute(\"aria-label\", \"close button\");\n    dismiss.setAttribute(\"title\", \"Remove Tab from Recent List\");\n    let title = tab.title;\n    let url = tab.url;\n    let favIconUrl = null;\n    if (\"favIconUrl\" in tab && tab.favIconUrl) {\n      favIconUrl = tab.favIconUrl;\n      image.style.backgroundImage = `url(${favIconUrl})`;\n    }\n    renderedInfo += favIconUrl + \" \";\n    let anchor = document.createElement(\"button\");\n    renderedInfo += url + \" \";\n    anchor.classList.add(\"tab\");\n    text.textContent = title;\n    renderedInfo += title + \"\\n\";\n    anchor.addEventListener(\"click\", (event) =>\n      _onTabClick(event, tabs, url, favIconUrl, index, title, eventLabel));\n    parent.addEventListener(\"click\", (event) =>\n      _onTabClick(event, tabs, url, favIconUrl, index, title, eventLabel));\n    // Only add the dismiss button if its a recent tab\n    if (eventLabel === \"recent-tab\") {\n      dismiss.addEventListener(\"click\", async (event) => {\n      event.stopPropagation(); // prevent the selection of tab\n      await browser.runtime.sendMessage({\n        type: \"dismissTab\",\n        index,\n       });\n      });\n    }\n    anchor.prepend(image);\n    anchor.appendChild(text);\n    parent.appendChild(anchor);\n    if (eventLabel === \"recent-tab\") {\n      parent.appendChild(dismiss);\n    }\n    li.appendChild(parent);\n    newTabList.appendChild(li);\n  });\n  if (renderedInfo !== renderTabListLastRendered[containerSelector]) {\n    tabList.replaceWith(newTabList);\n    renderTabListLastRendered[containerSelector] = renderedInfo;\n  }\n}\n\nfunction element(selector) {\n  return document.querySelector(selector);\n}\n\nelement(\".mobile-toggle\").addEventListener(\"click\", async () => {\n  await browser.sidebarAction.open();\n  await browser.runtime.sendMessage({\n    type: \"toggleDesktop\",\n  });\n});\n\nelement(\"#close-private-warning\").addEventListener(\"click\", async () => {\n  await browser.runtime.sendMessage({\n    type: \"turnOffPrivateWarning\",\n  });\n  element(\"#private-warning\").style.display = \"none\";\n});\n\nfunction loadCachedRecentTabs() {\n  let value = localStorage.getItem(\"recentTabs\") || \"[]\";\n  value = JSON.parse(value);\n  return value;\n}\n\nfunction cacheRecentTabs(value) {\n  localStorage.setItem(\"recentTabs\", JSON.stringify(value));\n}\n\nfunction applyDarkTheme() {\n  document.body.style.background = \"#4a4a4f\";\n  document.body.style.color = \"#fff\";\n  document.querySelector(\"#panel\").classList.add(\"dark-theme\");\n}\n\nasync function checkForDark() {\n  browser.management.getAll().then((extensions) => {\n    for (let extension of extensions) {\n    // The user has the default dark theme enabled\n    if (extension.id ===\n      \"firefox-compact-dark@mozilla.org@personas.mozilla.org\"\n      && extension.enabled) {\n        applyDarkTheme();\n      }\n    }\n  });\n}\n\nasync function init() {\n  document.addEventListener(\"contextmenu\", event => event.preventDefault());\n\n  browser.runtime.onMessage.addListener((message) => {\n    if (message.type === \"updateRecentTabs\") {\n      recentTabs = message.recentTabs;\n      updateHome();\n      cacheRecentTabs(recentTabs);\n    } else if (message.type === \"isDesktop\") {\n      isDesktop = message.isDesktop;\n      updateHome();\n    } else if ([\"setDesktop\", \"sidebarOpenedPage\", \"sidebarDisplayedHome\", \"getRecentTabs\"].includes(message.type)) {\n      // These intended to go to the backgrond and can be ignored here\n    } else {\n      console.error(\"Got unexpected message:\", message);\n    }\n  });\n\n  recentTabs = loadCachedRecentTabs();\n  updateHome();\n\n  let info = await browser.runtime.sendMessage({\n    type: \"getRecentAndDesktop\",\n  });\n  recentTabs = info.recentTabs;\n  isDesktop = info.isDesktop;\n  if (info.incognito && !info.hasSeenPrivateWarning) {\n    element(\"#private-warning\").style.display = \"\";\n  }\n  updateHome();\n\n  // Listen for tab changes to update while popup is still open\n  for (let eventName of rerenderEvents) {\n    browser.tabs[eventName].addListener(updateHome);\n  }\n  checkForDark();\n}\n\ninit();\n"
  },
  {
    "path": "addon/sidebar.css",
    "content": "body,\nhtml {\n  font: message-box;\n  font-size: 15px;\n  overflow: hidden;\n  color: rgb(12, 12, 13);\n}\n\n:root {\n  --dark-theme-background-color: #4a4a4f;\n  --dark-theme-highlight-color: #6d6d6f;\n  --dark-theme-color: #fff;\n  --dark-theme-links: #45a1ff;\n}\n\n* {\n  box-sizing: border-box;\n  text-align: center;\n}\n\nbody {\n  margin: 0;\n}\n\n#home-panel {\n  display: none;\n}\n\n.page {\n  background: #f9f9fa;\n  min-height: 100vh;\n  padding: 40px 28px;\n}\n\n.title {\n  font-size: 1.46em;\n  font-weight: 300;\n  line-height: 1.3em;\n  margin: 0;\n}\n\n.subtitle {\n  font-size: 1em;\n  font-weight: 400;\n  margin: 6px 0 24px;\n}\n\n.subtitle a {\n  color: rgb(12, 12, 13);\n}\n\n.instructions {\n  list-style: none;\n  margin: 0;\n  padding: 0;\n}\n\n#landing-panel {\n  align-items: center;\n  display: flex;\n  flex-direction: column;\n  justify-content: center;\n}\n\n.graphic {\n  align-items: center;\n  display: flex;\n  flex-direction: column;\n  margin-bottom: 16px;\n  width: 71vw;\n  max-width: 284px;\n  height: 52vw;\n  max-height: 206px;\n}\n\n.graphic__overlay {\n  position: relative;\n  max-width: 284px;\n  width: 100%;\n  height: 61vw;\n  max-height: 174px;\n  margin-bottom: 9.2%;\n}\n\n.graphic__clouds {\n  max-width: 284px;\n  width: 100%;\n  max-height: 174px;\n  height: 100%;\n  background: url(images/in-content-clouds.png) no-repeat center;\n  background-size: contain;\n  position: absolute;\n}\n\n.graphic__browser {\n  animation: fade-in-down forwards 1000ms cubic-bezier(0.22, 0.92, 0.62, 1);\n  animation-delay: 100ms;\n  background: url(images/in-content-icon.png) no-repeat center;\n  background-size: contain;\n  max-width: 284px;\n  width: 100%;\n  height: 100%;\n  opacity: 0;\n  position: absolute;\n  transform: translate3d(0, -72px, 0);\n}\n\n.graphic__shadow {\n  animation: fade-in-scale forwards 1000ms cubic-bezier(0.22, 0.92, 0.62, 1);\n  animation-delay: 250ms;\n  max-width: 170px;\n  width: 61.2%;\n  height: 16px;\n  border-radius: 50%;\n  background: #ededf0;\n  opacity: 0;\n  transform: scale(1.3);\n}\n\n@keyframes fade-in-down {\n  0% {\n    opacity: 0;\n    transform: translate3d(0, -72px, 0);\n  }\n\n  100% {\n    opacity: 1;\n    transform: translate3d(0, 0, 0);\n  }\n}\n\n@keyframes fade-in-scale {\n  0% {\n    opacity: 0;\n    transform: scale(1.3);\n  }\n\n  100% {\n    opacity: 1;\n    transform: scale(1);\n  }\n}\n\n.default-link {\n  appearance: none;\n  background-color: rgba(0, 0, 0, 0);\n  border: 0;\n  color: rgb(10, 141, 255);\n  cursor: pointer;\n  font-size: 15px;\n  margin: 6px 0;\n  padding: 0;\n  text-decoration: none;\n  transition: color 100ms;\n}\n\n.subtitle .default-link {\n  margin: 0;\n  padding: 0;\n}\n\n.default-link:hover,\n.default-link:focus {\n  color: rgb(0, 96, 223);\n  text-decoration: underline;\n}\n\n/* Dark theme */\n\n.page.dark-theme {\n  color: var(--dark-theme-color);\n  background: var(--dark-theme-background-color);\n}\n\n.page.dark-theme button:hover,\n.page.dark-theme button:focus,\n.page.dark-theme .graphic__shadow {\n  background: var(--dark-theme-highlight-color);\n  background-color: transparent;\n}\n\n.page.dark-theme .default-link,\n.page.dark-theme .default-link:hover,\n.page.dark-theme .default-link:focus {\n  color: var(--dark-theme-links);\n}\n\n.page.dark-theme .graphic__clouds {\n  background: url(images/in-content-clouds-dark.png);\n}\n"
  },
  {
    "path": "addon/sidebar.html",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"UTF-8\">\n    <title>Sidebar</title>\n    <link rel=\"stylesheet\" href=\"sidebar.css\"/>\n  </head>\n  <body>\n    <div class=\"page\" id=\"landing-panel\">\n      <div class=\"graphic\">\n        <div class=\"graphic__overlay\">\n          <div class=\"graphic__clouds\"></div>\n          <div class=graphic__browser></div>\n        </div>\n        <div class=\"graphic__shadow\"></div>\n      </div>\n      <h1 class=\"title\">Welcome to Side View</h1>\n\n      <p>\n        <a href=\"https://youtu.be/no6D_B4wgo8\" id=\"watch-tutorial\">Watch a tutorial</a>\n      </p>\n    </div>\n\n    <script src=\"build/buildSettings.js\"></script>\n    <script src=\"sidebar.js\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "addon/sidebar.js",
    "content": "/* globals buildSettings */\n\nfunction element(selector) {\n  return document.querySelector(selector);\n}\n\nfunction applyDarkTheme() {\n  document.querySelector(\".page\").classList.add(\"dark-theme\");\n}\n\nasync function checkForDark() {\n  browser.management.getAll().then((extensions) => {\n    for (let extension of extensions) {\n    // The user has the default dark theme enabled\n    if (extension.id ===\n      \"firefox-compact-dark@mozilla.org@personas.mozilla.org\"\n      && extension.enabled) {\n        applyDarkTheme();\n      }\n    }\n  });\n}\n\nasync function init() {\n  element(\"#watch-tutorial\").onclick = () => {\n    window.open(\"https://youtu.be/no6D_B4wgo8\");\n  };\n\n  checkForDark();\n  browser.management.onEnabled.addListener((info) => {\n    checkForDark();\n  });\n}\n\ninit();\n"
  },
  {
    "path": "docs/release.md",
    "content": "# Release Process\n\n## addons.mozilla.org\n\nTo build for AMO:\n\n```sh\nnpm run package\n# XPI is in ./addon-amo.xpi\n```\n\nThen upload manually via the [web interface](https://addons.mozilla.org/en-US/developers/addon/side-view/edit) (TODO: use web-ext to further automate the release).\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"side-view\",\n  \"description\": \"Open a mobile view of a page in the sidebar\",\n  \"version\": \"0.6.0\",\n  \"author\": \"Mozilla (https://mozilla.org/)\",\n  \"bugs\": {\n    \"url\": \"https://github.com/mozilla/side-view/issues\"\n  },\n  \"devDependencies\": {\n    \"addons-linter\": \"^7.3.0\",\n    \"eslint\": \"^5.5.0\",\n    \"eslint-plugin-mozilla\": \"^0.15.4\",\n    \"eslint-plugin-no-unsanitized\": \"^3.0.2\",\n    \"mustache\": \"^2.3.2\",\n    \"npm-run-all\": \"4.1.5\",\n    \"stylelint\": \"^9.5.0\",\n    \"stylelint-config-standard\": \"^18.2.0\",\n    \"web-ext\": \"^2.9.1\"\n  },\n  \"homepage\": \"https://github.com/mozilla/side-view/\",\n  \"license\": \"MPL-2.0\",\n  \"private\": true,\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/mozilla/side-view.git\"\n  },\n  \"scripts\": {\n    \"start\": \"npm-run-all build run\",\n    \"lint\": \"npm-run-all lint:*\",\n    \"lint:addon\": \"npm run package && addons-linter ./addon.xpi -o text --self-hosted\",\n    \"lint:js\": \"eslint .\",\n    \"lint:styles\": \"stylelint ./addon/*.css\",\n    \"build\": \"npm-run-all build:*\",\n    \"build:manifest\": \"node -e 'let input = JSON.parse(fs.readFileSync(\\\"package.json\\\")); input.version = input.version.slice(0, -1) + Math.floor((Date.now() - new Date(new Date().getFullYear().toString()).getTime()) / 3600000); Object.assign(input, process.env); console.log(JSON.stringify(input))' | mustache - addon/manifest.json.tmpl > addon/manifest.json\",\n    \"build:buildSettings\": \"mkdir -p addon/build/ && node -e 'console.log(JSON.stringify(process.env))' | mustache - addon/buildSettings.js.tmpl > addon/build/buildSettings.js\",\n    \"build:web-ext\": \"web-ext build --source-dir=addon --overwrite-dest --ignore-files '*.tmpl'\",\n    \"package\": \"npm run build && cp web-ext-artifacts/`ls -t1 web-ext-artifacts | head -n 1` addon.xpi\",\n    \"run\": \"mkdir -p ./Profile && web-ext run --source-dir=addon -p ./Profile --browser-console --keep-profile-changes -f nightly\",\n    \"test\": \"npm run lint\"\n  }\n}\n"
  }
]