From 03ce431546a871a3817a3e0e71fe5618e4df845a Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Wed, 16 Jan 2019 21:43:57 +0000 Subject: [PATCH] Add env variable to configure permissions --- TODO.org | 7 ++++--- src/manifest.json | 7 ------- utils/env.js | 5 +++-- webpack.config.js | 15 +++++++++++++++ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/TODO.org b/TODO.org index 57be934..e60af46 100644 --- a/TODO.org +++ b/TODO.org @@ -1,7 +1,5 @@ * TODO [#B] doesn't look like hotkey working unless you manually rebind.. wtf? -* TODO [#C] update screens and video now that the notification is nicer - * TODO [#C] how to test it? try on different pages? https://www.blazemeter.com/blog/6-easy-steps-testing-your-chrome-extension-selenium looks tricky... @@ -12,7 +10,7 @@ * TODO [#D] do not minfy for dev * TODO [#D] make manifest templated so we don't have to hardcode actions -* TODO [#D] +* TODO [#D] production build? ## Packing After the development of your extension run the command @@ -42,6 +40,9 @@ Now, the content of `build` folder will be the extension ready to be submitted t * DONE [#B] docs on using CLOSED: [2019-01-06 Sun 21:39] +* DONE [#C] update screens and video now that the notification is nicer + CLOSED: [2019-01-13 Sun 15:32] + * DONE [#C] custom capture template? CLOSED: [2019-01-13 Sun 14:57] * DONE [#C] make notification configurable or only in case of errors diff --git a/src/manifest.json b/src/manifest.json index 2f268ab..9323191 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -16,13 +16,6 @@ "default_popup": "popup.html", "default_title": "Capture page, with extra information" }, - "permissions": [ - "storage", - "notifications", - "activeTab", - "http://localhost/capture", - "https://localhost/capture" - ], "commands": { "capture-simple": { "description": "Quick capture: url, title and selection", diff --git a/utils/env.js b/utils/env.js index 27f2a3c..ec3d792 100644 --- a/utils/env.js +++ b/utils/env.js @@ -1,5 +1,6 @@ // tiny wrapper with default env vars module.exports = { - NODE_ENV: (process.env.NODE_ENV || "development"), - PORT: (process.env.PORT || 3000) + NODE_ENV: (process.env.NODE_ENV || "development"), + PORT: (process.env.PORT || 3000), + ANY_HOST: (process.env.ANY_HOST ? true : false), }; diff --git a/webpack.config.js b/webpack.config.js index fbdf57e..e6380c3 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -11,6 +11,20 @@ var webpack = require("webpack"), const pkg = require('./package.json'); const baseManifest = require('./src/manifest.json'); +const permissions = [ + "storage", + "notifications", + "activeTab", + "http://localhost/capture", + "https://localhost/capture" +]; + +if (env.ANY_HOST) { + permissions.push("https://*/capture"); +} + + + // load the secrets var alias = {}; @@ -78,6 +92,7 @@ var options = { extend: { version: pkg.version, description: pkg.description, + permissions: permissions, } } }),