Skip to content

Commit

Permalink
Merge pull request #1166 from dis-moi/feat/lmel_manifest
Browse files Browse the repository at this point in the history
feat: Adapt manifest.json to LMEL facet
  • Loading branch information
JalilArfaoui authored Nov 4, 2021
2 parents 04d4404 + ae41291 commit 212319f
Show file tree
Hide file tree
Showing 15 changed files with 218 additions and 171 deletions.
98 changes: 51 additions & 47 deletions manifest/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,55 @@
const version = require('../package.json').version;
const icons = require('./icons');

module.exports = Object.freeze({
name: 'Dismoi',
description:
'Amis, media, experts vous informent directement sur les pages web visitées. ',
version,
manifest_version: 2,
icons,
background: {
page: 'background.html'
},
content_scripts: [
{
exclude_globs: [
'*.pdf*',
'*.Pdf*',
'*.PDF*',
'*.jpeg*',
'*.jpg*',
'*.png*',
'*.gif*'
],
matches: ['*://*/*'],
exclude_matches: [
'*://*.googleusercontent.com/viewer/secure/pdf/*',
'*://*.cdn.mozilla.net/*',
'*://*.accounts.firefox.com/*',
'*://*.addons.mozilla.org/*',
'*://*.input.mozilla.org/*',
'*://*.install.mozilla.org/*',
'*://*.support.mozilla.org/*',
'*://*.services.mozilla.org/*',
'*://*.testpilot.firefox.com/*'
],
js: ['js/browser-polyfill.js', 'js/content.bundle.js'],
run_at: 'document_end'
}
],
browser_action: {
default_icon: {
'16': 'img/logo/16x16.png',
'48': 'img/logo/48x48.png',
'128': 'img/logo/128x128.png'
module.exports = facet => {
const facetName = facet === 'lmel' ? 'Le Même en Local' : 'Dismoi';

return Object.freeze({
name: facetName,
description:
'Amis, media, experts vous informent directement sur les pages web visitées. ',
version,
manifest_version: 2,
icons,
background: {
page: 'background.html'
},
content_scripts: [
{
exclude_globs: [
'*.pdf*',
'*.Pdf*',
'*.PDF*',
'*.jpeg*',
'*.jpg*',
'*.png*',
'*.gif*'
],
matches: ['*://*/*'],
exclude_matches: [
'*://*.googleusercontent.com/viewer/secure/pdf/*',
'*://*.cdn.mozilla.net/*',
'*://*.accounts.firefox.com/*',
'*://*.addons.mozilla.org/*',
'*://*.input.mozilla.org/*',
'*://*.install.mozilla.org/*',
'*://*.support.mozilla.org/*',
'*://*.services.mozilla.org/*',
'*://*.testpilot.firefox.com/*'
],
js: ['js/browser-polyfill.js', 'js/content.bundle.js'],
run_at: 'document_end'
}
],
browser_action: {
default_icon: {
'16': 'img/logo/16x16.png',
'48': 'img/logo/48x48.png',
'128': 'img/logo/128x128.png'
},
default_title: facetName
},
default_title: 'Dismoi'
},
permissions: ['activeTab', 'storage', 'contextMenus'],
web_accessible_resources: ['img/*', 'fonts/*'],
});
permissions: ['activeTab', 'storage', 'contextMenus'],
web_accessible_resources: ['img/*', 'fonts/*']
});
};
35 changes: 19 additions & 16 deletions manifest/development/chromium.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
const csp = require('content-security-policy-builder');
const base = require('../base');

module.exports = {
...base,
name: `${base.name} - development`,
content_security_policy: csp({
directives: {
'script-src': ["'self'", "'unsafe-eval'"],
'object-src': ["'self'"]
module.exports = facet => {
const facetBase = base(facet);
return {
...facetBase,
name: `${facetBase.name} - development`,
content_security_policy: csp({
directives: {
'script-src': ["'self'", "'unsafe-eval'"],
'object-src': ["'self'"]
}
}),
browser_action: {
...facetBase.browser_action,
default_title: `${facetBase.browser_action.default_title} - development`
},
externally_connectable: {
matches: ['*://localhost/*'],
accepts_tls_channel_id: false
}
}),
browser_action: {
...base.browser_action,
default_title: `${base.browser_action.default_title} - development`
},
externally_connectable: {
matches: ['*://localhost/*'],
accepts_tls_channel_id: false
}
};
};
29 changes: 16 additions & 13 deletions manifest/development/firefox.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
const csp = require('content-security-policy-builder');
const base = require('../base');

module.exports = {
...base,
name: `${base.name} - development`,
permissions: [...base.permissions, '*://*/*'],
content_security_policy: csp({
directives: {
'script-src': ["'self'", "'unsafe-eval'"],
'object-src': ["'self'"]
module.exports = facet => {
const facetBase = base(facet);
return {
...facetBase,
name: `${facetBase.name} - development`,
permissions: [...facetBase.permissions, '*://*/*'],
content_security_policy: csp({
directives: {
'script-src': ["'self'", "'unsafe-eval'"],
'object-src': ["'self'"]
}
}),
browser_action: {
...facetBase.browser_action,
default_title: `${facetBase.browser_action.default_title} - development`
}
}),
browser_action: {
...base.browser_action,
default_title: `${base.browser_action.default_title} - development`
}
};
};
8 changes: 6 additions & 2 deletions manifest/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const getManifestFilepath = (env, platform) => `./${env}/${platform}.js`;

const getManifest = (env, platform) => {
const getManifest = (env, platform, facet) => {
console.log(getManifestFilepath(env, platform));
return JSON.stringify(require(getManifestFilepath(env, platform)), null, 2);
return JSON.stringify(
require(getManifestFilepath(env, platform))(facet),
null,
2
);
};

module.exports = getManifest;
47 changes: 25 additions & 22 deletions manifest/proding/chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@ const csp = require('content-security-policy-builder');
const production = require('../production/chromium');
const base = require('../base');

module.exports = {
...production,
name: `${base.name} - proding`,
content_security_policy: csp({
directives: {
'default-src': ['https://api.dismoi.io'],
'connect-src': [
'https://api.dismoi.io',
'https://sentry.io',
'https://stats.lmem.net',
'https://app.posthog.com'
],
'script-src': ["'self'", "'unsafe-eval'"],
'object-src': ["'self'"],
'img-src': ["'self'", 'https://api.dismoi.io', 'data:'],
'font-src': ["'self'", 'data:'],
'style-src': ["'unsafe-inline'"]
module.exports = facet => {
const facetBase = base(facet);
return {
...production(facet),
name: `${facetBase.name} - proding`,
content_security_policy: csp({
directives: {
'default-src': ['https://api.dismoi.io'],
'connect-src': [
'https://api.dismoi.io',
'https://sentry.io',
'https://stats.lmem.net',
'https://app.posthog.com'
],
'script-src': ["'self'", "'unsafe-eval'"],
'object-src': ["'self'"],
'img-src': ["'self'", 'https://api.dismoi.io', 'data:'],
'font-src': ["'self'", 'data:'],
'style-src': ["'unsafe-inline'"]
}
}),
browser_action: {
...facetBase.browser_action,
default_title: `${facetBase.browser_action.default_title} - proding`
}
}),
browser_action: {
...base.browser_action,
default_title: `${base.browser_action.default_title} - proding`
}
};
};
17 changes: 10 additions & 7 deletions manifest/proding/firefox.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const production = require('../production/firefox');
const base = require('../base');

module.exports = {
...production,
name: `${base.name} - proding`,
browser_action: {
...base.browser_action,
default_title: `${base.browser_action.default_title} - proding`
}
module.exports = facet => {
const facetBase = base(facet);
return {
...production(facet),
name: `${facetBase.name} - proding`,
browser_action: {
...facetBase.browser_action,
default_title: `${facetBase.browser_action.default_title} - proding`
}
};
};
6 changes: 3 additions & 3 deletions manifest/production/chromium.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const csp = require('content-security-policy-builder');
const base = require('../base');

module.exports = {
...base,
module.exports = facet => ({
...base(facet),
content_security_policy: csp({
directives: {
'default-src': ['https://api.dismoi.io'],
Expand All @@ -23,4 +23,4 @@ module.exports = {
matches: ['https://*.dismoi.io/*'],
accepts_tls_channel_id: false
}
};
});
9 changes: 6 additions & 3 deletions manifest/production/firefox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const base = require('../base');

module.exports = {
...base,
permissions: [...base.permissions, '*://*/*']
module.exports = facet => {
const facetBase = base(facet);
return {
...facetBase,
permissions: [...facetBase.permissions, '*://*/*']
};
};
47 changes: 25 additions & 22 deletions manifest/staging/chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@ const csp = require('content-security-policy-builder');
const proding = require('../proding/chromium');
const base = require('../base');

module.exports = {
...proding,
name: `${base.name} - staging`,
content_security_policy: csp({
directives: {
'default-src': ['https://staging.dismoi.io'],
'connect-src': [
'https://staging.dismoi.io',
'https://sentry.io',
'https://stats.lmem.net',
'https://app.posthog.com'
],
'script-src': ["'self'", "'unsafe-eval'"],
'object-src': ["'self'"],
'img-src': ["'self'", 'https://staging.dismoi.io', 'data:'],
'font-src': ["'self'", 'data:'],
'style-src': ["'unsafe-inline'"]
module.exports = facet => {
const facetBase = base(facet);
return {
...proding(facet),
name: `${facetBase.name} - staging`,
content_security_policy: csp({
directives: {
'default-src': ['https://staging.dismoi.io'],
'connect-src': [
'https://staging.dismoi.io',
'https://sentry.io',
'https://stats.lmem.net',
'https://app.posthog.com'
],
'script-src': ["'self'", "'unsafe-eval'"],
'object-src': ["'self'"],
'img-src': ["'self'", 'https://staging.dismoi.io', 'data:'],
'font-src': ["'self'", 'data:'],
'style-src': ["'unsafe-inline'"]
}
}),
browser_action: {
...facetBase.browser_action,
default_title: `${facetBase.browser_action.default_title} - staging`
}
}),
browser_action: {
...base.browser_action,
default_title: `${base.browser_action.default_title} - staging`
}
};
};
17 changes: 10 additions & 7 deletions manifest/staging/firefox.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const proding = require('../proding/firefox');
const base = require('../base');

module.exports = {
...proding,
name: `${base.name} - staging`,
browser_action: {
...base.browser_action,
default_title: `${base.browser_action.default_title} - staging`
}
module.exports = facet => {
const facetBase = base(facet);
return {
...proding(facet),
name: `${facetBase.name} - staging`,
browser_action: {
...facetBase.browser_action,
default_title: `${facetBase.browser_action.default_title} - staging`
}
};
};
Loading

0 comments on commit 212319f

Please sign in to comment.