/* tslint:disable */

/* -------------------------------------------------- */

/*      Start of Webpack Hot Extension Middleware     */

/* ================================================== */

/*  This will be converted into a lodash templ., any  */

/*  external argument must be provided using it       */

/* -------------------------------------------------- */
(function (window) {
  var injectionContext = {
    browser: null
  };
  (function () {
    ""||(function (global, factory) {
  if (typeof define === "function" && define.amd) {
    define("webextension-polyfill", ["module"], factory);
  } else if (typeof exports !== "undefined") {
    factory(module);
  } else {
    var mod = {
      exports: {}
    };
    factory(mod);
    global.browser = mod.exports;
  }
})(this, function (module) {
  /* webextension-polyfill - v0.5.0 - Thu Sep 26 2019 22:22:26 */
  /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
  /* vim: set sts=2 sw=2 et tw=80: */
  /* This Source Code Form is subject to the terms of the Mozilla Public
   * License, v. 2.0. If a copy of the MPL was not distributed with this
   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  "use strict";

  if (typeof browser === "undefined" || Object.getPrototypeOf(browser) !== Object.prototype) {
    const CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE = "The message port closed before a response was received.";
    const SEND_RESPONSE_DEPRECATION_WARNING = "Returning a Promise is the preferred way to send a reply from an onMessage/onMessageExternal listener, as the sendResponse will be removed from the specs (See https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage)";

    // Wrapping the bulk of this polyfill in a one-time-use function is a minor
    // optimization for Firefox. Since Spidermonkey does not fully parse the
    // contents of a function until the first time it's called, and since it will
    // never actually need to be called, this allows the polyfill to be included
    // in Firefox nearly for free.
    const wrapAPIs = extensionAPIs => {
      // NOTE: apiMetadata is associated to the content of the api-metadata.json file
      // at build time by replacing the following "include" with the content of the
      // JSON file.
      const apiMetadata = {
        "alarms": {
          "clear": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "clearAll": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "get": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "getAll": {
            "minArgs": 0,
            "maxArgs": 0
          }
        },
        "bookmarks": {
          "create": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "get": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getChildren": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getRecent": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getSubTree": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getTree": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "move": {
            "minArgs": 2,
            "maxArgs": 2
          },
          "remove": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removeTree": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "search": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "update": {
            "minArgs": 2,
            "maxArgs": 2
          }
        },
        "browserAction": {
          "disable": {
            "minArgs": 0,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          },
          "enable": {
            "minArgs": 0,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          },
          "getBadgeBackgroundColor": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getBadgeText": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getPopup": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getTitle": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "openPopup": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "setBadgeBackgroundColor": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          },
          "setBadgeText": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          },
          "setIcon": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "setPopup": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          },
          "setTitle": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          }
        },
        "browsingData": {
          "remove": {
            "minArgs": 2,
            "maxArgs": 2
          },
          "removeCache": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removeCookies": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removeDownloads": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removeFormData": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removeHistory": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removeLocalStorage": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removePasswords": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removePluginData": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "settings": {
            "minArgs": 0,
            "maxArgs": 0
          }
        },
        "commands": {
          "getAll": {
            "minArgs": 0,
            "maxArgs": 0
          }
        },
        "contextMenus": {
          "remove": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removeAll": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "update": {
            "minArgs": 2,
            "maxArgs": 2
          }
        },
        "cookies": {
          "get": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getAll": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getAllCookieStores": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "remove": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "set": {
            "minArgs": 1,
            "maxArgs": 1
          }
        },
        "devtools": {
          "inspectedWindow": {
            "eval": {
              "minArgs": 1,
              "maxArgs": 2,
              "singleCallbackArg": false
            }
          },
          "panels": {
            "create": {
              "minArgs": 3,
              "maxArgs": 3,
              "singleCallbackArg": true
            }
          }
        },
        "downloads": {
          "cancel": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "download": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "erase": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getFileIcon": {
            "minArgs": 1,
            "maxArgs": 2
          },
          "open": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          },
          "pause": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removeFile": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "resume": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "search": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "show": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          }
        },
        "extension": {
          "isAllowedFileSchemeAccess": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "isAllowedIncognitoAccess": {
            "minArgs": 0,
            "maxArgs": 0
          }
        },
        "history": {
          "addUrl": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "deleteAll": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "deleteRange": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "deleteUrl": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getVisits": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "search": {
            "minArgs": 1,
            "maxArgs": 1
          }
        },
        "i18n": {
          "detectLanguage": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getAcceptLanguages": {
            "minArgs": 0,
            "maxArgs": 0
          }
        },
        "identity": {
          "launchWebAuthFlow": {
            "minArgs": 1,
            "maxArgs": 1
          }
        },
        "idle": {
          "queryState": {
            "minArgs": 1,
            "maxArgs": 1
          }
        },
        "management": {
          "get": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getAll": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "getSelf": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "setEnabled": {
            "minArgs": 2,
            "maxArgs": 2
          },
          "uninstallSelf": {
            "minArgs": 0,
            "maxArgs": 1
          }
        },
        "notifications": {
          "clear": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "create": {
            "minArgs": 1,
            "maxArgs": 2
          },
          "getAll": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "getPermissionLevel": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "update": {
            "minArgs": 2,
            "maxArgs": 2
          }
        },
        "pageAction": {
          "getPopup": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getTitle": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "hide": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          },
          "setIcon": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "setPopup": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          },
          "setTitle": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          },
          "show": {
            "minArgs": 1,
            "maxArgs": 1,
            "fallbackToNoCallback": true
          }
        },
        "permissions": {
          "contains": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getAll": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "remove": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "request": {
            "minArgs": 1,
            "maxArgs": 1
          }
        },
        "runtime": {
          "getBackgroundPage": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "getPlatformInfo": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "openOptionsPage": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "requestUpdateCheck": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "sendMessage": {
            "minArgs": 1,
            "maxArgs": 3
          },
          "sendNativeMessage": {
            "minArgs": 2,
            "maxArgs": 2
          },
          "setUninstallURL": {
            "minArgs": 1,
            "maxArgs": 1
          }
        },
        "sessions": {
          "getDevices": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "getRecentlyClosed": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "restore": {
            "minArgs": 0,
            "maxArgs": 1
          }
        },
        "storage": {
          "local": {
            "clear": {
              "minArgs": 0,
              "maxArgs": 0
            },
            "get": {
              "minArgs": 0,
              "maxArgs": 1
            },
            "getBytesInUse": {
              "minArgs": 0,
              "maxArgs": 1
            },
            "remove": {
              "minArgs": 1,
              "maxArgs": 1
            },
            "set": {
              "minArgs": 1,
              "maxArgs": 1
            }
          },
          "managed": {
            "get": {
              "minArgs": 0,
              "maxArgs": 1
            },
            "getBytesInUse": {
              "minArgs": 0,
              "maxArgs": 1
            }
          },
          "sync": {
            "clear": {
              "minArgs": 0,
              "maxArgs": 0
            },
            "get": {
              "minArgs": 0,
              "maxArgs": 1
            },
            "getBytesInUse": {
              "minArgs": 0,
              "maxArgs": 1
            },
            "remove": {
              "minArgs": 1,
              "maxArgs": 1
            },
            "set": {
              "minArgs": 1,
              "maxArgs": 1
            }
          }
        },
        "tabs": {
          "captureVisibleTab": {
            "minArgs": 0,
            "maxArgs": 2
          },
          "create": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "detectLanguage": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "discard": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "duplicate": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "executeScript": {
            "minArgs": 1,
            "maxArgs": 2
          },
          "get": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getCurrent": {
            "minArgs": 0,
            "maxArgs": 0
          },
          "getZoom": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "getZoomSettings": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "highlight": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "insertCSS": {
            "minArgs": 1,
            "maxArgs": 2
          },
          "move": {
            "minArgs": 2,
            "maxArgs": 2
          },
          "query": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "reload": {
            "minArgs": 0,
            "maxArgs": 2
          },
          "remove": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "removeCSS": {
            "minArgs": 1,
            "maxArgs": 2
          },
          "sendMessage": {
            "minArgs": 2,
            "maxArgs": 3
          },
          "setZoom": {
            "minArgs": 1,
            "maxArgs": 2
          },
          "setZoomSettings": {
            "minArgs": 1,
            "maxArgs": 2
          },
          "update": {
            "minArgs": 1,
            "maxArgs": 2
          }
        },
        "topSites": {
          "get": {
            "minArgs": 0,
            "maxArgs": 0
          }
        },
        "webNavigation": {
          "getAllFrames": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "getFrame": {
            "minArgs": 1,
            "maxArgs": 1
          }
        },
        "webRequest": {
          "handlerBehaviorChanged": {
            "minArgs": 0,
            "maxArgs": 0
          }
        },
        "windows": {
          "create": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "get": {
            "minArgs": 1,
            "maxArgs": 2
          },
          "getAll": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "getCurrent": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "getLastFocused": {
            "minArgs": 0,
            "maxArgs": 1
          },
          "remove": {
            "minArgs": 1,
            "maxArgs": 1
          },
          "update": {
            "minArgs": 2,
            "maxArgs": 2
          }
        }
      };

      if (Object.keys(apiMetadata).length === 0) {
        throw new Error("api-metadata.json has not been included in browser-polyfill");
      }

      /**
       * A WeakMap subclass which creates and stores a value for any key which does
       * not exist when accessed, but behaves exactly as an ordinary WeakMap
       * otherwise.
       *
       * @param {function} createItem
       *        A function which will be called in order to create the value for any
       *        key which does not exist, the first time it is accessed. The
       *        function receives, as its only argument, the key being created.
       */
      class DefaultWeakMap extends WeakMap {
        constructor(createItem, items = undefined) {
          super(items);
          this.createItem = createItem;
        }

        get(key) {
          if (!this.has(key)) {
            this.set(key, this.createItem(key));
          }

          return super.get(key);
        }
      }

      /**
       * Returns true if the given object is an object with a `then` method, and can
       * therefore be assumed to behave as a Promise.
       *
       * @param {*} value The value to test.
       * @returns {boolean} True if the value is thenable.
       */
      const isThenable = value => {
        return value && typeof value === "object" && typeof value.then === "function";
      };

      /**
       * Creates and returns a function which, when called, will resolve or reject
       * the given promise based on how it is called:
       *
       * - If, when called, `chrome.runtime.lastError` contains a non-null object,
       *   the promise is rejected with that value.
       * - If the function is called with exactly one argument, the promise is
       *   resolved to that value.
       * - Otherwise, the promise is resolved to an array containing all of the
       *   function's arguments.
       *
       * @param {object} promise
       *        An object containing the resolution and rejection functions of a
       *        promise.
       * @param {function} promise.resolve
       *        The promise's resolution function.
       * @param {function} promise.rejection
       *        The promise's rejection function.
       * @param {object} metadata
       *        Metadata about the wrapped method which has created the callback.
       * @param {integer} metadata.maxResolvedArgs
       *        The maximum number of arguments which may be passed to the
       *        callback created by the wrapped async function.
       *
       * @returns {function}
       *        The generated callback function.
       */
      const makeCallback = (promise, metadata) => {
        return (...callbackArgs) => {
          if (extensionAPIs.runtime.lastError) {
            promise.reject(extensionAPIs.runtime.lastError);
          } else if (metadata.singleCallbackArg || callbackArgs.length <= 1 && metadata.singleCallbackArg !== false) {
            promise.resolve(callbackArgs[0]);
          } else {
            promise.resolve(callbackArgs);
          }
        };
      };

      const pluralizeArguments = numArgs => numArgs == 1 ? "argument" : "arguments";

      /**
       * Creates a wrapper function for a method with the given name and metadata.
       *
       * @param {string} name
       *        The name of the method which is being wrapped.
       * @param {object} metadata
       *        Metadata about the method being wrapped.
       * @param {integer} metadata.minArgs
       *        The minimum number of arguments which must be passed to the
       *        function. If called with fewer than this number of arguments, the
       *        wrapper will raise an exception.
       * @param {integer} metadata.maxArgs
       *        The maximum number of arguments which may be passed to the
       *        function. If called with more than this number of arguments, the
       *        wrapper will raise an exception.
       * @param {integer} metadata.maxResolvedArgs
       *        The maximum number of arguments which may be passed to the
       *        callback created by the wrapped async function.
       *
       * @returns {function(object, ...*)}
       *       The generated wrapper function.
       */
      const wrapAsyncFunction = (name, metadata) => {
        return function asyncFunctionWrapper(target, ...args) {
          if (args.length < metadata.minArgs) {
            throw new Error(`Expected at least ${metadata.minArgs} ${pluralizeArguments(metadata.minArgs)} for ${name}(), got ${args.length}`);
          }

          if (args.length > metadata.maxArgs) {
            throw new Error(`Expected at most ${metadata.maxArgs} ${pluralizeArguments(metadata.maxArgs)} for ${name}(), got ${args.length}`);
          }

          return new Promise((resolve, reject) => {
            if (metadata.fallbackToNoCallback) {
              // This API method has currently no callback on Chrome, but it return a promise on Firefox,
              // and so the polyfill will try to call it with a callback first, and it will fallback
              // to not passing the callback if the first call fails.
              try {
                target[name](...args, makeCallback({ resolve, reject }, metadata));
              } catch (cbError) {
                console.warn(`${name} API method doesn't seem to support the callback parameter, ` + "falling back to call it without a callback: ", cbError);

                target[name](...args);

                // Update the API method metadata, so that the next API calls will not try to
                // use the unsupported callback anymore.
                metadata.fallbackToNoCallback = false;
                metadata.noCallback = true;

                resolve();
              }
            } else if (metadata.noCallback) {
              target[name](...args);
              resolve();
            } else {
              target[name](...args, makeCallback({ resolve, reject }, metadata));
            }
          });
        };
      };

      /**
       * Wraps an existing method of the target object, so that calls to it are
       * intercepted by the given wrapper function. The wrapper function receives,
       * as its first argument, the original `target` object, followed by each of
       * the arguments passed to the original method.
       *
       * @param {object} target
       *        The original target object that the wrapped method belongs to.
       * @param {function} method
       *        The method being wrapped. This is used as the target of the Proxy
       *        object which is created to wrap the method.
       * @param {function} wrapper
       *        The wrapper function which is called in place of a direct invocation
       *        of the wrapped method.
       *
       * @returns {Proxy<function>}
       *        A Proxy object for the given method, which invokes the given wrapper
       *        method in its place.
       */
      const wrapMethod = (target, method, wrapper) => {
        return new Proxy(method, {
          apply(targetMethod, thisObj, args) {
            return wrapper.call(thisObj, target, ...args);
          }
        });
      };

      let hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty);

      /**
       * Wraps an object in a Proxy which intercepts and wraps certain methods
       * based on the given `wrappers` and `metadata` objects.
       *
       * @param {object} target
       *        The target object to wrap.
       *
       * @param {object} [wrappers = {}]
       *        An object tree containing wrapper functions for special cases. Any
       *        function present in this object tree is called in place of the
       *        method in the same location in the `target` object tree. These
       *        wrapper methods are invoked as described in {@see wrapMethod}.
       *
       * @param {object} [metadata = {}]
       *        An object tree containing metadata used to automatically generate
       *        Promise-based wrapper functions for asynchronous. Any function in
       *        the `target` object tree which has a corresponding metadata object
       *        in the same location in the `metadata` tree is replaced with an
       *        automatically-generated wrapper function, as described in
       *        {@see wrapAsyncFunction}
       *
       * @returns {Proxy<object>}
       */
      const wrapObject = (target, wrappers = {}, metadata = {}) => {
        let cache = Object.create(null);
        let handlers = {
          has(proxyTarget, prop) {
            return prop in target || prop in cache;
          },

          get(proxyTarget, prop, receiver) {
            if (prop in cache) {
              return cache[prop];
            }

            if (!(prop in target)) {
              return undefined;
            }

            let value = target[prop];

            if (typeof value === "function") {
              // This is a method on the underlying object. Check if we need to do
              // any wrapping.

              if (typeof wrappers[prop] === "function") {
                // We have a special-case wrapper for this method.
                value = wrapMethod(target, target[prop], wrappers[prop]);
              } else if (hasOwnProperty(metadata, prop)) {
                // This is an async method that we have metadata for. Create a
                // Promise wrapper for it.
                let wrapper = wrapAsyncFunction(prop, metadata[prop]);
                value = wrapMethod(target, target[prop], wrapper);
              } else {
                // This is a method that we don't know or care about. Return the
                // original method, bound to the underlying object.
                value = value.bind(target);
              }
            } else if (typeof value === "object" && value !== null && (hasOwnProperty(wrappers, prop) || hasOwnProperty(metadata, prop))) {
              // This is an object that we need to do some wrapping for the children
              // of. Create a sub-object wrapper for it with the appropriate child
              // metadata.
              value = wrapObject(value, wrappers[prop], metadata[prop]);
            } else {
              // We don't need to do any wrapping for this property,
              // so just forward all access to the underlying object.
              Object.defineProperty(cache, prop, {
                configurable: true,
                enumerable: true,
                get() {
                  return target[prop];
                },
                set(value) {
                  target[prop] = value;
                }
              });

              return value;
            }

            cache[prop] = value;
            return value;
          },

          set(proxyTarget, prop, value, receiver) {
            if (prop in cache) {
              cache[prop] = value;
            } else {
              target[prop] = value;
            }
            return true;
          },

          defineProperty(proxyTarget, prop, desc) {
            return Reflect.defineProperty(cache, prop, desc);
          },

          deleteProperty(proxyTarget, prop) {
            return Reflect.deleteProperty(cache, prop);
          }
        };

        // Per contract of the Proxy API, the "get" proxy handler must return the
        // original value of the target if that value is declared read-only and
        // non-configurable. For this reason, we create an object with the
        // prototype set to `target` instead of using `target` directly.
        // Otherwise we cannot return a custom object for APIs that
        // are declared read-only and non-configurable, such as `chrome.devtools`.
        //
        // The proxy handlers themselves will still use the original `target`
        // instead of the `proxyTarget`, so that the methods and properties are
        // dereferenced via the original targets.
        let proxyTarget = Object.create(target);
        return new Proxy(proxyTarget, handlers);
      };

      /**
       * Creates a set of wrapper functions for an event object, which handles
       * wrapping of listener functions that those messages are passed.
       *
       * A single wrapper is created for each listener function, and stored in a
       * map. Subsequent calls to `addListener`, `hasListener`, or `removeListener`
       * retrieve the original wrapper, so that  attempts to remove a
       * previously-added listener work as expected.
       *
       * @param {DefaultWeakMap<function, function>} wrapperMap
       *        A DefaultWeakMap object which will create the appropriate wrapper
       *        for a given listener function when one does not exist, and retrieve
       *        an existing one when it does.
       *
       * @returns {object}
       */
      const wrapEvent = wrapperMap => ({
        addListener(target, listener, ...args) {
          target.addListener(wrapperMap.get(listener), ...args);
        },

        hasListener(target, listener) {
          return target.hasListener(wrapperMap.get(listener));
        },

        removeListener(target, listener) {
          target.removeListener(wrapperMap.get(listener));
        }
      });

      // Keep track if the deprecation warning has been logged at least once.
      let loggedSendResponseDeprecationWarning = false;

      const onMessageWrappers = new DefaultWeakMap(listener => {
        if (typeof listener !== "function") {
          return listener;
        }

        /**
         * Wraps a message listener function so that it may send responses based on
         * its return value, rather than by returning a sentinel value and calling a
         * callback. If the listener function returns a Promise, the response is
         * sent when the promise either resolves or rejects.
         *
         * @param {*} message
         *        The message sent by the other end of the channel.
         * @param {object} sender
         *        Details about the sender of the message.
         * @param {function(*)} sendResponse
         *        A callback which, when called with an arbitrary argument, sends
         *        that value as a response.
         * @returns {boolean}
         *        True if the wrapped listener returned a Promise, which will later
         *        yield a response. False otherwise.
         */
        return function onMessage(message, sender, sendResponse) {
          let didCallSendResponse = false;

          let wrappedSendResponse;
          let sendResponsePromise = new Promise(resolve => {
            wrappedSendResponse = function (response) {
              if (!loggedSendResponseDeprecationWarning) {
                console.warn(SEND_RESPONSE_DEPRECATION_WARNING, new Error().stack);
                loggedSendResponseDeprecationWarning = true;
              }
              didCallSendResponse = true;
              resolve(response);
            };
          });

          let result;
          try {
            result = listener(message, sender, wrappedSendResponse);
          } catch (err) {
            result = Promise.reject(err);
          }

          const isResultThenable = result !== true && isThenable(result);

          // If the listener didn't returned true or a Promise, or called
          // wrappedSendResponse synchronously, we can exit earlier
          // because there will be no response sent from this listener.
          if (result !== true && !isResultThenable && !didCallSendResponse) {
            return false;
          }

          // A small helper to send the message if the promise resolves
          // and an error if the promise rejects (a wrapped sendMessage has
          // to translate the message into a resolved promise or a rejected
          // promise).
          const sendPromisedResult = promise => {
            promise.then(msg => {
              // send the message value.
              sendResponse(msg);
            }, error => {
              // Send a JSON representation of the error if the rejected value
              // is an instance of error, or the object itself otherwise.
              let message;
              if (error && (error instanceof Error || typeof error.message === "string")) {
                message = error.message;
              } else {
                message = "An unexpected error occurred";
              }

              sendResponse({
                __mozWebExtensionPolyfillReject__: true,
                message
              });
            }).catch(err => {
              // Print an error on the console if unable to send the response.
              console.error("Failed to send onMessage rejected reply", err);
            });
          };

          // If the listener returned a Promise, send the resolved value as a
          // result, otherwise wait the promise related to the wrappedSendResponse
          // callback to resolve and send it as a response.
          if (isResultThenable) {
            sendPromisedResult(result);
          } else {
            sendPromisedResult(sendResponsePromise);
          }

          // Let Chrome know that the listener is replying.
          return true;
        };
      });

      const wrappedSendMessageCallback = ({ reject, resolve }, reply) => {
        if (extensionAPIs.runtime.lastError) {
          // Detect when none of the listeners replied to the sendMessage call and resolve
          // the promise to undefined as in Firefox.
          // See https://github.com/mozilla/webextension-polyfill/issues/130
          if (extensionAPIs.runtime.lastError.message === CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE) {
            resolve();
          } else {
            reject(extensionAPIs.runtime.lastError);
          }
        } else if (reply && reply.__mozWebExtensionPolyfillReject__) {
          // Convert back the JSON representation of the error into
          // an Error instance.
          reject(new Error(reply.message));
        } else {
          resolve(reply);
        }
      };

      const wrappedSendMessage = (name, metadata, apiNamespaceObj, ...args) => {
        if (args.length < metadata.minArgs) {
          throw new Error(`Expected at least ${metadata.minArgs} ${pluralizeArguments(metadata.minArgs)} for ${name}(), got ${args.length}`);
        }

        if (args.length > metadata.maxArgs) {
          throw new Error(`Expected at most ${metadata.maxArgs} ${pluralizeArguments(metadata.maxArgs)} for ${name}(), got ${args.length}`);
        }

        return new Promise((resolve, reject) => {
          const wrappedCb = wrappedSendMessageCallback.bind(null, { resolve, reject });
          args.push(wrappedCb);
          apiNamespaceObj.sendMessage(...args);
        });
      };

      const staticWrappers = {
        runtime: {
          onMessage: wrapEvent(onMessageWrappers),
          onMessageExternal: wrapEvent(onMessageWrappers),
          sendMessage: wrappedSendMessage.bind(null, "sendMessage", { minArgs: 1, maxArgs: 3 })
        },
        tabs: {
          sendMessage: wrappedSendMessage.bind(null, "sendMessage", { minArgs: 2, maxArgs: 3 })
        }
      };
      const settingMetadata = {
        clear: { minArgs: 1, maxArgs: 1 },
        get: { minArgs: 1, maxArgs: 1 },
        set: { minArgs: 1, maxArgs: 1 }
      };
      apiMetadata.privacy = {
        network: {
          networkPredictionEnabled: settingMetadata,
          webRTCIPHandlingPolicy: settingMetadata
        },
        services: {
          passwordSavingEnabled: settingMetadata
        },
        websites: {
          hyperlinkAuditingEnabled: settingMetadata,
          referrersEnabled: settingMetadata
        }
      };

      return wrapObject(extensionAPIs, staticWrappers, apiMetadata);
    };

    if (typeof chrome != "object" || !chrome || !chrome.runtime || !chrome.runtime.id) {
      throw new Error("This script should only be loaded in a browser extension.");
    }

    // The build process adds a UMD wrapper around this file, which makes the
    // `module` variable available.
    module.exports = wrapAPIs(chrome);
  } else {
    module.exports = browser;
  }
});
//# sourceMappingURL=browser-polyfill.js.map
"";
  }).bind(injectionContext)();
  var browser = injectionContext.browser;
  var signals = JSON.parse('{"SIGN_CHANGE":"SIGN_CHANGE","SIGN_RELOAD":"SIGN_RELOAD","SIGN_RELOADED":"SIGN_RELOADED","SIGN_LOG":"SIGN_LOG","SIGN_CONNECT":"SIGN_CONNECT"}');
  var config = JSON.parse('{"RECONNECT_INTERVAL":2000,"SOCKET_ERR_CODE_REF":"https://tools.ietf.org/html/rfc6455#section-7.4.1"}');
  var reloadPage = "true" === "true";
  var wsHost = "ws://localhost:9090";
  var SIGN_CHANGE = signals.SIGN_CHANGE,
      SIGN_RELOAD = signals.SIGN_RELOAD,
      SIGN_RELOADED = signals.SIGN_RELOADED,
      SIGN_LOG = signals.SIGN_LOG,
      SIGN_CONNECT = signals.SIGN_CONNECT;
  var RECONNECT_INTERVAL = config.RECONNECT_INTERVAL,
      SOCKET_ERR_CODE_REF = config.SOCKET_ERR_CODE_REF;
  var extension = browser.extension,
      runtime = browser.runtime,
      tabs = browser.tabs;
  var manifest = runtime.getManifest(); // =============================== Helper functions ======================================= //

  var formatter = function formatter(msg) {
    return "[ WER: ".concat(msg, " ]");
  };

  var logger = function logger(msg) {
    var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "info";
    return console[level](formatter(msg));
  };

  var timeFormatter = function timeFormatter(date) {
    return date.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
  }; // ========================== Called only on content scripts ============================== //


  function contentScriptWorker() {
    runtime.sendMessage({
      type: SIGN_CONNECT
    }).then(function (msg) {
      return console.info(msg);
    });
    runtime.onMessage.addListener(function (_ref) {
      var type = _ref.type,
          payload = _ref.payload;

      switch (type) {
        case SIGN_RELOAD:
          logger("Detected Changes. Reloading ...");
          reloadPage && window.location.reload();
          break;

        case SIGN_LOG:
          console.info(payload);
          break;
      }
    });
  } // ======================== Called only on background scripts ============================= //


  function backgroundWorker(socket) {
    runtime.onMessage.addListener(function (action, sender) {
      if (action.type === SIGN_CONNECT) {
        return Promise.resolve(formatter("Connected to Extension Hot Reloader"));
      }

      return true;
    });
    socket.addEventListener("message", function (_ref2) {
      var data = _ref2.data;

      var _JSON$parse = JSON.parse(data),
          type = _JSON$parse.type,
          payload = _JSON$parse.payload;

      if (type === SIGN_CHANGE && (!payload || !payload.onlyPageChanged)) {
        tabs.query({
          status: "complete"
        }).then(function (loadedTabs) {
          loadedTabs.forEach(function (tab) {
            return tab.id && tabs.sendMessage(tab.id, {
              type: SIGN_RELOAD
            });
          });
          socket.send(JSON.stringify({
            type: SIGN_RELOADED,
            payload: formatter("".concat(timeFormatter(new Date()), " - ").concat(manifest.name, " successfully reloaded"))
          }));
          runtime.reload();
        });
      } else {
        runtime.sendMessage({
          type: type,
          payload: payload
        });
      }
    });
    socket.addEventListener("close", function (_ref3) {
      var code = _ref3.code;
      logger("Socket connection closed. Code ".concat(code, ". See more in ").concat(SOCKET_ERR_CODE_REF), "warn");
      var intId = setInterval(function () {
        logger("Attempting to reconnect (tip: Check if Webpack is running)");
        var ws = new WebSocket(wsHost);

        ws.onerror = function () {
          return logger("Error trying to re-connect. Reattempting in ".concat(RECONNECT_INTERVAL / 1000, "s"), "warn");
        };

        ws.addEventListener("open", function () {
          clearInterval(intId);
          logger("Reconnected. Reloading plugin");
          runtime.reload();
        });
      }, RECONNECT_INTERVAL);
    });
  } // ======================== Called only on extension pages that are not the background ============================= //


  function extensionPageWorker() {
    runtime.sendMessage({
      type: SIGN_CONNECT
    }).then(function (msg) {
      return console.info(msg);
    });
    runtime.onMessage.addListener(function (_ref4) {
      var type = _ref4.type,
          payload = _ref4.payload;

      switch (type) {
        case SIGN_CHANGE:
          logger("Detected Changes. Reloading ...");
          reloadPage && window.location.reload();
          break;

        case SIGN_LOG:
          console.info(payload);
          break;
      }
    });
  } // ======================= Bootstraps the middleware =========================== //


  runtime.reload ? extension.getBackgroundPage() === window ? backgroundWorker(new WebSocket(wsHost)) : extensionPageWorker() : contentScriptWorker();
})(window);
/* ----------------------------------------------- */

/* End of Webpack Hot Extension Middleware  */

/* ----------------------------------------------- *//******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./core.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "../node_modules/webextension-polyfill/dist/browser-polyfill.js":
/*!**********************************************************************!*\
  !*** ../node_modules/webextension-polyfill/dist/browser-polyfill.js ***!
  \**********************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (global, factory) {\n  if (true) {\n    !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?\n\t\t\t\t(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n  } else { var mod; }\n})(this, function (module) {\n  /* webextension-polyfill - v0.3.1 - Tue Aug 21 2018 10:09:34 */\n  /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */\n  /* vim: set sts=2 sw=2 et tw=80: */\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  \"use strict\";\n\n  if (typeof browser === \"undefined\" || Object.getPrototypeOf(browser) !== Object.prototype) {\n    const CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE = \"The message port closed before a response was received.\";\n    const SEND_RESPONSE_DEPRECATION_WARNING = \"Returning a Promise is the preferred way to send a reply from an onMessage/onMessageExternal listener, as the sendResponse will be removed from the specs (See https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage)\";\n\n    // Wrapping the bulk of this polyfill in a one-time-use function is a minor\n    // optimization for Firefox. Since Spidermonkey does not fully parse the\n    // contents of a function until the first time it's called, and since it will\n    // never actually need to be called, this allows the polyfill to be included\n    // in Firefox nearly for free.\n    const wrapAPIs = () => {\n      // NOTE: apiMetadata is associated to the content of the api-metadata.json file\n      // at build time by replacing the following \"include\" with the content of the\n      // JSON file.\n      const apiMetadata = {\n        \"alarms\": {\n          \"clear\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"clearAll\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"get\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"getAll\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          }\n        },\n        \"bookmarks\": {\n          \"create\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"get\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getChildren\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getRecent\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getSubTree\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getTree\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"move\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 2\n          },\n          \"remove\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removeTree\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"search\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"update\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 2\n          }\n        },\n        \"browserAction\": {\n          \"disable\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          },\n          \"enable\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          },\n          \"getBadgeBackgroundColor\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getBadgeText\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getPopup\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getTitle\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"openPopup\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"setBadgeBackgroundColor\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          },\n          \"setBadgeText\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          },\n          \"setIcon\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"setPopup\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          },\n          \"setTitle\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          }\n        },\n        \"browsingData\": {\n          \"remove\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 2\n          },\n          \"removeCache\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removeCookies\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removeDownloads\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removeFormData\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removeHistory\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removeLocalStorage\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removePasswords\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removePluginData\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"settings\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          }\n        },\n        \"commands\": {\n          \"getAll\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          }\n        },\n        \"contextMenus\": {\n          \"remove\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removeAll\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"update\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 2\n          }\n        },\n        \"cookies\": {\n          \"get\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getAll\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getAllCookieStores\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"remove\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"set\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          }\n        },\n        \"devtools\": {\n          \"inspectedWindow\": {\n            \"eval\": {\n              \"minArgs\": 1,\n              \"maxArgs\": 2\n            }\n          },\n          \"panels\": {\n            \"create\": {\n              \"minArgs\": 3,\n              \"maxArgs\": 3,\n              \"singleCallbackArg\": true\n            }\n          }\n        },\n        \"downloads\": {\n          \"cancel\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"download\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"erase\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getFileIcon\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 2\n          },\n          \"open\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          },\n          \"pause\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removeFile\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"resume\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"search\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"show\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          }\n        },\n        \"extension\": {\n          \"isAllowedFileSchemeAccess\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"isAllowedIncognitoAccess\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          }\n        },\n        \"history\": {\n          \"addUrl\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"deleteAll\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"deleteRange\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"deleteUrl\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getVisits\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"search\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          }\n        },\n        \"i18n\": {\n          \"detectLanguage\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getAcceptLanguages\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          }\n        },\n        \"identity\": {\n          \"launchWebAuthFlow\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          }\n        },\n        \"idle\": {\n          \"queryState\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          }\n        },\n        \"management\": {\n          \"get\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getAll\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"getSelf\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"setEnabled\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 2\n          },\n          \"uninstallSelf\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          }\n        },\n        \"notifications\": {\n          \"clear\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"create\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 2\n          },\n          \"getAll\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"getPermissionLevel\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"update\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 2\n          }\n        },\n        \"pageAction\": {\n          \"getPopup\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getTitle\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"hide\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          },\n          \"setIcon\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"setPopup\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          },\n          \"setTitle\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          },\n          \"show\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1,\n            \"fallbackToNoCallback\": true\n          }\n        },\n        \"permissions\": {\n          \"contains\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getAll\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"remove\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"request\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          }\n        },\n        \"runtime\": {\n          \"getBackgroundPage\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"getBrowserInfo\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"getPlatformInfo\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"openOptionsPage\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"requestUpdateCheck\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"sendMessage\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 3\n          },\n          \"sendNativeMessage\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 2\n          },\n          \"setUninstallURL\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          }\n        },\n        \"sessions\": {\n          \"getDevices\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"getRecentlyClosed\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"restore\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          }\n        },\n        \"storage\": {\n          \"local\": {\n            \"clear\": {\n              \"minArgs\": 0,\n              \"maxArgs\": 0\n            },\n            \"get\": {\n              \"minArgs\": 0,\n              \"maxArgs\": 1\n            },\n            \"getBytesInUse\": {\n              \"minArgs\": 0,\n              \"maxArgs\": 1\n            },\n            \"remove\": {\n              \"minArgs\": 1,\n              \"maxArgs\": 1\n            },\n            \"set\": {\n              \"minArgs\": 1,\n              \"maxArgs\": 1\n            }\n          },\n          \"managed\": {\n            \"get\": {\n              \"minArgs\": 0,\n              \"maxArgs\": 1\n            },\n            \"getBytesInUse\": {\n              \"minArgs\": 0,\n              \"maxArgs\": 1\n            }\n          },\n          \"sync\": {\n            \"clear\": {\n              \"minArgs\": 0,\n              \"maxArgs\": 0\n            },\n            \"get\": {\n              \"minArgs\": 0,\n              \"maxArgs\": 1\n            },\n            \"getBytesInUse\": {\n              \"minArgs\": 0,\n              \"maxArgs\": 1\n            },\n            \"remove\": {\n              \"minArgs\": 1,\n              \"maxArgs\": 1\n            },\n            \"set\": {\n              \"minArgs\": 1,\n              \"maxArgs\": 1\n            }\n          }\n        },\n        \"tabs\": {\n          \"captureVisibleTab\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 2\n          },\n          \"create\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"detectLanguage\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"discard\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"duplicate\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"executeScript\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 2\n          },\n          \"get\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getCurrent\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          },\n          \"getZoom\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"getZoomSettings\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"highlight\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"insertCSS\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 2\n          },\n          \"move\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 2\n          },\n          \"query\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"reload\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 2\n          },\n          \"remove\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"removeCSS\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 2\n          },\n          \"sendMessage\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 3\n          },\n          \"setZoom\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 2\n          },\n          \"setZoomSettings\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 2\n          },\n          \"update\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 2\n          }\n        },\n        \"topSites\": {\n          \"get\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          }\n        },\n        \"webNavigation\": {\n          \"getAllFrames\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"getFrame\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          }\n        },\n        \"webRequest\": {\n          \"handlerBehaviorChanged\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 0\n          }\n        },\n        \"windows\": {\n          \"create\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"get\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 2\n          },\n          \"getAll\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"getCurrent\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"getLastFocused\": {\n            \"minArgs\": 0,\n            \"maxArgs\": 1\n          },\n          \"remove\": {\n            \"minArgs\": 1,\n            \"maxArgs\": 1\n          },\n          \"update\": {\n            \"minArgs\": 2,\n            \"maxArgs\": 2\n          }\n        }\n      };\n\n      if (Object.keys(apiMetadata).length === 0) {\n        throw new Error(\"api-metadata.json has not been included in browser-polyfill\");\n      }\n\n      /**\n       * A WeakMap subclass which creates and stores a value for any key which does\n       * not exist when accessed, but behaves exactly as an ordinary WeakMap\n       * otherwise.\n       *\n       * @param {function} createItem\n       *        A function which will be called in order to create the value for any\n       *        key which does not exist, the first time it is accessed. The\n       *        function receives, as its only argument, the key being created.\n       */\n      class DefaultWeakMap extends WeakMap {\n        constructor(createItem, items = undefined) {\n          super(items);\n          this.createItem = createItem;\n        }\n\n        get(key) {\n          if (!this.has(key)) {\n            this.set(key, this.createItem(key));\n          }\n\n          return super.get(key);\n        }\n      }\n\n      /**\n       * Returns true if the given object is an object with a `then` method, and can\n       * therefore be assumed to behave as a Promise.\n       *\n       * @param {*} value The value to test.\n       * @returns {boolean} True if the value is thenable.\n       */\n      const isThenable = value => {\n        return value && typeof value === \"object\" && typeof value.then === \"function\";\n      };\n\n      /**\n       * Creates and returns a function which, when called, will resolve or reject\n       * the given promise based on how it is called:\n       *\n       * - If, when called, `chrome.runtime.lastError` contains a non-null object,\n       *   the promise is rejected with that value.\n       * - If the function is called with exactly one argument, the promise is\n       *   resolved to that value.\n       * - Otherwise, the promise is resolved to an array containing all of the\n       *   function's arguments.\n       *\n       * @param {object} promise\n       *        An object containing the resolution and rejection functions of a\n       *        promise.\n       * @param {function} promise.resolve\n       *        The promise's resolution function.\n       * @param {function} promise.rejection\n       *        The promise's rejection function.\n       * @param {object} metadata\n       *        Metadata about the wrapped method which has created the callback.\n       * @param {integer} metadata.maxResolvedArgs\n       *        The maximum number of arguments which may be passed to the\n       *        callback created by the wrapped async function.\n       *\n       * @returns {function}\n       *        The generated callback function.\n       */\n      const makeCallback = (promise, metadata) => {\n        return (...callbackArgs) => {\n          if (chrome.runtime.lastError) {\n            promise.reject(chrome.runtime.lastError);\n          } else if (metadata.singleCallbackArg || callbackArgs.length <= 1) {\n            promise.resolve(callbackArgs[0]);\n          } else {\n            promise.resolve(callbackArgs);\n          }\n        };\n      };\n\n      const pluralizeArguments = numArgs => numArgs == 1 ? \"argument\" : \"arguments\";\n\n      /**\n       * Creates a wrapper function for a method with the given name and metadata.\n       *\n       * @param {string} name\n       *        The name of the method which is being wrapped.\n       * @param {object} metadata\n       *        Metadata about the method being wrapped.\n       * @param {integer} metadata.minArgs\n       *        The minimum number of arguments which must be passed to the\n       *        function. If called with fewer than this number of arguments, the\n       *        wrapper will raise an exception.\n       * @param {integer} metadata.maxArgs\n       *        The maximum number of arguments which may be passed to the\n       *        function. If called with more than this number of arguments, the\n       *        wrapper will raise an exception.\n       * @param {integer} metadata.maxResolvedArgs\n       *        The maximum number of arguments which may be passed to the\n       *        callback created by the wrapped async function.\n       *\n       * @returns {function(object, ...*)}\n       *       The generated wrapper function.\n       */\n      const wrapAsyncFunction = (name, metadata) => {\n        return function asyncFunctionWrapper(target, ...args) {\n          if (args.length < metadata.minArgs) {\n            throw new Error(`Expected at least ${metadata.minArgs} ${pluralizeArguments(metadata.minArgs)} for ${name}(), got ${args.length}`);\n          }\n\n          if (args.length > metadata.maxArgs) {\n            throw new Error(`Expected at most ${metadata.maxArgs} ${pluralizeArguments(metadata.maxArgs)} for ${name}(), got ${args.length}`);\n          }\n\n          return new Promise((resolve, reject) => {\n            if (metadata.fallbackToNoCallback) {\n              // This API method has currently no callback on Chrome, but it return a promise on Firefox,\n              // and so the polyfill will try to call it with a callback first, and it will fallback\n              // to not passing the callback if the first call fails.\n              try {\n                target[name](...args, makeCallback({ resolve, reject }, metadata));\n              } catch (cbError) {\n                console.warn(`${name} API method doesn't seem to support the callback parameter, ` + \"falling back to call it without a callback: \", cbError);\n\n                target[name](...args);\n\n                // Update the API method metadata, so that the next API calls will not try to\n                // use the unsupported callback anymore.\n                metadata.fallbackToNoCallback = false;\n                metadata.noCallback = true;\n\n                resolve();\n              }\n            } else if (metadata.noCallback) {\n              target[name](...args);\n              resolve();\n            } else {\n              target[name](...args, makeCallback({ resolve, reject }, metadata));\n            }\n          });\n        };\n      };\n\n      /**\n       * Wraps an existing method of the target object, so that calls to it are\n       * intercepted by the given wrapper function. The wrapper function receives,\n       * as its first argument, the original `target` object, followed by each of\n       * the arguments passed to the original method.\n       *\n       * @param {object} target\n       *        The original target object that the wrapped method belongs to.\n       * @param {function} method\n       *        The method being wrapped. This is used as the target of the Proxy\n       *        object which is created to wrap the method.\n       * @param {function} wrapper\n       *        The wrapper function which is called in place of a direct invocation\n       *        of the wrapped method.\n       *\n       * @returns {Proxy<function>}\n       *        A Proxy object for the given method, which invokes the given wrapper\n       *        method in its place.\n       */\n      const wrapMethod = (target, method, wrapper) => {\n        return new Proxy(method, {\n          apply(targetMethod, thisObj, args) {\n            return wrapper.call(thisObj, target, ...args);\n          }\n        });\n      };\n\n      let hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty);\n\n      /**\n       * Wraps an object in a Proxy which intercepts and wraps certain methods\n       * based on the given `wrappers` and `metadata` objects.\n       *\n       * @param {object} target\n       *        The target object to wrap.\n       *\n       * @param {object} [wrappers = {}]\n       *        An object tree containing wrapper functions for special cases. Any\n       *        function present in this object tree is called in place of the\n       *        method in the same location in the `target` object tree. These\n       *        wrapper methods are invoked as described in {@see wrapMethod}.\n       *\n       * @param {object} [metadata = {}]\n       *        An object tree containing metadata used to automatically generate\n       *        Promise-based wrapper functions for asynchronous. Any function in\n       *        the `target` object tree which has a corresponding metadata object\n       *        in the same location in the `metadata` tree is replaced with an\n       *        automatically-generated wrapper function, as described in\n       *        {@see wrapAsyncFunction}\n       *\n       * @returns {Proxy<object>}\n       */\n      const wrapObject = (target, wrappers = {}, metadata = {}) => {\n        let cache = Object.create(null);\n        let handlers = {\n          has(proxyTarget, prop) {\n            return prop in target || prop in cache;\n          },\n\n          get(proxyTarget, prop, receiver) {\n            if (prop in cache) {\n              return cache[prop];\n            }\n\n            if (!(prop in target)) {\n              return undefined;\n            }\n\n            let value = target[prop];\n\n            if (typeof value === \"function\") {\n              // This is a method on the underlying object. Check if we need to do\n              // any wrapping.\n\n              if (typeof wrappers[prop] === \"function\") {\n                // We have a special-case wrapper for this method.\n                value = wrapMethod(target, target[prop], wrappers[prop]);\n              } else if (hasOwnProperty(metadata, prop)) {\n                // This is an async method that we have metadata for. Create a\n                // Promise wrapper for it.\n                let wrapper = wrapAsyncFunction(prop, metadata[prop]);\n                value = wrapMethod(target, target[prop], wrapper);\n              } else {\n                // This is a method that we don't know or care about. Return the\n                // original method, bound to the underlying object.\n                value = value.bind(target);\n              }\n            } else if (typeof value === \"object\" && value !== null && (hasOwnProperty(wrappers, prop) || hasOwnProperty(metadata, prop))) {\n              // This is an object that we need to do some wrapping for the children\n              // of. Create a sub-object wrapper for it with the appropriate child\n              // metadata.\n              value = wrapObject(value, wrappers[prop], metadata[prop]);\n            } else {\n              // We don't need to do any wrapping for this property,\n              // so just forward all access to the underlying object.\n              Object.defineProperty(cache, prop, {\n                configurable: true,\n                enumerable: true,\n                get() {\n                  return target[prop];\n                },\n                set(value) {\n                  target[prop] = value;\n                }\n              });\n\n              return value;\n            }\n\n            cache[prop] = value;\n            return value;\n          },\n\n          set(proxyTarget, prop, value, receiver) {\n            if (prop in cache) {\n              cache[prop] = value;\n            } else {\n              target[prop] = value;\n            }\n            return true;\n          },\n\n          defineProperty(proxyTarget, prop, desc) {\n            return Reflect.defineProperty(cache, prop, desc);\n          },\n\n          deleteProperty(proxyTarget, prop) {\n            return Reflect.deleteProperty(cache, prop);\n          }\n        };\n\n        // Per contract of the Proxy API, the \"get\" proxy handler must return the\n        // original value of the target if that value is declared read-only and\n        // non-configurable. For this reason, we create an object with the\n        // prototype set to `target` instead of using `target` directly.\n        // Otherwise we cannot return a custom object for APIs that\n        // are declared read-only and non-configurable, such as `chrome.devtools`.\n        //\n        // The proxy handlers themselves will still use the original `target`\n        // instead of the `proxyTarget`, so that the methods and properties are\n        // dereferenced via the original targets.\n        let proxyTarget = Object.create(target);\n        return new Proxy(proxyTarget, handlers);\n      };\n\n      /**\n       * Creates a set of wrapper functions for an event object, which handles\n       * wrapping of listener functions that those messages are passed.\n       *\n       * A single wrapper is created for each listener function, and stored in a\n       * map. Subsequent calls to `addListener`, `hasListener`, or `removeListener`\n       * retrieve the original wrapper, so that  attempts to remove a\n       * previously-added listener work as expected.\n       *\n       * @param {DefaultWeakMap<function, function>} wrapperMap\n       *        A DefaultWeakMap object which will create the appropriate wrapper\n       *        for a given listener function when one does not exist, and retrieve\n       *        an existing one when it does.\n       *\n       * @returns {object}\n       */\n      const wrapEvent = wrapperMap => ({\n        addListener(target, listener, ...args) {\n          target.addListener(wrapperMap.get(listener), ...args);\n        },\n\n        hasListener(target, listener) {\n          return target.hasListener(wrapperMap.get(listener));\n        },\n\n        removeListener(target, listener) {\n          target.removeListener(wrapperMap.get(listener));\n        }\n      });\n\n      // Keep track if the deprecation warning has been logged at least once.\n      let loggedSendResponseDeprecationWarning = false;\n\n      const onMessageWrappers = new DefaultWeakMap(listener => {\n        if (typeof listener !== \"function\") {\n          return listener;\n        }\n\n        /**\n         * Wraps a message listener function so that it may send responses based on\n         * its return value, rather than by returning a sentinel value and calling a\n         * callback. If the listener function returns a Promise, the response is\n         * sent when the promise either resolves or rejects.\n         *\n         * @param {*} message\n         *        The message sent by the other end of the channel.\n         * @param {object} sender\n         *        Details about the sender of the message.\n         * @param {function(*)} sendResponse\n         *        A callback which, when called with an arbitrary argument, sends\n         *        that value as a response.\n         * @returns {boolean}\n         *        True if the wrapped listener returned a Promise, which will later\n         *        yield a response. False otherwise.\n         */\n        return function onMessage(message, sender, sendResponse) {\n          let didCallSendResponse = false;\n\n          let wrappedSendResponse;\n          let sendResponsePromise = new Promise(resolve => {\n            wrappedSendResponse = function (response) {\n              if (!loggedSendResponseDeprecationWarning) {\n                console.warn(SEND_RESPONSE_DEPRECATION_WARNING, new Error().stack);\n                loggedSendResponseDeprecationWarning = true;\n              }\n              didCallSendResponse = true;\n              resolve(response);\n            };\n          });\n\n          let result;\n          try {\n            result = listener(message, sender, wrappedSendResponse);\n          } catch (err) {\n            result = Promise.reject(err);\n          }\n\n          const isResultThenable = result !== true && isThenable(result);\n\n          // If the listener didn't returned true or a Promise, or called\n          // wrappedSendResponse synchronously, we can exit earlier\n          // because there will be no response sent from this listener.\n          if (result !== true && !isResultThenable && !didCallSendResponse) {\n            return false;\n          }\n\n          // A small helper to send the message if the promise resolves\n          // and an error if the promise rejects (a wrapped sendMessage has\n          // to translate the message into a resolved promise or a rejected\n          // promise).\n          const sendPromisedResult = promise => {\n            promise.then(msg => {\n              // send the message value.\n              sendResponse(msg);\n            }, error => {\n              // Send a JSON representation of the error if the rejected value\n              // is an instance of error, or the object itself otherwise.\n              let message;\n              if (error && (error instanceof Error || typeof error.message === \"string\")) {\n                message = error.message;\n              } else {\n                message = \"An unexpected error occurred\";\n              }\n\n              sendResponse({\n                __mozWebExtensionPolyfillReject__: true,\n                message\n              });\n            }).catch(err => {\n              // Print an error on the console if unable to send the response.\n              console.error(\"Failed to send onMessage rejected reply\", err);\n            });\n          };\n\n          // If the listener returned a Promise, send the resolved value as a\n          // result, otherwise wait the promise related to the wrappedSendResponse\n          // callback to resolve and send it as a response.\n          if (isResultThenable) {\n            sendPromisedResult(result);\n          } else {\n            sendPromisedResult(sendResponsePromise);\n          }\n\n          // Let Chrome know that the listener is replying.\n          return true;\n        };\n      });\n\n      const wrappedSendMessageCallback = ({ reject, resolve }, reply) => {\n        if (chrome.runtime.lastError) {\n          // Detect when none of the listeners replied to the sendMessage call and resolve\n          // the promise to undefined as in Firefox.\n          // See https://github.com/mozilla/webextension-polyfill/issues/130\n          if (chrome.runtime.lastError.message === CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE) {\n            resolve();\n          } else {\n            reject(chrome.runtime.lastError);\n          }\n        } else if (reply && reply.__mozWebExtensionPolyfillReject__) {\n          // Convert back the JSON representation of the error into\n          // an Error instance.\n          reject(new Error(reply.message));\n        } else {\n          resolve(reply);\n        }\n      };\n\n      const wrappedSendMessage = (name, metadata, apiNamespaceObj, ...args) => {\n        if (args.length < metadata.minArgs) {\n          throw new Error(`Expected at least ${metadata.minArgs} ${pluralizeArguments(metadata.minArgs)} for ${name}(), got ${args.length}`);\n        }\n\n        if (args.length > metadata.maxArgs) {\n          throw new Error(`Expected at most ${metadata.maxArgs} ${pluralizeArguments(metadata.maxArgs)} for ${name}(), got ${args.length}`);\n        }\n\n        return new Promise((resolve, reject) => {\n          const wrappedCb = wrappedSendMessageCallback.bind(null, { resolve, reject });\n          args.push(wrappedCb);\n          apiNamespaceObj.sendMessage(...args);\n        });\n      };\n\n      const staticWrappers = {\n        runtime: {\n          onMessage: wrapEvent(onMessageWrappers),\n          onMessageExternal: wrapEvent(onMessageWrappers),\n          sendMessage: wrappedSendMessage.bind(null, \"sendMessage\", { minArgs: 1, maxArgs: 3 })\n        },\n        tabs: {\n          sendMessage: wrappedSendMessage.bind(null, \"sendMessage\", { minArgs: 2, maxArgs: 3 })\n        }\n      };\n      const settingMetadata = {\n        clear: { minArgs: 1, maxArgs: 1 },\n        get: { minArgs: 1, maxArgs: 1 },\n        set: { minArgs: 1, maxArgs: 1 }\n      };\n      apiMetadata.privacy = {\n        network: {\n          networkPredictionEnabled: settingMetadata,\n          webRTCIPHandlingPolicy: settingMetadata\n        },\n        services: {\n          passwordSavingEnabled: settingMetadata\n        },\n        websites: {\n          hyperlinkAuditingEnabled: settingMetadata,\n          referrersEnabled: settingMetadata\n        }\n      };\n\n      return wrapObject(chrome, staticWrappers, apiMetadata);\n    };\n\n    // The build process adds a UMD wrapper around this file, which makes the\n    // `module` variable available.\n    module.exports = wrapAPIs(); // eslint-disable-line no-undef\n  } else {\n    module.exports = browser; // eslint-disable-line no-undef\n  }\n});\n//# sourceMappingURL=browser-polyfill.js.map\n\n\n//# sourceURL=webpack:///../node_modules/webextension-polyfill/dist/browser-polyfill.js?");

/***/ }),

/***/ "./core.js":
/*!*****************!*\
  !*** ./core.js ***!
  \*****************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("window.browser = __webpack_require__(/*! webextension-polyfill */ \"../node_modules/webextension-polyfill/dist/browser-polyfill.js\");\nconst commModel = document.createElement('style');\nconst commCss = `div.memos{ column-count: 3;column-gap: 0;height:unset!important;display:block!important;flex-direction:unset!important} .memo{break-inside: avoid; box-sizing: border-box; padding: 10px;padding: 10px;}.el-container{max-width:none!important} .tags{max-height:calc(100% - 420px);overflow-y:auto}  .el-aside{background:white} .editor-content .ProseMirror{min-height:80px!important}  @media(min-width: 1200px) { div.memos { column-count: 4; } }  @media (max-width: 767px) and (max-width: 1100px) { div.memos { column-count: 1; } } \n\n`;\ncommModel.type = 'text/css';\ncommModel.innerText = commCss;\ncommModel.id = 'commModel';\n\nfunction inject() {\n  var file = chrome.extension.getURL('notify.js');\n  var s = document.createElement('script');\n  s.type = 'text/javascript';\n  s.src = file;\n  document.head.appendChild(s);\n}\n\nfunction getTagContentCount() {\n  const memos = document.querySelectorAll('.memo');\n\n  if (memos) {\n    for (let i = 0; i < memos.length; i++) {\n      const memoFontCountDom = document.createElement('span');\n      memoFontCountDom.style = 'text-align:right;font-size:12px;color:gray;float: left;margin-right:10px';\n      memoFontCountDom.className = 'memoContentCount';\n\n      if (memos[i].querySelector('.content')) {\n        memoFontCountDom.innerText = `${memos[i].querySelector('.content').textContent.length}字`;\n\n        if (!memos[i].querySelector('.memoContentCount')) {\n          memos[i].querySelector('.display .header .tools').append(memoFontCountDom);\n        }\n      }\n    }\n  }\n}\n\nfunction removeAllTagCount() {\n  const memos = document.querySelectorAll('.memo');\n\n  if (memos) {\n    for (let i = 0; i < memos.length; i++) {\n      const memoFontCountDom = document.createElement('span');\n      memoFontCountDom.style = 'text-align:right;font-size:12px;color:gray;float: left;margin-right:10px';\n      memoFontCountDom.className = 'memoContentCount';\n\n      if (memos[i].querySelector('.content')) {\n        memoFontCountDom.innerText = `${memos[i].querySelector('.content').textContent.length}字`;\n\n        if (memos[i].querySelector('.memoContentCount')) {\n          memos[i].querySelector('.memoContentCount').remove();\n        }\n      }\n    }\n  }\n}\n\nfunction getAllTagClick() {\n  var lis = document.getElementsByTagName('li');\n\n  for (var i = 0; i < lis.length; i++) {\n    (function (i) {\n      lis[i].addEventListener('click', function () {\n        setTimeout(() => {\n          getTagContentCount();\n        }, 1500);\n      }, false);\n    })(i);\n  }\n}\n\nfunction getTagCount() {\n  if (document.getElementById('sidebar').getElementsByTagName('h3')) {\n    const rightTags = document.getElementById('sidebar').getElementsByTagName('h3');\n\n    for (let i = 0; i < rightTags.length; i++) {\n      const content = rightTags[i].textContent;\n\n      if (content == '置顶') {\n        rightTags[i].textContent = content + ' ( ' + document.getElementsByClassName('tags')[i].children.length + ' ) ';\n      }\n\n      if (content == '标签') {\n        rightTags[i].textContent = content + ' ( ' + document.getElementsByClassName('tags')[i].children.length + ' ) ';\n      }\n    }\n  }\n}\n\nfunction removeTagCount() {\n  if (document.getElementById('sidebar').getElementsByTagName('h3')) {\n    const rightTags = document.getElementById('sidebar').getElementsByTagName('h3');\n\n    for (let i = 0; i < rightTags.length; i++) {\n      const content = rightTags[i].textContent;\n\n      if (content.indexOf('置顶') > -1) {\n        rightTags[i].textContent = '置顶';\n      }\n\n      if (content.indexOf('标签') > -1) {\n        rightTags[i].textContent = '标签';\n      }\n    }\n  }\n}\n\nfunction insertSolarizedTheme() {\n  const css = `\n  .el-button--primary,\n.el-input--suffix,\n.el-input__inner {\n    border-radius: 20px !important;\n}\n\n.el-button--primary {\n    background-color: #424e53;\n    border: none;\n}\n\n.el-button--primary:hover {\n    background-color: #545d61;\n    border: none;\n}\n\n\n.el-input--suffix,\n.el-input__inner {\n    background: #fffcf7 !important;\n}\n\n/* editor */\nul li.selected,\nul li.selected > div,\nul li:hover,\nul li > div:hover,\ndiv.topbar .el-input.search .el-input__inner,\ndiv.content span.tag {\n    border-radius: 20px !important;\n}\nul li > div:hover {\n    background: #f2ebd4 !important;\n}\n\nul li.selected,\nul li.selected > div {\n    background: #5c6d74 !important;\n}\n\nul li.selected ul li div span {\n    color: #b0a6a6 !important;\n}\n\nhtml,\nbody {\n    background: rgb(252, 246, 229);\n    color: #3f4e54 !important;\n}\n\n\n.el-aside {\n    overflow: visible !important;\n}\n\n.stat .grid {\n    padding: 10px !important;\n}\n.stat .grid .day {\n    background: #d2d2d2 !important;\n    border-radius: 20px !important;\n}\n\n.stat .grid .day.green {\n    background: #3f4e54 !important;\n    border-radius: 6px;\n}\n\n.stat .grid:hover {\n    box-shadow: 0px 2px 16px #DDDDDD;\n    border-radius: 6px;\n}\n\n.stat .grid .day.today {\n    border-color: #5c6d74 !important;\n}\n#sidebar h3 {\n    color: #5c6d74 !important;\n    font-weight: 800;\n    font-size: 1em;\n}\n\n.stat .datas .data .number {\n    color: #424e53 !important;\n}\n.stat .datas .data .type {\n    font-size: 8px !important;\n}\n\ndiv.topbar .el-input.search .el-input__inner {\n    background: #f7eedd !important;\n}\n.el-input.is-active .el-input__inner,\n.el-input__inner:focus {\n    border-color: #5c6d74;\n}\n\ndiv.memo div.card,\n.editor-content,\ndiv.editor-menu-bar {\n    background: #fff9ef !important;\n}\n\ndiv.editor-menu-bar .submit-btn {\n    background: #5c6d74 !important;\n    border: none;\n    border-radius: 20px;\n}\n\ndiv.editor-menu-bar .submit-btn:hover {\n    background: #424e53 !important;\n}\n\ndiv.content span.tag {\n    background-color: #f7eedd !important;\n    color: #a4772d !important;\n}\n\ndiv.topbar {\n    padding: 12px 10px 0 !important;\n}\ndiv.input {\n    padding: 0 16px 10px !important;\n}\n\ndiv.content label.highlight {\n    background: #f0c859 !important;\n    color: #424e53 !important;\n    padding: 4px 6px !important;\n}\n\ndiv.content {\n    padding: 10px 0 !important;\n}\n  `;\n  const style = document.createElement('style');\n  style.type = 'text/css';\n  style.innerText = css;\n  style.id = 'SolarizedModel';\n\n  if (!document.getElementById('SolarizedModel')) {\n    document.head.appendChild(style);\n  }\n}\n\nfunction setTheme(isDark) {\n  const darkCss = 'body{  background: #202124!important; } .flomoPlus-tool,.flomo-themeBox {  background: #000000!important; } .flomo-themeItem-action{color:lightseagreen!important} .flomo-themeItem:hover{background: #2e2e2e!important;} .flomo-themeItem{color:gray !important}.flomoPlus-tool,.flomo-themeBox {box-shadow:0px 2px 16px #222222!important}.flomoPlus-tool .active{color:white!important} .flomoPlus-tool i:hover{color:lightgray!important} .girdIcon{color:gray!important;} .el-loading-mask{background-color:#202124!important} .memo{border:none!important;} .memo:hover { box-shadow: unset!important;} .memo,div.card,.editor-content,div.editor-menu-bar,div.input-box, .el-input__inner,.el-message-box,.reply-card{background:#2e2e2e!important;} div.content,div.editor-menu-bar .submit-btn:disabled{color:#9D9D9D!important;}  .submit-btn{color:#ffffff!important;} div.memo div.card:hover,div.reply div.reply-card:hover{box-shadow:none!important} div.input-box,.files img{border:none!important;} ::-webkit-scrollbar{background: #252729!important;width:5px} ::-webkit-scrollbar-thumb{background:#666666;border-radius:5px;}.editor-content{color:#fff!important;}.notify,.iwh,.referral{background:#2e2e2e!important} div.content span.tag{background-color:#6f7174!important;color:#000000!important; padding: 4px;ont-size: 12px;border-radius: 3px;} ul li.tag > div:hover,.stat .grid .day{background:#2E2E2E!important} ul li.selected,ul li.tag.selected > div,div.editor-menu-bar .submit-btn{background:#395345!important} .el-col .tag,.el-popover,.el-drawer ,div.thread{background:#292929!important} .el-col .tag .name,.iwh h3,.iwh p,.el-message-box__title{color:gray!important} .el-popover{border:1px solid #292929!important} .el-popper[x-placement^=bottom] .popper__arrow::after{border-bottom-color:#292929!important} .tag:hover{box-shadow:0px 2px 16px #292929!important} .stat .grid .day.light_green{background:#475446!important} .stat .grid .day.green{background:#5D795C!important} .stat .grid .day.dark_green{background:#79AF77!important} div.editor-menu-bar .submit-btn{border-color: #395345!important;} .el-message-box{border:1px solid #292929!important}.referral h3{color:lightgray!important;}div.tasks p.task{color:#8f9193!important;} .plan ul.features li,.el-popover h4,.block h3,.block p{color:lightgray!important;}.plan,.block{background:#2e2e2e!important}.link a{color: wheat !important;}.el-dialog.share-dialog {    background: #292929!important;} .tips p,.el-dialog__title{color:gray!important;} div.content strong{color:lightgray!important;}ul li.tag.selected{border-radius:5px!important;} div.card,.memo{border-radius: 6px!important;}';\n  const darkModel = document.createElement('style');\n  const btnModel = document.createElement('style');\n  const btnCss = `\n  // .theme{position: fixed;bottom: 40px;right: 90px;} \n  // .girdBtn{position: fixed;bottom: 40px;right: 140px;}\n  // .editBtn{position: fixed;bottom: 40px;right: 190px;}\n  .js-snackbar-container {\n    position: absolute;\n    bottom: 0;\n    right: 0;\n    display: flex;\n    flex-direction: column;\n    align-items: flex-end;\n    max-width: 100%;\n    padding: 10px;\n    overflow: hidden;\n}\n\n.js-snackbar-container * {\n    box-sizing: border-box;\n}\n\n.js-snackbar__wrapper {\n    overflow: hidden;\n    height: auto;\n    margin: 5px 0;\n    transition: all ease .5s;\n    border-radius: 3px;\n    box-shadow: 0 0 4px 0 black;\n}\n\n.js-snackbar {\n    display: inline-flex;\n    box-sizing: border-box;\n    border-radius: 3px;\n    color: #eee;\n    font-size: 16px;\n    background-color: #262626;\n    vertical-align: bottom;\n}\n\n.js-snackbar__close,\n.js-snackbar__status,\n.js-snackbar__message {\n    position: relative;\n}\n\n.js-snackbar__message {\n    padding: 12px;\n}\n\n.js-snackbar__status {\n    display: none;\n    width: 15px;\n    margin-right: 5px;\n    border-radius: 3px 0 0 3px;\n    background-color: transparent;\n}\n\n .js-snackbar__status.js-snackbar--success,\n .js-snackbar__status.js-snackbar--warning,\n .js-snackbar__status.js-snackbar--danger,\n .js-snackbar__status.js-snackbar--info {\n    display: block;\n}\n\n.js-snackbar__status.js-snackbar--success  {\n    background-color: #4caf50;\n}\n\n.js-snackbar__status.js-snackbar--warning  {\n    background-color: #ff9800;\n}\n\n .js-snackbar__status.js-snackbar--danger {\n    background-color: #b90909;\n}\n\n .js-snackbar__status.js-snackbar--info {\n    background-color: #2196f3;\n}\n\n.js-snackbar__close {\n    cursor: pointer;\n    display: flex;\n    align-items: center;\n    padding: 0 10px;\n    user-select: none;\n}\n\n.js-snackbar__close:hover {\n    background-color: #444;\n}\n#mySelect{\n  background-color: #fff;\n  background-image: none;\n  border-radius: 4px;\n  border: 1px solid #dcdfe6;\n  box-sizing: border-box;\n  color: #606266;\n  display: inline-block;\n  font-size: inherit;\n  height: 33px;\n  line-height: 33px;\n  outline: none;\n  padding: 0 0px;\n  transition: border-color .2s cubic-bezier(.645,.045,.355,1);\n  font-size: 14px;\n}\n.settingBox{\n  width: 324px;\n  background: #fff;\n  box-shadow: rgb(0 0 0 / 35%) 0 6px 100px 0;\n  height: 253px;\n  position: fixed;\n  bottom: 101px;\n  right: 35px;\n  border-radius: 10px;\n  animation: fade-in;/*动画名称*/\n  animation-duration: 0.5s;/*动画持续时间*/\n  -webkit-animation:fade-in 0.5s;/*针对webkit内核*/\n}\n\n@keyframes fade-in {\n  0% {opacity: 0;}/*初始状态 透明度为0*/\n  40% {opacity: 0;}/*过渡状态 透明度为0*/\n  100% {opacity: 1;}/*结束状态 透明度为1*/\n  }\n  .enterBox{\n    position: absolute;\n    bottom: -30px;\n    right: 0px;\n    border: 1px solid #E8E8E8;\n    z-index: 9999;\n    background: #fff;\n    border-radius: 5px;\n    display:none\n  }\n  #tipsBtn{\n    right: 66px;\n    position: absolute;\n    top: -5px;\n    color: gray;\n  }\n  .idLabel{\n    margin-left:10px;\n  }\n  .girdIcon{\n    cursor:pointer;\n  }\n  .flomoPlus-tool{\n    position: fixed;\n    bottom: 40px;\n    right: 40px;\n    box-shadow: 0px 2px 16px #dddddd;\n    background:#ffffff;\n    border-radius: 10px;\n    color: gray;\n  }\n  .help{\n    display:none!important;\n  }\n  .flomoPlus-tool i{\n    font-size: 20px;\n    cursor:pointer;\n    padding: 10px;\n  }\n\n  .flomoPlus-tool i:hover{\n    // box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);\n    color:blue\n  }\n  .flomoPlus-tool .active{\n    color:#000000;\n  }\n  .fullscreen .el-aside{\n    display:none;\n  }\n  .fullscreen .memos{\n    display:none!important;\n  }\n  .fullscreen .topbar{\n    display:none!important;\n  }\n  .fullscreen .input{\n    margin-top:10vh;\n  }\n\n .isGird .memos .memo{\n    width: 49%;\n    // border: 1px solid #eee;\n    box-sizing: border-box;\n    color: #fff;\n    background: white;\n    border-radius: 6px;\n  }\n  .isGird div.memo div.card:hover {\n    box-shadow: unset!important;\n  }\n  .isGird .memo:hover {\n    box-shadow: 0px 2px 16px #dddddd;\n  }\n  .isGird div.memos{\n    flex-wrap: wrap;\n    flex-direction:unset!important;\n    justify-content: space-between;\n   \n  }\n  .isGird .el-container{\n    max-width:unset!important;\n  }\n\n  .flomo-themeBox{\n    outline: 0;\n    position: absolute;\n    width: 200px;\n    bottom: 90px;\n    right: 40px;\n    box-shadow: 0px 2px 16px #dddddd;\n    background: #ffffff;\n    border-radius: 10px;\n    overflow:hidden;\n  }\n\n  .flomo-themeItem{\n    padding:10px;\n    display:flex;\n  }\n  .flomo-themeItem:hover{\n    background: #EFEFEF;\n  }\n\n  .flomo-themeItem span{\n    flex:1;\n    text-align: left;\n    font-size:13px;\n  }\n  .flomo-themeItem-action{\n    color:blue;\n    text-align:right!important;\n    cursor:pointer;\n  }\n\n  `;\n  const noteStyle = `body{background:#77695d!important}`;\n  btnModel.type = 'text/css';\n  btnModel.innerText = btnCss;\n  btnModel.id = 'btnModel';\n  darkModel.type = 'text/css';\n  darkModel.innerText = darkCss;\n  darkModel.id = 'darkModel'; // 新增newBtn\n\n  const newBtn = document.createElement('DIV');\n  newBtn.className = 'flomoPlus-tool';\n  newBtn.id = 'flomoPlus-tool';\n  const t = document.createElement('i');\n  t.className = 'el-icon-moon';\n  t.id = 'darkBtn';\n  const d = document.createElement('i');\n  d.className = 'el-icon-full-screen';\n  d.id = 'fullscreen';\n  const c = document.createElement('i');\n  c.className = 'el-icon-ice-cream-round';\n  c.id = 'labBtn';\n  const g = document.createElement('i');\n  g.className = 'el-icon-menu';\n  g.id = 'girdMenuBtn';\n  const h = document.createElement('i');\n  h.className = 'el-icon-d-arrow-right';\n  h.id = 'hideFlomoPlus';\n  const ct = document.createElement('i');\n  ct.className = 'el-icon-cherry';\n  ct.id = 'checkTheme';\n  newBtn.appendChild(ct); // newBtn.appendChild(t);\n\n  newBtn.appendChild(d);\n  newBtn.appendChild(c);\n  newBtn.appendChild(g);\n  newBtn.appendChild(h);\n\n  ct.onclick = function () {\n    if (document.querySelector('.flomo-themeBox').style.display == 'none') {\n      document.querySelector('.flomo-themeBox').style.display = 'block';\n    } else {\n      document.querySelector('.flomo-themeBox').style.display = 'none';\n    }\n  };\n\n  h.onclick = function (e) {\n    if (newBtn.classList.contains('active')) {\n      newBtn.className = 'flomoPlus-tool';\n      t.style.display = 'inline-block';\n      d.style.display = 'inline-block';\n      c.style.display = 'inline-block';\n      g.style.display = 'inline-block';\n      ct.style.display = 'inline-block';\n      h.className = 'el-icon-d-arrow-right';\n    } else {\n      newBtn.className = newBtn.className + ' active';\n      t.style.display = 'none';\n      d.style.display = 'none';\n      c.style.display = 'none';\n      g.style.display = 'none';\n      ct.style.display = 'none';\n      h.className = 'el-icon-d-arrow-left';\n\n      if (document.querySelector('.flomo-themeBox')) {\n        document.querySelector('.flomo-themeBox').style.display = 'none';\n      }\n    }\n  }; // theme box\n\n\n  const themeBox = document.createElement('DIV');\n  themeBox.className = 'flomo-themeBox';\n  themeBox.style.display = 'none';\n  themeBox.innerHTML = '<div class=\"flomo-themeItem\"><span>暗黑模式</span><span class=\"flomo-themeItem-action darkAction\">开启</span></div><div class=\"flomo-themeItem\" title=\"Solarized Light by sherlock1990\"><span >Solarized Light</span><span class=\"flomo-themeItem-action solarizedAction\">开启</span></div>';\n  let theme = document.getElementById('theme');\n  let gird = document.getElementById('girdBtn');\n  let darkBtn = document.getElementById('darkBtn');\n  let labBtn = document.getElementById('labBtn');\n  let fullscreenBtn = document.getElementById('fullscreen');\n  let edit = document.getElementById('editBtn');\n  const editBtn = document.createElement('BUTTON');\n  editBtn.className = 'el-button help is-circle editBtn  ';\n  editBtn.id = 'editBtn';\n  const b = document.createElement('i');\n  b.className = 'el-icon-edit';\n  b.title = '撰写memo';\n  editBtn.appendChild(b);\n\n  if (window.location.host == 'flomoapp.com') {\n    h.click();\n    document.getElementsByClassName('el-main')[0].append(themeBox);\n\n    if (!document.getElementById('btnModel')) {\n      document.head.appendChild(btnModel);\n    }\n\n    if (!document.getElementById('flomoPlus-tool')) {\n      // 添加主题btn\n      // document.getElementsByClassName('el-main')[0].append(themeBtn);\n      document.getElementsByClassName('el-main')[0].append(newBtn);\n    }\n\n    if (!document.getElementById('girdBtn')) {// document.getElementsByClassName('el-main')[0].append(girdBtn);\n    } // if (!document.getElementById('editBtn')) {\n    //   document.getElementsByClassName('el-main')[0].append(editBtn);\n    // }\n\n\n    if (isDark) {\n      if (!document.getElementById('darkModel')) {\n        document.head.appendChild(darkModel);\n      }\n\n      window.localStorage.setItem('theme', 'dark');\n\n      if (theme) {\n        if (theme.querySelector('.el-icon-moon')) {\n          theme.querySelector('.el-icon-moon').className = 'el-icon-sunny';\n          theme.querySelector('.el-icon-sunny').title = '关闭黑暗模式';\n        }\n      }\n    } else if (document.getElementById('darkModel')) {\n      document.getElementById('darkModel').remove();\n      window.localStorage.setItem('theme', 'light');\n\n      if (theme) {\n        if (theme.querySelector('.el-icon-sunny')) {\n          theme.querySelector('.el-icon-sunny').className = 'el-icon-moon';\n          theme.querySelector('.el-icon-moon').title = '开启黑暗模式';\n        }\n      }\n    }\n\n    if (window.localStorage.getItem('isLab') == 1) {\n      // document.head.appendChild(commModel);\n      let labBtn = document.getElementById('labBtn');\n\n      if (labBtn) {\n        labBtn.className = 'el-icon-ice-cream-round active';\n      }\n\n      setTimeout(() => {\n        getTagCount();\n        getTagContentCount();\n        getAllTagClick();\n      }, 1500);\n    } else {\n      // if (document.getElementById('commModel')) {\n      //   document.getElementById('commModel').remove();\n      // }\n      let labBtn = document.getElementById('labBtn');\n\n      if (labBtn) {\n        labBtn.className = 'el-icon-ice-cream-round';\n      }\n\n      setTimeout(() => {\n        removeTagCount();\n      }, 1000);\n    }\n  }\n}\n\nfunction SnackBar(userOptions) {\n  var snackbar = this;\n\n  var _Interval;\n\n  var _Message;\n\n  var _Element;\n\n  var _Container;\n\n  var _OptionDefaults = {\n    message: 'Operation performed successfully.',\n    dismissible: true,\n    timeout: 1000,\n    status: ''\n  };\n  var _Options = _OptionDefaults;\n\n  function _Create() {\n    _Container = document.getElementsByClassName('js-snackbar-container')[0];\n\n    if (!_Container) {\n      // need to create a new container for notifications\n      _Container = document.createElement('div');\n\n      _Container.classList.add('js-snackbar-container');\n\n      document.body.appendChild(_Container);\n    }\n\n    _Element = document.createElement('div');\n\n    _Element.classList.add('js-snackbar__wrapper');\n\n    let innerSnack = document.createElement('div');\n    innerSnack.classList.add('js-snackbar', 'js-snackbar--show');\n\n    if (_Options.status) {\n      _Options.status = _Options.status.toLowerCase().trim();\n      let status = document.createElement('span');\n      status.classList.add('js-snackbar__status');\n\n      if (_Options.status === 'success' || _Options.status === 'green') {\n        status.classList.add('js-snackbar--success');\n      } else if (_Options.status === 'warning' || _Options.status === 'alert' || _Options.status === 'orange') {\n        status.classList.add('js-snackbar--warning');\n      } else if (_Options.status === 'danger' || _Options.status === 'error' || _Options.status === 'red') {\n        status.classList.add('js-snackbar--danger');\n      } else {\n        status.classList.add('js-snackbar--info');\n      }\n\n      innerSnack.appendChild(status);\n    }\n\n    _Message = document.createElement('span');\n\n    _Message.classList.add('js-snackbar__message');\n\n    _Message.textContent = _Options.message;\n    innerSnack.appendChild(_Message);\n\n    if (_Options.dismissible) {\n      let closeBtn = document.createElement('span');\n      closeBtn.classList.add('js-snackbar__close');\n      closeBtn.innerText = '\\u00D7';\n      closeBtn.onclick = Close;\n      innerSnack.appendChild(closeBtn);\n    }\n\n    _Element.style.height = '0px';\n    _Element.style.opacity = '0';\n    _Element.style.marginTop = '0px';\n    _Element.style.marginBottom = '0px';\n\n    _Element.appendChild(innerSnack);\n\n    _Container.appendChild(_Element);\n\n    if (_Options.timeout !== false) {\n      _Interval = setTimeout(Close, _Options.timeout);\n    }\n  }\n\n  var _ConfigureDefaults = function () {\n    // if no options given, revert to default\n    if (userOptions === undefined) {\n      return;\n    }\n\n    if (userOptions.message !== undefined) {\n      _Options.message = userOptions.message;\n    }\n\n    if (userOptions.dismissible !== undefined) {\n      if (typeof userOptions.dismissible === 'string') {\n        _Options.dismissible = userOptions.dismissible === 'true';\n      } else if (typeof userOptions.dismissible === 'boolean') {\n        _Options.dismissible = userOptions.dismissible;\n      } else {\n        console.debug(\"Invalid option provided for 'dismissable' [\" + userOptions.dismissible + '] is of type ' + typeof userOptions.dismissible);\n      }\n    }\n\n    if (userOptions.timeout !== undefined) {\n      if (typeof userOptions.timeout === 'boolean' && userOptions.timeout === false) {\n        _Options.timeout = false;\n      } else if (typeof userOptions.timeout === 'string') {\n        _Options.timeout = parseInt(userOptions.timeout);\n      }\n\n      if (typeof userOptions.timeout === 'number') {\n        if (userOptions.timeout === Infinity) {\n          _Options.timeout = false;\n        } else if (userOptions.timeout >= 0) {\n          _Options.timeout = userOptions.timeout;\n        } else {\n          console.debug('Invalid timeout entered. Must be greater than or equal to 0.');\n        }\n\n        _Options.timeout = userOptions.timeout;\n      }\n    }\n\n    if (userOptions.status !== undefined) {\n      _Options.status = userOptions.status;\n    }\n  };\n\n  this.Open = function () {\n    let contentHeight = _Element.firstElementChild.scrollHeight; // get the height of the content\n\n    _Element.style.height = contentHeight + 'px';\n    _Element.style.opacity = 1;\n    _Element.style.marginTop = '5px';\n    _Element.style.marginBottom = '5px';\n\n    _Element.addEventListener('transitioned', function () {\n      _Element.removeEventListener('transitioned', arguments.callee);\n\n      _Element.style.height = null;\n    });\n  };\n\n  this.Close = function () {\n    if (_Interval) clearInterval(_Interval);\n    let snackbarHeight = _Element.scrollHeight; // get the auto height as a px value\n\n    let snackbarTransitions = _Element.style.transition;\n    _Element.style.transition = '';\n    requestAnimationFrame(function () {\n      _Element.style.height = snackbarHeight + 'px'; // set the auto height to the px height\n\n      _Element.style.opacity = 1;\n      _Element.style.marginTop = '0px';\n      _Element.style.marginBottom = '0px';\n      _Element.style.transition = snackbarTransitions;\n      requestAnimationFrame(function () {\n        _Element.style.height = '0px';\n        _Element.style.opacity = 0;\n      });\n    });\n    setTimeout(function () {\n      _Container.removeChild(_Element);\n    }, 1000);\n  };\n\n  _ConfigureDefaults();\n\n  _Create();\n\n  Open();\n}\n\nwindow.onmouseup = function () {\n  const selection = window.getSelection();\n\n  if (selection.anchorOffset != selection.extentOffset) {\n    chrome.runtime.sendMessage({\n      type: 'text',\n      content: selection.toString()\n    });\n  }\n};\n\nwindow.onload = function () {\n  setTheme(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches);\n  let theme = document.getElementById('theme');\n  let gird = document.getElementById('girdBtn');\n  let edit = document.getElementById('editBtn');\n  let darkBtn = document.getElementById('darkBtn');\n  let labBtn = document.getElementById('labBtn');\n  let fullscreenBtn = document.getElementById('fullscreen');\n  let girdMenuBtn = document.getElementById('girdMenuBtn');\n  let darkAction = document.querySelector('.darkAction');\n  let solarizedAction = document.querySelector('.solarizedAction');\n\n  if (solarizedAction) {\n    solarizedAction.onclick = function () {\n      if (document.getElementById('darkModel')) {\n        document.getElementById('darkModel').remove();\n        darkAction.innerText = '开启';\n      }\n\n      if (solarizedAction.innerText == '开启') {\n        insertSolarizedTheme();\n        window.localStorage.setItem('theme', 'solarized');\n        solarizedAction.innerText = '关闭';\n        SnackBar({\n          message: '开启Solarized Light!'\n        });\n      } else {\n        document.getElementById('SolarizedModel').remove();\n        window.localStorage.setItem('theme', 'light');\n        solarizedAction.innerText = '开启';\n        SnackBar({\n          message: '关闭Solarized Light!'\n        });\n      }\n    };\n  }\n\n  if (darkAction) {\n    darkAction.onclick = function () {\n      if (document.getElementById('SolarizedModel')) {\n        document.getElementById('SolarizedModel').remove();\n        solarizedAction.innerText = '开启';\n      }\n\n      if (darkAction.innerText == '开启') {\n        setTheme(true);\n        window.localStorage.setItem('theme', 'dark');\n        darkAction.innerText = '关闭';\n        SnackBar({\n          message: '开启黑暗模式!'\n        });\n      } else {\n        document.getElementById('darkModel').remove();\n        window.localStorage.setItem('theme', 'light');\n        darkAction.innerText = '开启';\n        SnackBar({\n          message: '关闭黑暗模式!'\n        });\n      }\n    };\n  } //setting box\n\n\n  const settingBox = document.createElement('DIV');\n  settingBox.className = 'settingBox';\n  settingBox.id = 'settingBox';\n\n  if (girdMenuBtn) {\n    girdMenuBtn.addEventListener('click', function (ev) {\n      ev.cancelBubble = true;\n      ev.preventDefault();\n      ev.stopPropagation();\n\n      if (girdMenuBtn.className.indexOf('active') == -1) {\n        girdMenuBtn.className = 'el-icon-menu active';\n        window.localStorage.setItem('isGird', 1);\n        document.body.className = document.body.className + ' isGird';\n        SnackBar({\n          message: '开启Gird模式!'\n        });\n      } else {\n        girdMenuBtn.className = 'el-icon-menu';\n        window.localStorage.setItem('isGird', 2);\n        document.body.className = document.body.className.replace('isGird', '');\n        SnackBar({\n          message: '关闭Gird模式!'\n        });\n      }\n    });\n  }\n\n  if (fullscreenBtn) {\n    fullscreenBtn.addEventListener('click', function (ev) {\n      ev.cancelBubble = true;\n      ev.preventDefault();\n      ev.stopPropagation();\n\n      if (fullscreenBtn.className.indexOf('active') == -1) {\n        fullscreenBtn.className = 'el-icon-full-screen active';\n        window.localStorage.setItem('fullscreen', true);\n        console.log(document.body.className);\n        document.body.className = document.body.className + ' fullscreen';\n        SnackBar({\n          message: '开启专注模式!'\n        });\n      } else {\n        fullscreenBtn.className = 'el-icon-full-screen';\n        window.localStorage.setItem('fullscreen', false);\n        document.body.className = document.body.className.replace('fullscreen', '');\n        SnackBar({\n          message: '关闭专注模式!'\n        });\n      }\n    });\n  }\n\n  if (labBtn) {\n    labBtn.addEventListener('click', function (ev) {\n      ev.cancelBubble = true;\n      ev.preventDefault();\n      ev.stopPropagation();\n\n      if (labBtn.className.indexOf('active') == -1) {\n        labBtn.className = 'el-icon-ice-cream-round active';\n        window.localStorage.setItem('isLab', 1); // document.head.appendChild(commModel);\n\n        getTagCount();\n        getTagContentCount();\n        getAllTagClick();\n        SnackBar({\n          message: '开启实验功能!'\n        }); // document.body.appendChild(settingBox);\n      } else {\n        labBtn.className = 'el-icon-ice-cream-round ';\n\n        if (document.getElementById('commModel')) {\n          document.getElementById('commModel').remove();\n        }\n\n        window.localStorage.setItem('isLab', 0);\n        removeAllTagCount();\n        removeTagCount();\n\n        if (document.getElementById('settingBox')) {\n          document.getElementById('settingBox').remove();\n        }\n\n        SnackBar({\n          message: '关闭实验功能!'\n        });\n      }\n    });\n  }\n\n  if (window.location.host == 'flomoapp.com') {\n    if (window.localStorage.getItem('theme') == 'dark') {\n      setTheme(true);\n      darkAction.innerText = '关闭';\n    } else if (window.localStorage.getItem('theme') == 'solarized') {\n      insertSolarizedTheme();\n      solarizedAction.innerText = '关闭';\n    } else {\n      darkAction.innerText = '开启';\n      solarizedAction.innerText = '开启';\n    }\n  }\n\n  if (darkBtn) {\n    darkBtn.addEventListener('click', function (ev) {\n      if (darkBtn.className.indexOf('el-icon-moon') != -1) {\n        darkBtn.className = 'el-icon-sunny';\n        setTheme(true);\n        window.localStorage.setItem('theme', 'dark');\n        SnackBar({\n          message: '开启黑暗模式!'\n        });\n      } else {\n        darkBtn.className = 'el-icon-moon';\n\n        if (document.getElementById('darkModel')) {\n          document.getElementById('darkModel').remove();\n        }\n\n        window.localStorage.setItem('theme', 'light');\n        SnackBar({\n          message: '关闭黑暗模式!'\n        });\n      }\n    });\n\n    if (window.localStorage.getItem('theme') == 'dark') {\n      setTheme(true);\n\n      if (darkBtn.className.indexOf('el-icon-moon') > -1) {\n        darkBtn.className = 'el-icon-sunny';\n      }\n    } else {\n      if (document.getElementById('darkModel')) {\n        document.getElementById('darkModel').remove();\n\n        if (darkBtn.querySelector('.el-icon-moon')) {\n          darkBtn.querySelector('.el-icon-sunny').className = 'el-icon-moon';\n        }\n      }\n    }\n  }\n\n  if (theme) {\n    theme.addEventListener('click', function (ev) {\n      if (theme.querySelector('.el-icon-moon')) {\n        theme.querySelector('.el-icon-moon').className = 'el-icon-sunny';\n        setTheme(true);\n        window.localStorage.setItem('theme', 'dark');\n        SnackBar({\n          message: '开启黑暗模式!'\n        });\n      } else {\n        theme.querySelector('.el-icon-sunny').className = 'el-icon-moon';\n\n        if (document.getElementById('darkModel')) {\n          document.getElementById('darkModel').remove();\n        }\n\n        window.localStorage.setItem('theme', 'light');\n        SnackBar({\n          message: '关闭黑暗模式!'\n        });\n      }\n    });\n\n    if (window.localStorage.getItem('theme') == 'dark') {\n      setTheme(true);\n\n      if (theme.querySelector('.el-icon-moon')) {\n        theme.querySelector('.el-icon-moon').className = 'el-icon-sunny';\n      }\n    } else {\n      if (document.getElementById('darkModel')) {\n        document.getElementById('darkModel').remove();\n\n        if (theme.querySelector('.el-icon-moon')) {\n          theme.querySelector('.el-icon-sunny').className = 'el-icon-moon';\n        }\n      }\n    }\n  }\n\n  if (edit) {\n    edit.addEventListener('click', function (e) {\n      console.log(e);\n      let input = document.getElementsByClassName('input')[0];\n      input.style.position = 'fixed';\n      input.style.width = '668px';\n      input.style.bottom = '70px';\n      input.style.zIndex = '99999999';\n    });\n  }\n\n  document.body.addEventListener('click', function (e) {\n    // console.log(e);\n    if (document.getElementById('settingBox')) {\n      document.getElementById('settingBox').remove();\n    }\n\n    enterBox.style.display = 'none';\n  }); // enter+shift\n\n  let editor = document.getElementsByClassName('ProseMirror')[0];\n  let editorBar = document.getElementsByClassName('pin-right')[0]; // editorBar.appendChild(selectList);\n\n  const tipsBtn = document.createElement('BUTTON');\n  tipsBtn.className = 'el-button  el-button--text ';\n  tipsBtn.id = 'tipsBtn';\n  const t = document.createElement('i');\n  t.className = 'el-icon-warning-outline';\n  t.title = '修改回车方式';\n  tipsBtn.appendChild(t);\n  t.style.cursor = 'pointer';\n\n  if (editorBar) {\n    editorBar.appendChild(tipsBtn);\n  }\n\n  var inputBox = document.getElementsByClassName('input-box')[0];\n  const enterBox = document.createElement('DIV');\n  enterBox.className = 'enterBox';\n  enterBox.id = 'enterBox';\n\n  if (inputBox) {\n    inputBox.appendChild(enterBox);\n  } //Create array of options to be added\n\n\n  var array = ['enter换行', 'enter+shift换行']; //Create and append select list\n\n  var selectList = document.createElement('select');\n  selectList.id = 'mySelect';\n  enterBox.appendChild(selectList); //Create and append the options\n\n  for (var i = 0; i < array.length; i++) {\n    var option = document.createElement('option');\n    option.value = array[i];\n    option.text = array[i];\n    selectList.appendChild(option);\n  }\n\n  var btn = document.getElementsByClassName('submit-btn')[0];\n  var enterType = window.localStorage.getItem('enterType');\n  selectList.defaultValue = enterType;\n\n  if (editor) {\n    editor.addEventListener('keydown', function (event) {\n      enterType = window.localStorage.getItem('enterType');\n\n      if (!event.shiftKey && event.keyCode == 13) {\n        if (enterType) {\n          if (enterType != 'enter换行') {\n            console.log(editor.innerText);\n\n            if (editor.innerText.length != 4) {\n              btn.click();\n            }\n          }\n        }\n      }\n\n      if (event.shiftKey && event.keyCode == 13) {\n        if (enterType) {\n          if (enterType != 'enter换行') {\n            event.cancelBubble = true;\n            event.preventDefault();\n            event.stopPropagation();\n            editor.innerHTML = editor.innerHTML + '<p><br></p>';\n          }\n        }\n      }\n    });\n  }\n\n  if (tipsBtn) {\n    tipsBtn.addEventListener('click', function (ev) {\n      ev.cancelBubble = true;\n      ev.preventDefault();\n      ev.stopPropagation();\n\n      if (enterType && enterType != 'enter换行') {\n        selectList[1].selected = 'selected';\n      } else {\n        selectList[0].selected = 'selected';\n      }\n\n      enterBox.style.display = 'block';\n    });\n    selectList.addEventListener('click', function (ev) {\n      ev.cancelBubble = true;\n      ev.preventDefault();\n      ev.stopPropagation();\n    });\n  }\n\n  selectList.addEventListener('change', function (event) {\n    event.cancelBubble = true;\n    event.preventDefault();\n    event.stopPropagation();\n    window.localStorage.setItem('enterType', event.target.value);\n    selectList.defaultValue = event.target.value;\n    enterBox.style.display = 'none';\n  });\n  var nickBox = document.getElementsByClassName('nickname')[0];\n\n  if (nickBox) {\n    var actualCode = `\n    var nickBox = document.getElementsByClassName('nickname')[0];\n    var idBox = document.createElement('label');\n    idBox.className='idLabel'\n    let newContent = document.createTextNode(me.id);\n    idBox.appendChild(newContent);\n    nickBox.appendChild(idBox);\n`;\n    var script = document.createElement('script');\n    script.textContent = actualCode; // (document.head || document.documentElement).appendChild(script);\n  } // 微信读书\n\n\n  if (window.location.href == 'https://weread.qq.com/') {\n    chrome.runtime.sendMessage({\n      type: 'storage',\n      content: window.localStorage\n    });\n  } // 即刻\n\n\n  function addFlomoBtn() {\n    const jkCard = document.querySelectorAll('.hkfshi');\n    console.log(jkCard);\n\n    for (let i = 0; i < jkCard.length; i++) {\n      const flomoBtn = document.createElement('DIV');\n      flomoBtn.className = 'sc-bdfBwQ sc-gsTCUz ActionContainer-sc-1ffcz6r-0 kWKzJL bhdLno gcgBcs flomo';\n      let newContent = document.createTextNode('flomo');\n      flomoBtn.appendChild(newContent);\n\n      flomoBtn.onclick = function (ev) {\n        ev.cancelBubble = true;\n        ev.preventDefault();\n        ev.stopPropagation();\n        console.log(jkCard[i].parentElement.parentElement.querySelector('.ehDrPv span').innerHTML);\n      };\n\n      if (!jkCard[i].querySelector('.flomo')) {\n        jkCard[i].appendChild(flomoBtn);\n      }\n    }\n  }\n\n  if (window.location.href == 'https://web.okjike.com/') {\n    chrome.runtime.sendMessage({\n      type: 'jk',\n      content: window.localStorage\n    });\n  }\n\n  if (window.location.href == 'https://web.okjike.com/login') {\n    chrome.runtime.sendMessage({\n      type: 'jkLogin',\n      content: window.localStorage\n    });\n  } // 得到\n\n\n  if (window.location.href == 'https://www.dedao.cn/') {\n    chrome.runtime.sendMessage({\n      type: 'dd',\n      content: window.localStorage\n    });\n  } // weibo\n\n\n  if (window.location.href == 'https://weibo.com/') {\n    chrome.runtime.sendMessage({\n      type: 'wb',\n      content: window.localStorage\n    });\n  }\n\n  if (window.location.href == 'https://weibo.com/login.php?url=https%3A%2F%2Fweibo.com%2F') {\n    chrome.runtime.sendMessage({\n      type: 'wbLogin',\n      content: window.localStorage\n    });\n  } // 专注模式\n\n\n  if (window.location.host == 'flomoapp.com') {\n    const topbar = document.querySelector('.topbar .left');\n    const gird = document.createElement('I');\n\n    if (window.localStorage.getItem('isGird') == 1) {\n      gird.className = 'girdIcon el-icon-files';\n    } else {\n      gird.className = 'girdIcon el-icon-s-grid';\n    }\n\n    if (window.localStorage.getItem('isGird') == 1) {\n      document.body.className = document.body.className + ' isGird';\n      girdMenuBtn.className = 'el-icon-menu active';\n    } else {\n      girdMenuBtn.className = 'el-icon-menu';\n      document.body.className = document.body.className.replace('isGird', '');\n    }\n  } // 推特\n\n\n  if (window.location.host == 'twitter.com') {// addFlomoAction();\n  }\n}; // 跟随系统主题\n\n\nwindow.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {\n  setTheme(event.matches);\n});\n\n//# sourceURL=webpack:///./core.js?");

/***/ })

/******/ });