Skip to content

Commit

Permalink
Support Chrome schema & minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
smalluban committed Oct 31, 2024
1 parent 09094b2 commit c9e2e60
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 10 deletions.
6 changes: 6 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ cpSync(
resolve(options.outDir, 'rule_resources', 'engine-trackerdb.dat'),
);

// copy managed storage configuration
if (manifest.storage?.managed_schema) {
const path = resolve(options.srcDir, manifest.storage.managed_schema);
cpSync(path, resolve(options.outDir, manifest.storage.managed_schema));
}

// copy declarative net request lists
if (manifest.declarative_net_request?.rule_resources) {
let rulesCount = 0;
Expand Down
25 changes: 25 additions & 0 deletions src/managed_storage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"type": "object",
"properties": {
"disableOnboarding": {
"title": "Disable onboarding process",
"description": "Automatically enable the extension without showing the onboarding process",
"type": "boolean"
},

"disableUserControl": {
"title": "Disable user control",
"description": "Prevents access to the settings page and hides UI elements that allow the user to interact with the extension",
"type": "boolean"
},

"trustedDomains": {
"title": "Trusted domains",
"description": "A list of domains that are trusted by default",
"type": "array",
"items": {
"type": "string"
}
}
}
}
3 changes: 3 additions & 0 deletions src/manifest.chromium.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"service_worker": "background/index.js",
"type": "module"
},
"storage": {
"managed_schema": "managed_storage.json"
},
"declarative_net_request": {
"rule_resources": [
{
Expand Down
26 changes: 17 additions & 9 deletions src/pages/onboarding/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,33 @@ import { mount, html, store, router } from 'hybrids';

import '/ui/index.js';
import Options from '/store/options.js';
import { GHOSTERY_DOMAIN } from '/utils/urls.js';

import './elements.js';

import Main from './views/main.js';
import Success from './views/success.js';

store.resolve(Options).then(({ onboarding }) => {
store.resolve(Options).then(({ onboarding, terms, managed }) => {
// As the user can access settings page from browser native UI
// we must redirect to the Ghostery website if the user has already
// accepted the terms and conditions and the extension is managed
if (terms && managed) {
return window.location.replace(`https://www.${GHOSTERY_DOMAIN}`);
}

store.set(Options, {
onboarding: {
shown: onboarding.shown + 1,
},
});
});

mount(document.body, {
stack: router([Main, Success]),
render: ({ stack }) => html`
<template layout="grid height::100%">
<onboarding-layout>${stack}</onboarding-layout>
</template>
`,
mount(document.body, {
stack: router([Main, Success]),
render: ({ stack }) => html`
<template layout="grid height::100%">
<onboarding-layout>${stack}</onboarding-layout>
</template>
`,
});
});
2 changes: 1 addition & 1 deletion src/store/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async function applyManagedOptions(options) {
options.onboarding = { shown: 1 };
}

if (managed.disableSettings === true) {
if (managed.disableUserControl === true) {
options.managed = true;
options.sync = false;

Expand Down

0 comments on commit c9e2e60

Please sign in to comment.