Skip to content

Commit

Permalink
Added documentation support (#328)
Browse files Browse the repository at this point in the history
Co-authored-by: Shane Osbourne <[email protected]>
  • Loading branch information
shakyShane and Shane Osbourne authored Mar 22, 2023
1 parent 29e02b2 commit 96c0d24
Show file tree
Hide file tree
Showing 15 changed files with 230 additions and 11 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/
docs/
lib/
Sources/ContentScopeScripts/dist/
integration-test/extension/contentScope.js
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
${{ runner.os }}-node-
- run: npm install
- run: npm run build
- run: npm run docs
- run: npm run lint
- run: npm run test-unit
- name: "Clean tree"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules/
.swiftpm
.env
build/
Sources/ContentScopeScripts/dist/
docs/
Sources/ContentScopeScripts/dist/
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Each platform calls into the API exposed by content-scope-features.js where the

The exposed API is a global called contentScopeFeatures and has three methods:
- load
- Calls the load method on all of the features
- Calls the load method on all the features
- init
- Calls the init method on all of the features
- Calls the init method on all the features
- This should be passed the arguments object which has the following keys:
- 'platform' which is an object with:
- 'name' which is a string of 'android', 'ios', 'macos' or 'extension'
- 'debug' true if debuging should be enabled
- 'debug' true if debugging should be enabled
- 'globalPrivacyControlValue' false if the user has disabled GPC.
- 'sessionKey' a unique session based key.
- 'cookie' TODO
Expand All @@ -24,7 +24,7 @@ The exposed API is a global called contentScopeFeatures and has three methods:
- 'domain' the hostname of the site in the URL bar
- 'enabledFeatures' this is an array of features/ to enable
- update
- Calls the update method on all of the features
- Calls the update method on all the features

## Features

Expand All @@ -51,7 +51,7 @@ The [inject/](https://github.com/duckduckgo/content-scope-scripts/tree/main/inje
- In Firefox the code is loaded as a standard extension content script.
- For Apple, Windows and Android the code is a UserScript that has some string replacements for properties and loads in as the page scope.
- Note: currently we don't implement the update calls as it's only required by cookie protections which we don't implement.
- All other browsers the code is stringified, base64 encoded and injected in as a self deleting <script> tag.
- All other browsers the code is stringified, base64 encoded and injected in as a self deleting `<script>` tag.

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

Expand All @@ -60,10 +60,10 @@ In the built output you will see these dramatic differences in the bundled code
- `$CONTENT_SCOPE$` - raw remote config object
- `$USER_UNPROTECTED_DOMAINS$` - an array of user allowlisted domains
- `$USER_PREFERENCES$` - an object containing:
- platform: { name: '<ios | macos | extension | android>' }
- platform: `{ name: '<ios | macos | extension | android>' }`
- debug: boolean
- globalPrivacyControlValue: boolean
- sessionKey: <CSRNG UUID 4 string> (used for fingerprinting) - this should regnerate on browser close or every 24 hours.
- sessionKey: `<CSRNG UUID 4 string>` (used for fingerprinting) - this should regenerate on browser close or every 24 hours.

### Features scope injection utilities

Expand Down
4 changes: 3 additions & 1 deletion inject/android.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* @module Android integration
*/
/* global contentScopeFeatures */

import { processConfig, isGloballyDisabled } from './../src/utils'

function init () {
Expand Down
3 changes: 3 additions & 0 deletions inject/apple.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @module Apple integration
*/
/* global contentScopeFeatures */

import { processConfig, isGloballyDisabled } from './../src/utils'
Expand Down
3 changes: 3 additions & 0 deletions inject/chrome-mv3.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @module Chrome MV3 integration
*/
/* global contentScopeFeatures */

import { isTrackerOrigin } from '../src/trackers'
Expand Down
3 changes: 3 additions & 0 deletions inject/chrome.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @module Chrome integration
*/
import { isTrackerOrigin } from '../src/trackers'

/**
Expand Down
5 changes: 4 additions & 1 deletion inject/integration.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* global contentScopeFeatures */
/**
* @module Testing integration
*/

/* global contentScopeFeatures */
function getTopLevelURL () {
try {
// FROM: https://stackoverflow.com/a/7739035/73479
Expand Down
3 changes: 3 additions & 0 deletions inject/mozilla.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @module Mozilla integration
*/
/* global contentScopeFeatures */
import { isTrackerOrigin } from '../src/trackers'

Expand Down
4 changes: 3 additions & 1 deletion inject/windows.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* @module Windows integration
*/
/* global contentScopeFeatures */

import { processConfig, isGloballyDisabled, windowsSpecificFeatures } from './../src/utils'

function init () {
Expand Down
Loading

0 comments on commit 96c0d24

Please sign in to comment.