Full Code of mozilla/side-view for AI

master 433e591750ec cached
22 files
52.8 KB
14.0k tokens
28 symbols
1 requests
Download .txt
Repository: mozilla/side-view
Branch: master
Commit: 433e591750ec
Files: 22
Total size: 52.8 KB

Directory structure:
gitextract_84i6seak/

├── .circleci/
│   └── config.yml
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .stylelintrc
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── addon/
│   ├── background.js
│   ├── buildSettings.js.tmpl
│   ├── intro.css
│   ├── intro.html
│   ├── intro.js
│   ├── manifest.json.tmpl
│   ├── popup.css
│   ├── popup.html
│   ├── popup.js
│   ├── sidebar.css
│   ├── sidebar.html
│   └── sidebar.js
├── docs/
│   └── release.md
└── package.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .circleci/config.yml
================================================
version: 2.0
jobs:
    package:
        docker:
            - image: circleci/node:8.9.4
        steps:
            - checkout
            - restore_cache:
                keys:
                    - node-modules-
            - run:
                name: install
                command: npm install
            - run:
                name: package
                command: npm run package
            - run:
                name: test
                command: npm test
            - save_cache:
                key: node-modules-
                paths:
                    - node_modules
            - store_artifacts:
                path: addon.xpi
            - persist_to_workspace:
                root: .
                paths:
                    - ./*
workflows:
    version: 2
    package:
        jobs:
            - package



================================================
FILE: .eslintignore
================================================
addon/build
Profile
web-ext-artifacts


================================================
FILE: .eslintrc.js
================================================
module.exports = {
  "env": {
    "es6": true,
    "webextensions": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:mozilla/recommended"
  ],
  "parserOptions": {
    "ecmaVersion": 8,
    "sourceType": "module"
  },
  "plugins": [
    "mozilla"
  ],
  "root": true,
  "rules": {
    "eqeqeq": "error",
    "no-console": "warn",
    "space-before-function-paren": "off",
    "no-console": ["error", {"allow": ["error", "info", "trace", "warn"]}]
  }
};


================================================
FILE: .gitignore
================================================
node_modules
web-ext-artifacts
addon*.xpi
addon/build
addon/manifest.json
/addon/experiment/study
/null-addon/addon/experiment
.DS_Store
/Profile


================================================
FILE: .stylelintrc
================================================
{
  "extends": "stylelint-config-standard",
  "rules": {
    "font-family-no-missing-generic-family-keyword": null
  }
}

================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Community Participation Guidelines

This repository is governed by Mozilla's code of conduct and etiquette guidelines. 
For more details, please read the
[Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/). 

## How to Report
For 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.

<!--
## Project Specific Etiquette

In some cases, there will be additional project etiquette i.e.: (https://bugzilla.mozilla.org/page.cgi?id=etiquette.html).
Please update for your project.
-->


================================================
FILE: LICENSE
================================================
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.


================================================
FILE: README.md
================================================
# Side View

An experiment with opening mobile views of pages in the sidebar.

[**Install from addons.mozilla.org**](https://addons.mozilla.org/en-US/firefox/addon/side-view/)

## Installing

Use `npm install`, then `npm start`.

## Installing manually

Check out the repository. Go to `about:debugging` in Firefox, and select **Load Temporary Add-on**. Select a file in the `addon/` directory.

Or: 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`

## Using

This 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.

## Credits

[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.


================================================
FILE: addon/background.js
================================================
const FIREFOX_VERSION = /rv:([0-9.]+)/.exec(navigator.userAgent)[1];

const USER_AGENT = `Mozilla/5.0 (Android 14; Mobile; rv:${FIREFOX_VERSION}) Gecko/${FIREFOX_VERSION} Firefox/${FIREFOX_VERSION}`;
// iOS:
//   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
// Firefox for Android:
//   Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0
// Chrome for Android:
//   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

// If you update DEFAULT_DESKTOP_SITES you should also increment DEFAULT_DESKTOP_VERSION
const DEFAULT_DESKTOP_SITES = [
  "www.youtube.com",
  "www.metacafe.com",
  "myspace.com",
  "imgur.com",
  "meet.google.com",
  "meet.app.goo.gl",
];

const DEFAULT_DESKTOP_VERSION = 2;

const MAX_RECENT_TABS = 5;
let sidebarUrl;
let hasSeenPrivateWarning = false;

browser.contextMenus.create({
  id: "open-in-sidebar",
  title: "Open in Side View",
  contexts: ["page", "tab", "bookmark"],
  documentUrlPatterns: ["<all_urls>"],
});

browser.contextMenus.create({
  id: "open-link-in-sidebar",
  title: "Open link in Side View",
  // FIXME: could add "bookmark", but have to fetch by info.bookmarkId
  contexts: ["link"],
  documentUrlPatterns: ["<all_urls>"],
});

browser.contextMenus.onClicked.addListener(async (info, tab) => {
  let url;
  let favIconUrl;
  let title;
  let incognito = tab && tab.incognito;
  await browser.sidebarAction.open();
  if (info.linkUrl) {
    url = info.linkUrl;
  } else if (info.bookmarkId) {
    let bookmarkInfo = await browser.bookmarks.get(info.bookmarkId);
    url = bookmarkInfo[0].url;
  } else {
    url = tab.url;
    title = tab.title;
    favIconUrl = tab.favIconUrl;
  }
  if (title && !incognito) {
    // In cases when we can't get a good title and favicon, we just don't bother saving it as a recent tab
    addRecentTab({url, favIconUrl, title});
  }
  openUrl(url);
});

browser.pageAction.onClicked.addListener((async (tab) => {
  let url = tab.url;
  if (!tab.incognito) {
    addRecentTab({url, favIconUrl: tab.favIconUrl, title: tab.title});
  }
  await browser.sidebarAction.open();
  openUrl(url);
}));

async function openUrl(url) {
  sidebarUrl = url;
  let hostname = (new URL(url)).hostname;
  let isDesktop = !!desktopHostnames[hostname];
  browser.runtime.sendMessage({
    type: "isDesktop",
    isDesktop,
  }).catch((error) => {
    // If the popup is not open this gives an error, but we don't care
  });
  browser.sidebarAction.setPanel({panel: url});
}

/* eslint-disable consistent-return */
// Because this dispatches to different kinds of functions, its return behavior is inconsistent
browser.runtime.onMessage.addListener(async (message) => {
  if (message.type === "toggleDesktop") {
    toggleDesktop();
  } else if (message.type === "openUrl") {
    openUrl(message.url);
    let windowInfo = await browser.windows.getCurrent();
    if (!windowInfo.incognito) {
      addRecentTab(message);
    }
  } else if (message.type === "dismissTab") {
    dismissRecentTab(message.index);
  } else if (message.type === "getRecentAndDesktop") {
    let isDesktop = false;
    if (sidebarUrl) {
      let hostname = (new URL(sidebarUrl)).hostname;
      isDesktop = !!desktopHostnames[hostname];
    }
    let currentWindow = await browser.windows.getCurrent();
    return Promise.resolve({
      recentTabs,
      isDesktop,
      hasSeenPrivateWarning,
      incognito: currentWindow.incognito,
    });
  } else if (message.type === "turnOffPrivateWarning") {
    turnOffPrivateWarning();
  } else {
    console.error("Unexpected message to background:", message);
  }
});
/* eslint-enable consistent-return */

// This is a RequestFilter: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/webRequest/RequestFilter
// It matches tabs that aren't attached to a normal location (like a sidebar)
// It only matches embedded iframes
let requestFilter = {
  tabId: -1,
  types: ["main_frame"],
  urls: ["http://*/*", "https://*/*"],
};

let desktopHostnames = {};

async function toggleDesktop() {
  if (!sidebarUrl) {
    console.warn("Got toggle desktop with no known sidebar URL");
    return;
  }
  let hostname = (new URL(sidebarUrl)).hostname;
  let isDesktop = !desktopHostnames[hostname];
  if (isDesktop) {
    desktopHostnames[hostname] = true;
  } else {
    delete desktopHostnames[hostname];
  }
  // We can't trigger a real reload without changing the URL, so we change it to blank and then
  // back to the previous URL:
  browser.sidebarAction.setPanel({panel: "about:blank"});
  openUrl(sidebarUrl);
  await browser.storage.local.set({desktopHostnames, defaultDesktopVersion: DEFAULT_DESKTOP_VERSION});
}

let recentTabs = [];

async function addRecentTab(tabInfo) {
  recentTabs = recentTabs.filter((item) => item.url !== tabInfo.url);
  recentTabs.unshift(tabInfo);
  recentTabs.splice(MAX_RECENT_TABS);
  try {
    await browser.runtime.sendMessage({
      type: "updateRecentTabs",
      recentTabs,
    });
  } catch (error) {
    if (String(error).includes("Could not establish connection")) {
      // We're just speculatively sending messages to the popup, it might not be open,
      // and that is fine
    } else {
      console.error("Got updating recent tabs:", String(error), error);
    }
  }
  await browser.storage.local.set({recentTabs});
}

async function dismissRecentTab(tab_index) {
  recentTabs.splice(tab_index, 1);
  try {
    await browser.runtime.sendMessage({
      type: "updateRecentTabs",
      recentTabs,
    });

  } catch (error) {
    if (String(error).includes("Could not establish connection")) {
      // popup speculation, as in addRecentTab()
    } else {
      console.error("Got updating recent tabs:", String(error), error);
    }
  }
  await browser.storage.local.set({recentTabs});
}

// Add a mobile header to outgoing requests
browser.webRequest.onBeforeSendHeaders.addListener(function (info) {
  let hostname = (new URL(info.url)).hostname;
  if (desktopHostnames[hostname]) {
    return {};
  }
  let headers = info.requestHeaders;
  for (let i = 0; i < headers.length; i++) {
    let name = headers[i].name.toLowerCase();
    if (name === "user-agent") {
      headers[i].value = USER_AGENT;
      return {"requestHeaders": headers};
    }
  }
  return {};
}, requestFilter, ["blocking", "requestHeaders"]);

function privateWarningOnUpdated(tabId, changeInfo, tab) {
  if (tab.incognito) {
    browser.browserAction.setBadgeText({text: "!", tabId: tab.id});
  }
}

async function turnOffPrivateWarning() {
  hasSeenPrivateWarning = true;
  browser.tabs.onUpdated.removeListener(privateWarningOnUpdated);
  let win = await browser.windows.getCurrent({populate: true});
  for (let tab of win.tabs) {
    browser.browserAction.setBadgeText({text: null, tabId: tab.id});
  }
  await browser.storage.local.set({hasSeenPrivateWarning});
}

function showOnboardingBadge() {
  browser.browserAction.setIcon({path: "side-view-onboarding.svg"});
  function onBrowserActionClick() {
    browser.browserAction.setPopup({popup: "intro.html"});
    browser.browserAction.openPopup();
    browser.browserAction.onClicked.removeListener(onBrowserActionClick);
    browser.browserAction.setIcon({path: "side-view.svg"});
    browser.storage.local.set({hasBeenOnboarded: true});
    browser.browserAction.setPopup({popup: "popup.html"});
  }
  // This disables the default popup action and lets us intercept the clicks:
  browser.browserAction.setPopup({popup: ""});
  browser.browserAction.onClicked.addListener(onBrowserActionClick);
}

async function init() {
  const result = await browser.storage.local.get(["desktopHostnames", "defaultDesktopVersion", "recentTabs", "hasSeenPrivateWarning", "hasBeenOnboarded"]);
  if (!result.desktopHostnames) {
    desktopHostnames = {};
  } else {
    desktopHostnames = result.desktopHostnames;
  }
  if (!result.defaultDesktopVersion || result.defaultDesktopVersion < DEFAULT_DESKTOP_VERSION) {
    for (let hostname of DEFAULT_DESKTOP_SITES) {
      desktopHostnames[hostname] = true;
    }
  }
  recentTabs = result.recentTabs || [];
  hasSeenPrivateWarning = result.hasSeenPrivateWarning;
  if (!hasSeenPrivateWarning) {
    browser.tabs.onUpdated.addListener(privateWarningOnUpdated);
  }
  if (!result.hasBeenOnboarded) {
    showOnboardingBadge();
  }
}

init();


================================================
FILE: addon/buildSettings.js.tmpl
================================================
var buildSettings = {
  NODE_ENV: "{{NODE_ENV}}",
};


================================================
FILE: addon/intro.css
================================================
:root {
  --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;
}

#container {
  display: flex;
  flex-direction: column;
  width: 100%;
  font: message-box;
  font-size: 16px;
}

.slide {
  width: 480px;
  flex-direction: column;
  align-items: center;
}

.slide-image {
  width: 480px;
  flex: 0 0 270px;
  border-bottom: 1px solid #ddd;
}

.slide p {
  line-height: 1.5em;
  margin: 0;
  padding: 0 32px;
  text-align: center;
  height: 84px;
  display: flex;
  align-items: center;
  color: black;
  background: white;
}

.slide-displayed {
  display: flex;
}

.slide-hidden {
  display: none;
}

#slide-controls {
  align-items: center;
  padding: 0 16px 16px;
  display: grid;
  grid-template-columns: 120px 1fr 120px;
  justify-content: center;
}

button {
  align-items: center;
  background: #f2f2f2;
  border-radius: 2px;
  border: 0;
  display: flex;
  font-size: 14px;
  height: 32px;
  justify-content: center;
  padding: 5px;
  flex: 1;
}

.button-hidden {
  display: none;
}

.button-invisible {
  visibility: hidden;
}

#next,
#done {
  grid-column: 3 / -1;
}

.button-primary {
  background: var(--blue-50);
  color: white;
}

.button-primary:hover,
.button-primary:focus {
  background: var(--blue-60);
}

.button-primary:active {
  background: var(--blue-70);
}


================================================
FILE: addon/intro.html
================================================
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="popup.css">
    <link rel="stylesheet" href="intro.css">
  </head>
  <body>
    <div id="container">
      <div id="slide-container">
        <!-- Slides go in here. If you add a slide, add a button in the controls as well -->
        <div class="slide slide-displayed" id="slide-0">
          <img class="slide-image" src="images/side-view-tour-1.jpg" alt=""/>
          <p>Introducing Side View,<br/> a new way to multitask with Firefox.</p>
        </div>
        <div class="slide slide-hidden" id="slide-1">
          <img class="slide-image" src="images/side-view-tour-2.jpg" alt="" />
          <p>Side View lets you send websites to your Firefox sidebar.</p>
        </div>
        <div class="slide slide-hidden" id="slide-2">
          <img class="slide-image" src="images/side-view-tour-3.jpg" alt="" />
          <p>By default, Side View displays mobile sites to keep everything looking good in a narrow window.</p>
        </div>
        <div class="slide slide-hidden" id="slide-3">
          <img class="slide-image"
          src="images/side-view-tour-4.jpg" alt="" />
          <p>You can also right click to open links in Side View.</p>
        </div>
      </div>

      <div id="slide-controls">
        <button id="previous" class="button-invisible button-secondary">Previous</button>
        <button id="next" class="button-primary">Next</button>
        <button id="done" class="button-hidden button-primary">Done</button>
      </div>

    </div>
    <script src="intro.js"></script>
  </body>
</html>


================================================
FILE: addon/intro.js
================================================
let foundSlides = 0;
let currentSlide = 0;

function selectSlide(num) {
  for (let i = 0; i < foundSlides; i++) {
    let el = document.querySelector(`#slide-${i}`);
    if (i === num) {
      el.classList.add("slide-displayed");
      el.classList.remove("slide-hidden");
    } else {
      el.classList.remove("slide-displayed");
      el.classList.add("slide-hidden");
    }
  }
  previous.disabled = num === 0;
  next.disabled = num === foundSlides - 1;
}

for (let el of document.querySelectorAll(".slide")) {
  let num = parseInt(el.id.replace(/[^\d]/g, ""), 10);
  foundSlides = Math.max(foundSlides + 1, num);
}

let previous = document.querySelector("#previous");
let next = document.querySelector("#next");
let done = document.querySelector("#done");

previous.addEventListener("click", () => {
  currentSlide = Math.max(0, currentSlide - 1);
  if (currentSlide === 0) {
    previous.classList.add("button-invisible");
  }
  if (currentSlide === foundSlides - 2) {
    next.classList.remove("button-hidden");
    done.classList.add("button-hidden");
  }
  selectSlide(currentSlide);
});

next.addEventListener("click", () => {
  currentSlide = Math.min(foundSlides - 1, currentSlide + 1);
  if (currentSlide === 1) {
    previous.classList.remove("button-invisible");
  }
  if (currentSlide === foundSlides - 1) {
    next.classList.add("button-hidden");
    done.classList.remove("button-hidden");
  }
  selectSlide(currentSlide);
});

done.addEventListener("click", () => {
  location.href = "popup.html";
});

selectSlide(currentSlide);


================================================
FILE: addon/manifest.json.tmpl
================================================
{
    "manifest_version": 2,
    "name": "Side View",
    "version": "{{version}}",
    "description": "{{description}}",
    "icons": {
      "48": "side-view.png",
      "96": "side-view.png"
    },
    "author": "{{{author}}}",
    "homepage_url": "{{{homepage}}}",
    "browser_specific_settings": {
      "gecko": {
        "id": "side-view@mozilla.org",
        "strict_min_version": "62.0"
      }
    },
    "background": {
      "scripts": [
        "build/buildSettings.js",
        "background.js"
      ]
    },
    "browser_action": {
      "default_icon": "side-view.svg",
      "default_popup": "popup.html",
      "default_title": "Open Side View",
      "browser_style": true
    },
    "sidebar_action": {
      "default_icon": "side-view.svg",
      "default_title": "Side View",
      "default_panel": "sidebar.html",
      "browser_style": false
    },
    "page_action": {
      "default_icon": "side-view.svg",
      "default_title": "Open Side View",
      "show_matches": ["http://*/*", "https://*/*"],
      "browser_style": true
    },
    "web_accessible_resources": [
    ],
    "permissions": [
      "activeTab",
      "tabs",
      "<all_urls>",
      "storage",
      "contextMenus",
      "webRequest",
      "webRequestBlocking",
      "bookmarks",
      "management"
    ]
  }


================================================
FILE: addon/popup.css
================================================
body,
html {
  font: message-box;
  overflow: hidden;
}

:root {
  --dark-theme-background-color: #4a4a4f;
  --dark-theme-highlight-color: #6d6d6f;
  --dark-theme-superhighlight-color: hsla(0, 0%, 80%, 0.45);
  --dark-theme-color: #fff;
  --dark-theme-links: #45a1ff;
}

* {
  box-sizing: border-box;
}

body {
  height: 100%;
  margin: 0;
  min-width: 320px;
  overflow: hidden !important;
}

#panel {
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  max-width: 440px;
  min-width: 320px;
  width: 100%;
}

#panel,
.tabs-section__title,
.tab {
  font: menu;
}

.separator {
  background: hsla(210, 4%, 10%, 0.14);
  height: 1px;
  margin: 6px 0;
}

.tabs-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tabs-section {
  display: flex;
  flex-direction: column;
  max-height: 300px;
  flex: 1 1;
}

.tabs-section__title {
  align-items: center;
  color: GrayText;
  display: flex;
  font-weight: normal;
  height: 24px;
  margin: 0;
  padding: 4px 12px;
}

.tabs-section:first-child .tabs-section__title {
  margin-top: 6px;
}

.tabs-section__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#open-tabs-list {
  flex: 1;
  overflow-y: auto;
}

.tab__parent {
  display: flex;
  width: 100%;
  background: #fff;
  height: 26.5px;
}

.tab {
  align-items: center;
  border: 0;
  width: 100%;
  background: transparent;
  font-weight: normal;
  padding-inline-start: 18px;
  padding: 4px 12px;
  display: flex;
  overflow: hidden;
}

.tab__parent:hover,
.tab__parent:focus {
  background: #ededf0;
}

.tab__image,
.tab__text {
  pointer-events: none;
}

.tab__image {
  background-size: 16px 16px;
  flex: 0 0 16px;
  height: 16px;
  margin-inline-end: 8px;
}

.tab__dismiss {
  border: 0;
  background: transparent;
  margin-top: 3.25px;
  margin-left: auto;
  margin-right: 10px;
  border-radius: 10%;
  opacity: 0;
  height: 20px;
  padding: 2px;
}

.tab__dismiss:hover,
.tab__dismiss:focus {
  background: rgba(224, 224, 225, 0.9);
}

.tab__dismiss:hover,
.tab__dismiss:focus,
.tab:hover + .tab__dismiss,
.tab:focus + .tab__dismiss,
.tab__parent:hover .tab__dismiss,
.tab__parent:focus .tab__dismiss {
  opacity: 100;
}

.tab__dismiss::after {
  content: url(images/close-16.svg);  /* close symbol */
}

/* this is a hack if, for any reason, a site does not
supply a favicon */

.tab__image[style*=undefined] {
  background-image: url(images/globe.svg) !important;
}

.tab__text {
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-footer {
  border-top: 1px solid hsla(210, 4%, 10%, 0.14);
  display: flex;
  flex: 0 0 41px;
  margin: 6px 0 0;
}

.panel-footer.toggle-disabled {
  grid-template-columns: 1fr;
}

.mobile-toggle {
  border: 0;
  align-items: center;
  background: hsla(0, 0%, 80%, 0.3);
  color: rgb(26, 26, 26);
  cursor: default;
  display: flex;
  flex: 1;
  font: menu;
  justify-content: center;
  margin-bottom: 0;
  padding: 12px 4px;
  text-decoration: none;
}

.toggle-disabled .mobile-toggle {
  display: none;
}

.mobile-toggle:hover {
  background: hsla(0, 0%, 80%, 0.4);
}

#getting-started {
  display: none;
  padding: 1em;
}

#private-warning {
  background: #ededf0;
  border-bottom: 1px dashed #d70022;
  color: #d70022;
  display: flex;
}

#close-private-warning-copy {
  padding: 12px 0 12px 12px;
}

#close-private-warning {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex: 0 0 24px;
  height: 24px;
  justify-content: center;
}

/* Dark theme */

#panel.dark-theme,
#panel.dark-theme .tab,
#panel.dark-theme .tab__parent,
#panel.dark-theme .tab__dismiss {
  background-color: var(--dark-theme-background-color);
  color: var(--dark-theme-color);
}

#panel.dark-theme .tab__parent:hover,
#panel.dark-theme .tab__parent:focus,
#panel.dark-theme .tab__parent:hover > *,
#panel.dark-theme .tab__parent:focus > *,
#panel.dark-theme .separator {
  background-color: var(--dark-theme-highlight-color);
}

#panel.dark-theme .tab__dismiss:hover,
#panel.dark-theme .tab__dismiss:focus {
  background-color: var(--dark-theme-background-color);
}

#panel.dark-theme .tab__dismiss::after {
  content: url(images/close-16-light.svg);
}

#panel.dark-theme .mobile-toggle {
  background-color: var(--dark-theme-superhighlight-color);
  color: var(--dark-theme-color);
}

#panel.dark-theme .mobile-toggle:hover {
  background-color: hsla(0, 0%, 80%, 0.6);
}

#recent-tabs[style$="none;"] + #open-tabs {
  margin-top: 6px;
}

#recent-tabs[style$="none;"] + #open-tabs .separator {
  display: none !important;
}


================================================
FILE: addon/popup.html
================================================
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Popup</title>
    <link rel="stylesheet" href="popup.css"/>
  </head>
  <body>
    <div id="panel">
      <div id="getting-started">
        To get started with Side View, open a website.
      </div>
      <div id="private-warning" style="display: none">
        <div id="close-private-warning-copy">Pages sent to Side View while browsing privately may appear in your browsing history.</div>
        <div id="close-private-warning" title="Dismiss">✖</div>
      </div>
      <div class="tabs-wrapper">
        <section class="tabs-section" id="recent-tabs">
          <h2 class="tabs-section__title">Recent</h2>
          <ul id="recent-tabs-list" class="tabs-section__list" role="navigation">
          </ul>
        </section>
        <section class="tabs-section" id="open-tabs">
          <div class="separator"></div>
          <h2 class="tabs-section__title">Current Tabs</h2>
          <ul id="open-tabs-list" class="tabs-section__list" role="navigation">
          </ul>
        </section>
      </div>
      <footer class="panel-footer toggle-enabled">
        <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>
      </footer>
    </div>
    <script src="build/buildSettings.js"></script>
    <script src="popup.js"></script>
  </body>
</html>


================================================
FILE: addon/popup.js
================================================
/* globals buildSettings */
let isDesktop = false;
let recentTabs = [];
const rerenderEvents = ["onUpdated", "onRemoved", "onCreated", "onMoved", "onDetached", "onAttached"];

async function displayPage({url, title, favIconUrl}) {
  // Note this must be called in response to an event, so we can't call it in background.js:
  await browser.sidebarAction.open();
  renderTabListLastRendered = {};
  for (let eventName of rerenderEvents) {
    browser.tabs[eventName].removeListener(updateHome);
  }
  await browser.runtime.sendMessage({
    type: "openUrl",
    url,
    title,
    favIconUrl,
  });
  window.close();
}

async function updateHome(event) {
  if (event) {
    // If this is called from an event, then often browser.windows.getCurrent() won't
    // be updated, and will return stale information, so we'll rerender a second time
    // very soon
    setTimeout(updateHome, 50);
    setTimeout(updateHome, 300);
  }
  const windowInfo = await browser.windows.getCurrent({populate: true});
  let tabs = windowInfo.tabs.filter(tab => tab.url.startsWith("http"));
  if (tabs.length) {
    element("#open-tabs").style.display = "flex";
    renderTabList(tabs, "#open-tabs-list", "existing-tab");
  } else {
    element("#open-tabs").style.display = "none";
  }
  if (recentTabs.length) {
    element("#recent-tabs").style.display = "flex";
    renderTabList(recentTabs, "#recent-tabs-list", "recent-tab");
  } else {
    element("#recent-tabs").style.display = "none";
  }
  if (!tabs.length && !recentTabs.length) {
    element("#getting-started").style.display = "flex";
  } else {
    element("#getting-started").style.display = "none";
  }
  let onElement = element(".ask-for-desktop");
  let offElement = element(".ask-for-mobile");
  if (isDesktop) {
    [ onElement, offElement ] = [ offElement, onElement ];
  }
  element(".mobile-toggle").title = onElement.textContent;
  onElement.style.display = "";
  offElement.style.display = "none";
}

let renderTabListLastRendered = {};

function _onTabClick(event, tabs, url, favIconUrl, index, title, eventLabel) {
  displayPage({
    url,
    favIconUrl,
    title,
  });
}

function renderTabList(tabs, containerSelector, eventLabel) {
  let renderedInfo = "";
  const tabList = element(containerSelector);
  const newTabList = tabList.cloneNode();
  tabs.forEach((tab, index) => {
    let li = document.createElement("li");
    let parent = document.createElement("div");
    let image = document.createElement("span");
    let text = document.createElement("span");
    let dismiss = document.createElement("button");
    parent.classList.add("tab__parent");
    image.classList.add("tab__image");
    text.classList.add("tab__text");
    dismiss.classList.add("tab__dismiss");
    dismiss.setAttribute("aria-label", "close button");
    dismiss.setAttribute("title", "Remove Tab from Recent List");
    let title = tab.title;
    let url = tab.url;
    let favIconUrl = null;
    if ("favIconUrl" in tab && tab.favIconUrl) {
      favIconUrl = tab.favIconUrl;
      image.style.backgroundImage = `url(${favIconUrl})`;
    }
    renderedInfo += favIconUrl + " ";
    let anchor = document.createElement("button");
    renderedInfo += url + " ";
    anchor.classList.add("tab");
    text.textContent = title;
    renderedInfo += title + "\n";
    anchor.addEventListener("click", (event) =>
      _onTabClick(event, tabs, url, favIconUrl, index, title, eventLabel));
    parent.addEventListener("click", (event) =>
      _onTabClick(event, tabs, url, favIconUrl, index, title, eventLabel));
    // Only add the dismiss button if its a recent tab
    if (eventLabel === "recent-tab") {
      dismiss.addEventListener("click", async (event) => {
      event.stopPropagation(); // prevent the selection of tab
      await browser.runtime.sendMessage({
        type: "dismissTab",
        index,
       });
      });
    }
    anchor.prepend(image);
    anchor.appendChild(text);
    parent.appendChild(anchor);
    if (eventLabel === "recent-tab") {
      parent.appendChild(dismiss);
    }
    li.appendChild(parent);
    newTabList.appendChild(li);
  });
  if (renderedInfo !== renderTabListLastRendered[containerSelector]) {
    tabList.replaceWith(newTabList);
    renderTabListLastRendered[containerSelector] = renderedInfo;
  }
}

function element(selector) {
  return document.querySelector(selector);
}

element(".mobile-toggle").addEventListener("click", async () => {
  await browser.sidebarAction.open();
  await browser.runtime.sendMessage({
    type: "toggleDesktop",
  });
});

element("#close-private-warning").addEventListener("click", async () => {
  await browser.runtime.sendMessage({
    type: "turnOffPrivateWarning",
  });
  element("#private-warning").style.display = "none";
});

function loadCachedRecentTabs() {
  let value = localStorage.getItem("recentTabs") || "[]";
  value = JSON.parse(value);
  return value;
}

function cacheRecentTabs(value) {
  localStorage.setItem("recentTabs", JSON.stringify(value));
}

function applyDarkTheme() {
  document.body.style.background = "#4a4a4f";
  document.body.style.color = "#fff";
  document.querySelector("#panel").classList.add("dark-theme");
}

async function checkForDark() {
  browser.management.getAll().then((extensions) => {
    for (let extension of extensions) {
    // The user has the default dark theme enabled
    if (extension.id ===
      "firefox-compact-dark@mozilla.org@personas.mozilla.org"
      && extension.enabled) {
        applyDarkTheme();
      }
    }
  });
}

async function init() {
  document.addEventListener("contextmenu", event => event.preventDefault());

  browser.runtime.onMessage.addListener((message) => {
    if (message.type === "updateRecentTabs") {
      recentTabs = message.recentTabs;
      updateHome();
      cacheRecentTabs(recentTabs);
    } else if (message.type === "isDesktop") {
      isDesktop = message.isDesktop;
      updateHome();
    } else if (["setDesktop", "sidebarOpenedPage", "sidebarDisplayedHome", "getRecentTabs"].includes(message.type)) {
      // These intended to go to the backgrond and can be ignored here
    } else {
      console.error("Got unexpected message:", message);
    }
  });

  recentTabs = loadCachedRecentTabs();
  updateHome();

  let info = await browser.runtime.sendMessage({
    type: "getRecentAndDesktop",
  });
  recentTabs = info.recentTabs;
  isDesktop = info.isDesktop;
  if (info.incognito && !info.hasSeenPrivateWarning) {
    element("#private-warning").style.display = "";
  }
  updateHome();

  // Listen for tab changes to update while popup is still open
  for (let eventName of rerenderEvents) {
    browser.tabs[eventName].addListener(updateHome);
  }
  checkForDark();
}

init();


================================================
FILE: addon/sidebar.css
================================================
body,
html {
  font: message-box;
  font-size: 15px;
  overflow: hidden;
  color: rgb(12, 12, 13);
}

:root {
  --dark-theme-background-color: #4a4a4f;
  --dark-theme-highlight-color: #6d6d6f;
  --dark-theme-color: #fff;
  --dark-theme-links: #45a1ff;
}

* {
  box-sizing: border-box;
  text-align: center;
}

body {
  margin: 0;
}

#home-panel {
  display: none;
}

.page {
  background: #f9f9fa;
  min-height: 100vh;
  padding: 40px 28px;
}

.title {
  font-size: 1.46em;
  font-weight: 300;
  line-height: 1.3em;
  margin: 0;
}

.subtitle {
  font-size: 1em;
  font-weight: 400;
  margin: 6px 0 24px;
}

.subtitle a {
  color: rgb(12, 12, 13);
}

.instructions {
  list-style: none;
  margin: 0;
  padding: 0;
}

#landing-panel {
  align-items: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.graphic {
  align-items: center;
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  width: 71vw;
  max-width: 284px;
  height: 52vw;
  max-height: 206px;
}

.graphic__overlay {
  position: relative;
  max-width: 284px;
  width: 100%;
  height: 61vw;
  max-height: 174px;
  margin-bottom: 9.2%;
}

.graphic__clouds {
  max-width: 284px;
  width: 100%;
  max-height: 174px;
  height: 100%;
  background: url(images/in-content-clouds.png) no-repeat center;
  background-size: contain;
  position: absolute;
}

.graphic__browser {
  animation: fade-in-down forwards 1000ms cubic-bezier(0.22, 0.92, 0.62, 1);
  animation-delay: 100ms;
  background: url(images/in-content-icon.png) no-repeat center;
  background-size: contain;
  max-width: 284px;
  width: 100%;
  height: 100%;
  opacity: 0;
  position: absolute;
  transform: translate3d(0, -72px, 0);
}

.graphic__shadow {
  animation: fade-in-scale forwards 1000ms cubic-bezier(0.22, 0.92, 0.62, 1);
  animation-delay: 250ms;
  max-width: 170px;
  width: 61.2%;
  height: 16px;
  border-radius: 50%;
  background: #ededf0;
  opacity: 0;
  transform: scale(1.3);
}

@keyframes fade-in-down {
  0% {
    opacity: 0;
    transform: translate3d(0, -72px, 0);
  }

  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fade-in-scale {
  0% {
    opacity: 0;
    transform: scale(1.3);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.default-link {
  appearance: none;
  background-color: rgba(0, 0, 0, 0);
  border: 0;
  color: rgb(10, 141, 255);
  cursor: pointer;
  font-size: 15px;
  margin: 6px 0;
  padding: 0;
  text-decoration: none;
  transition: color 100ms;
}

.subtitle .default-link {
  margin: 0;
  padding: 0;
}

.default-link:hover,
.default-link:focus {
  color: rgb(0, 96, 223);
  text-decoration: underline;
}

/* Dark theme */

.page.dark-theme {
  color: var(--dark-theme-color);
  background: var(--dark-theme-background-color);
}

.page.dark-theme button:hover,
.page.dark-theme button:focus,
.page.dark-theme .graphic__shadow {
  background: var(--dark-theme-highlight-color);
  background-color: transparent;
}

.page.dark-theme .default-link,
.page.dark-theme .default-link:hover,
.page.dark-theme .default-link:focus {
  color: var(--dark-theme-links);
}

.page.dark-theme .graphic__clouds {
  background: url(images/in-content-clouds-dark.png);
}


================================================
FILE: addon/sidebar.html
================================================
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Sidebar</title>
    <link rel="stylesheet" href="sidebar.css"/>
  </head>
  <body>
    <div class="page" id="landing-panel">
      <div class="graphic">
        <div class="graphic__overlay">
          <div class="graphic__clouds"></div>
          <div class=graphic__browser></div>
        </div>
        <div class="graphic__shadow"></div>
      </div>
      <h1 class="title">Welcome to Side View</h1>

      <p>
        <a href="https://youtu.be/no6D_B4wgo8" id="watch-tutorial">Watch a tutorial</a>
      </p>
    </div>

    <script src="build/buildSettings.js"></script>
    <script src="sidebar.js"></script>
  </body>
</html>


================================================
FILE: addon/sidebar.js
================================================
/* globals buildSettings */

function element(selector) {
  return document.querySelector(selector);
}

function applyDarkTheme() {
  document.querySelector(".page").classList.add("dark-theme");
}

async function checkForDark() {
  browser.management.getAll().then((extensions) => {
    for (let extension of extensions) {
    // The user has the default dark theme enabled
    if (extension.id ===
      "firefox-compact-dark@mozilla.org@personas.mozilla.org"
      && extension.enabled) {
        applyDarkTheme();
      }
    }
  });
}

async function init() {
  element("#watch-tutorial").onclick = () => {
    window.open("https://youtu.be/no6D_B4wgo8");
  };

  checkForDark();
  browser.management.onEnabled.addListener((info) => {
    checkForDark();
  });
}

init();


================================================
FILE: docs/release.md
================================================
# Release Process

## addons.mozilla.org

To build for AMO:

```sh
npm run package
# XPI is in ./addon-amo.xpi
```

Then 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).


================================================
FILE: package.json
================================================
{
  "name": "side-view",
  "description": "Open a mobile view of a page in the sidebar",
  "version": "0.6.0",
  "author": "Mozilla (https://mozilla.org/)",
  "bugs": {
    "url": "https://github.com/mozilla/side-view/issues"
  },
  "devDependencies": {
    "addons-linter": "^7.3.0",
    "eslint": "^5.5.0",
    "eslint-plugin-mozilla": "^0.15.4",
    "eslint-plugin-no-unsanitized": "^3.0.2",
    "mustache": "^2.3.2",
    "npm-run-all": "4.1.5",
    "stylelint": "^9.5.0",
    "stylelint-config-standard": "^18.2.0",
    "web-ext": "^2.9.1"
  },
  "homepage": "https://github.com/mozilla/side-view/",
  "license": "MPL-2.0",
  "private": true,
  "repository": {
    "type": "git",
    "url": "git+https://github.com/mozilla/side-view.git"
  },
  "scripts": {
    "start": "npm-run-all build run",
    "lint": "npm-run-all lint:*",
    "lint:addon": "npm run package && addons-linter ./addon.xpi -o text --self-hosted",
    "lint:js": "eslint .",
    "lint:styles": "stylelint ./addon/*.css",
    "build": "npm-run-all build:*",
    "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",
    "build:buildSettings": "mkdir -p addon/build/ && node -e 'console.log(JSON.stringify(process.env))' | mustache - addon/buildSettings.js.tmpl > addon/build/buildSettings.js",
    "build:web-ext": "web-ext build --source-dir=addon --overwrite-dest --ignore-files '*.tmpl'",
    "package": "npm run build && cp web-ext-artifacts/`ls -t1 web-ext-artifacts | head -n 1` addon.xpi",
    "run": "mkdir -p ./Profile && web-ext run --source-dir=addon -p ./Profile --browser-console --keep-profile-changes -f nightly",
    "test": "npm run lint"
  }
}
Download .txt
gitextract_84i6seak/

├── .circleci/
│   └── config.yml
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .stylelintrc
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── addon/
│   ├── background.js
│   ├── buildSettings.js.tmpl
│   ├── intro.css
│   ├── intro.html
│   ├── intro.js
│   ├── manifest.json.tmpl
│   ├── popup.css
│   ├── popup.html
│   ├── popup.js
│   ├── sidebar.css
│   ├── sidebar.html
│   └── sidebar.js
├── docs/
│   └── release.md
└── package.json
Download .txt
SYMBOL INDEX (28 symbols across 4 files)

FILE: addon/background.js
  constant FIREFOX_VERSION (line 1) | const FIREFOX_VERSION = /rv:([0-9.]+)/.exec(navigator.userAgent)[1];
  constant USER_AGENT (line 3) | const USER_AGENT = `Mozilla/5.0 (Android 14; Mobile; rv:${FIREFOX_VERSIO...
  constant DEFAULT_DESKTOP_SITES (line 12) | const DEFAULT_DESKTOP_SITES = [
  constant DEFAULT_DESKTOP_VERSION (line 21) | const DEFAULT_DESKTOP_VERSION = 2;
  constant MAX_RECENT_TABS (line 23) | const MAX_RECENT_TABS = 5;
  function openUrl (line 74) | async function openUrl(url) {
  function toggleDesktop (line 132) | async function toggleDesktop() {
  function addRecentTab (line 153) | async function addRecentTab(tabInfo) {
  function dismissRecentTab (line 173) | async function dismissRecentTab(tab_index) {
  function privateWarningOnUpdated (line 208) | function privateWarningOnUpdated(tabId, changeInfo, tab) {
  function turnOffPrivateWarning (line 214) | async function turnOffPrivateWarning() {
  function showOnboardingBadge (line 224) | function showOnboardingBadge() {
  function init (line 239) | async function init() {

FILE: addon/intro.js
  function selectSlide (line 4) | function selectSlide(num) {

FILE: addon/popup.js
  function displayPage (line 6) | async function displayPage({url, title, favIconUrl}) {
  function updateHome (line 22) | async function updateHome(event) {
  function _onTabClick (line 61) | function _onTabClick(event, tabs, url, favIconUrl, index, title, eventLa...
  function renderTabList (line 69) | function renderTabList(tabs, containerSelector, eventLabel) {
  function element (line 127) | function element(selector) {
  function loadCachedRecentTabs (line 145) | function loadCachedRecentTabs() {
  function cacheRecentTabs (line 151) | function cacheRecentTabs(value) {
  function applyDarkTheme (line 155) | function applyDarkTheme() {
  function checkForDark (line 161) | async function checkForDark() {
  function init (line 174) | async function init() {

FILE: addon/sidebar.js
  function element (line 3) | function element(selector) {
  function applyDarkTheme (line 7) | function applyDarkTheme() {
  function checkForDark (line 11) | async function checkForDark() {
  function init (line 24) | async function init() {
Condensed preview — 22 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (58K chars).
[
  {
    "path": ".circleci/config.yml",
    "chars": 837,
    "preview": "version: 2.0\njobs:\n    package:\n        docker:\n            - image: circleci/node:8.9.4\n        steps:\n            - ch"
  },
  {
    "path": ".eslintignore",
    "chars": 38,
    "preview": "addon/build\nProfile\nweb-ext-artifacts\n"
  },
  {
    "path": ".eslintrc.js",
    "chars": 468,
    "preview": "module.exports = {\n  \"env\": {\n    \"es6\": true,\n    \"webextensions\": true\n  },\n  \"extends\": [\n    \"eslint:recommended\",\n "
  },
  {
    "path": ".gitignore",
    "chars": 146,
    "preview": "node_modules\nweb-ext-artifacts\naddon*.xpi\naddon/build\naddon/manifest.json\n/addon/experiment/study\n/null-addon/addon/expe"
  },
  {
    "path": ".stylelintrc",
    "chars": 120,
    "preview": "{\n  \"extends\": \"stylelint-config-standard\",\n  \"rules\": {\n    \"font-family-no-missing-generic-family-keyword\": null\n  }\n}"
  },
  {
    "path": "CODE_OF_CONDUCT.md",
    "chars": 691,
    "preview": "# Community Participation Guidelines\n\nThis repository is governed by Mozilla's code of conduct and etiquette guidelines."
  },
  {
    "path": "LICENSE",
    "chars": 16725,
    "preview": "Mozilla Public License Version 2.0\n==================================\n\n1. Definitions\n--------------\n\n1.1. \"Contributor\""
  },
  {
    "path": "README.md",
    "chars": 931,
    "preview": "# Side View\n\nAn experiment with opening mobile views of pages in the sidebar.\n\n[**Install from addons.mozilla.org**](htt"
  },
  {
    "path": "addon/background.js",
    "chars": 8458,
    "preview": "const FIREFOX_VERSION = /rv:([0-9.]+)/.exec(navigator.userAgent)[1];\n\nconst USER_AGENT = `Mozilla/5.0 (Android 14; Mobil"
  },
  {
    "path": "addon/buildSettings.js.tmpl",
    "chars": 53,
    "preview": "var buildSettings = {\n  NODE_ENV: \"{{NODE_ENV}}\",\n};\n"
  },
  {
    "path": "addon/intro.css",
    "chars": 1400,
    "preview": ":root {\n  --blue-40: #45a1ff;\n  --blue-50: #0a84ff;\n  --blue-50-a30: rgba(10, 132, 255, 0.3);\n  --blue-60: #0060df;\n  --"
  },
  {
    "path": "addon/intro.html",
    "chars": 1619,
    "preview": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"UTF-8\">\n    <link rel=\"stylesheet\" href=\"popup.css\">\n    <link rel=\"s"
  },
  {
    "path": "addon/intro.js",
    "chars": 1550,
    "preview": "let foundSlides = 0;\nlet currentSlide = 0;\n\nfunction selectSlide(num) {\n  for (let i = 0; i < foundSlides; i++) {\n    le"
  },
  {
    "path": "addon/manifest.json.tmpl",
    "chars": 1313,
    "preview": "{\n    \"manifest_version\": 2,\n    \"name\": \"Side View\",\n    \"version\": \"{{version}}\",\n    \"description\": \"{{description}}\""
  },
  {
    "path": "addon/popup.css",
    "chars": 4576,
    "preview": "body,\nhtml {\n  font: message-box;\n  overflow: hidden;\n}\n\n:root {\n  --dark-theme-background-color: #4a4a4f;\n  --dark-them"
  },
  {
    "path": "addon/popup.html",
    "chars": 1477,
    "preview": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"UTF-8\">\n    <title>Popup</title>\n    <link rel=\"stylesheet\" href=\"pop"
  },
  {
    "path": "addon/popup.js",
    "chars": 6723,
    "preview": "/* globals buildSettings */\nlet isDesktop = false;\nlet recentTabs = [];\nconst rerenderEvents = [\"onUpdated\", \"onRemoved\""
  },
  {
    "path": "addon/sidebar.css",
    "chars": 3205,
    "preview": "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-t"
  },
  {
    "path": "addon/sidebar.html",
    "chars": 705,
    "preview": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"UTF-8\">\n    <title>Sidebar</title>\n    <link rel=\"stylesheet\" href=\"s"
  },
  {
    "path": "addon/sidebar.js",
    "chars": 776,
    "preview": "/* globals buildSettings */\n\nfunction element(selector) {\n  return document.querySelector(selector);\n}\n\nfunction applyDa"
  },
  {
    "path": "docs/release.md",
    "chars": 280,
    "preview": "# 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"
  },
  {
    "path": "package.json",
    "chars": 1940,
    "preview": "{\n  \"name\": \"side-view\",\n  \"description\": \"Open a mobile view of a page in the sidebar\",\n  \"version\": \"0.6.0\",\n  \"author"
  }
]

About this extraction

This page contains the full source code of the mozilla/side-view GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 22 files (52.8 KB), approximately 14.0k tokens, and a symbol index with 28 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!