Skip to content

Commit 16e1fe3

Browse files
Document platform key (#169)
1 parent f18a4c2 commit 16e1fe3

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The exposed API is a global called contentScopeFeatures and has three methods:
1212
- init
1313
- Calls the init method on all of the features
1414
- This should be passed the arguments object which has the following keys:
15+
- 'platform' which is an object with:
16+
- 'name' which is a string of 'android', 'ios', 'macos' or 'extension'
1517
- 'debug' true if debuging should be enabled
1618
- 'globalPrivacyControlValue' false if the user has disabled GPC.
1719
- 'sessionKey' a unique session based key.
@@ -47,12 +49,22 @@ There are three stages that the content scope code is hooked into the platform:
4749
The [inject/](https://github.com/duckduckgo/content-scope-scripts/tree/main/inject) directory handles platform specific differences and is glue code into calling the contentScopeFeatures API.
4850

4951
- In Firefox the code is loaded as a standard extension content script.
50-
- For Apple the code is a UserScript that has some string replacements for properties and loads in as the page scope.
52+
- For Apple, Windows and Android the code is a UserScript that has some string replacements for properties and loads in as the page scope.
5153
- Note: currently we don't implement the update calls as it's only required by cookie protections which we don't implement.
5254
- All other browsers the code is stringified, base64 encoded and injected in as a self deleting <script> tag.
5355

5456
In the built output you will see these dramatic differences in the bundled code which is created into: /build
5557

58+
#### App specific integration replacements
59+
60+
$CONTENT_SCOPE$ - raw remote config object
61+
$USER_UNPROTECTED_DOMAINS$ - an array of user allowlisted domains
62+
$USER_PREFERENCES$ - an object containing:
63+
platform: { name: '<ios | macos | extension | android>' }
64+
debug: boolean
65+
globalPrivacyControlValue: boolean
66+
sessionKey: <random UUID string> (used for fingerprinting)
67+
5668
### Features scope injection utilities
5769

5870
To handle the difference in scope injection we expose multiple utilities which behave differently per browser in src/utils.js. for Firefox the code exposed handles [xrays correctly](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts) without needing the features to be authored differently.

0 commit comments

Comments
 (0)