Skip to content

Commit 9b055be

Browse files
Docs: Work with content-scope-scripts repo on Windows (#1794)
* Add working with C-S-S for Windows content * Add windows caveat * Add Getting started docs * Add platform support docs * Lint fix * Change certainty of WSL advice
1 parent b33ee8d commit 9b055be

File tree

6 files changed

+201
-7
lines changed

6 files changed

+201
-7
lines changed

.cursorrules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ When asked about Content Scope Scripts topics, refer to these documentation file
66

77
- **API Reference**: `injected/docs/api-reference.md`
88
- **Feature Development**: `injected/docs/features-guide.md`
9-
- **Platform Integration**: `injected/docs/platform-integration.md`
9+
- **Platform Integration and engine support**: `injected/docs/platform-integration.md`
1010
- **Development Utilities**: `injected/docs/development-utilities.md`
1111
- **Testing**: `injected/docs/testing-guide.md`
1212
- **Favicon**: `injected/docs/favicon.md`

injected/README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ Content Scope Scripts provides a unified API for browser privacy features across
1818

1919
## Key Concepts
2020

21+
### Project Structure
22+
23+
Content Scope Scripts contains two main sub-projects:
24+
25+
- **[Special Pages](../special-pages/)** - HTML/CSS/JS applications loaded into browsers (DuckPlayer, Release Notes, New Tab page, etc.)
26+
- **Injected Features** - Features injected into websites (privacy protections, compatibility fixes)
27+
28+
> **For Special Pages development**, see the [Special Pages README](../special-pages/README.md) for detailed getting started instructions.
29+
2130
### Features
2231
Features are JavaScript modules that implement privacy protections. Each feature:
2332
- Extends the `ConfigFeature` class for remote configuration support
@@ -65,13 +74,9 @@ npm run fake-extension # Runs an example extension used within the integration t
6574
- `unit-test/` - Unit test suite
6675
- `integration-test/` - Integration test suite
6776

68-
## Third-Party Libraries
69-
- [Adguard Scriptlets](https://github.com/AdguardTeam/Scriptlets)
70-
71-
---
77+
> **For detailed development setup instructions, debugging tips, and test build workflows, see the [Development Utilities](./docs/development-utilities.md) and [Testing Guide](./docs/testing-guide.md).**
7278
7379
## Third-Party Libraries
74-
We make use of the following submodules:
75-
- [Adguard Scriptlets](https://github.com/AdguardTeam/Scriptlets)
80+
- [Adguard Scriptlets](https://github.com/AdguardTeam/Scriptlets)
7681

7782
For detailed information about any specific topic, please refer to the [documentation](./docs/).

injected/docs/development-utilities.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,77 @@
44

55
To handle the difference in scope injection we expose multiple utilities which behave differently per browser in `src/utils.js` and `ContentFeature` base class. 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.
66

7+
## Development Setup
8+
9+
### Repository Access
10+
11+
1. **Clone the repository**: `https://github.com/duckduckgo/content-scope-scripts`
12+
2. **Request write-access** (for contributors): Submit a request via [Internal Support README](https://app.asana.com/1/137249556945/project/908478224964033/task/1209367367171662?focus=true) asking for `https://github.com/orgs/duckduckgo/teams/core` group access
13+
14+
### Local Development Setup
15+
16+
**Important**: Before cloning the repo on Windows, to avoid major headaches, make sure you clone it with unix-style line endings:
17+
18+
```shell
19+
git clone --config core.autocrlf=false https://github.com/duckduckgo/content-scope-scripts
20+
```
21+
22+
The Content Scope Scripts repo includes the build artifacts, which need to be generated as part of your commit.
23+
24+
### Initial Setup
25+
26+
Inside the repo, run:
27+
28+
```shell
29+
npm ci # Preferred over 'npm install' for accurate lockfile updates
30+
```
31+
32+
Ensure you have a version of node that matches what's in the `.nvmrc` file.
33+
34+
Now, to ensure everything's setup, try a full build:
35+
36+
```shell
37+
npm run build
38+
```
39+
40+
This will place built files into the top-level `build` folder. If this command ran successfully, you can continue with development.
41+
42+
### Windows Development
43+
44+
The tools should work on Windows, but if you have problems you _may_ wish to try using WSL.
45+
46+
**Optional:**: Use Windows Subsystem for Linux - [WSL Installation Guide](https://learn.microsoft.com/en-us/windows/wsl/install)
47+
48+
Once you have WSL running, make sure you have node and make installed:
49+
50+
```shell
51+
sudo apt update
52+
sudo apt install make
53+
```
54+
55+
For Node.js installation: [How to Install Node.js on Ubuntu/Debian](https://computingforgeeks.com/how-to-install-node-js-on-ubuntu-debian/)
56+
57+
Once node is installed, navigate to the repo path (e.g., `/mnt/c/dev/git/content-scope-scripts`) and:
58+
59+
```shell
60+
npm install # Install packages
61+
npm run build # Build JS artifacts
62+
```
63+
64+
After this, you can commit the generated files from your Windows environment through the usual git tools.
65+
66+
### Docker Alternative
67+
68+
If you don't want to install npm on your machine, you can use Docker instead:
69+
70+
```shell
71+
docker run -it --rm -v "<repo root>/submodules/content-scope-scripts:/content-scope-scripts" node:latest /bin/bash
72+
73+
root@<id>:/# cd /content-scope-scripts
74+
root@<id>:/content-scope-scripts# npm install
75+
root@<id>:/content-scope-scripts# npm run build
76+
```
77+
778
## ContentFeature Utilities
879

980
### `ContentFeature.defineProperty(object, propertyName, descriptor)`

injected/docs/platform-integration.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,41 @@
44

55
The [injected/entry-points/](https://github.com/duckduckgo/content-scope-scripts/tree/main/injected/entry-points) directory handles platform specific differences and is glue code into calling the contentScopeFeatures API.
66

7+
## Browser Compatibility
8+
9+
The following is a guideline for when using native JavaScript syntax or built-in global DOM objects. Testing is always advised, but code authors might be unable to replicate the code on the correct application environments (due to hardware or an updated local environment).
10+
11+
### Minimum Supported Engines
12+
13+
#### iOS
14+
15+
- **Safari 14** (minimum)
16+
- **Minimum support**: iOS 14 - [Review supported device and iOS versions](https://support.apple.com/en-us/102662)
17+
- **Engine**: WKWebView should behave like Safari 14 as this is the native engine
18+
19+
#### macOS
20+
21+
- **Safari 14** (minimum)
22+
- **Minimum support**: Catalina (potentially Safari 14 is native engine in non-updated device)
23+
- **Engine**: WKWebView should behave like Safari 14
24+
25+
#### Android
26+
27+
- **Android 23** (minimum) - [Product feedback request: Android - min supported version](https://app.asana.com/1/137249556945/project/908478224964033/task/1209367367171662?focus=true)
28+
- **Chrome 80+** (minimum)
29+
- **Reference**: See [pixel dashboard](https://app.asana.com/1/137249556945/project/908478224964033/task/1209367367171662?focus=true)
30+
31+
#### Windows
32+
33+
- **Edge-based** behavior expected
34+
- **Minimum**: Chrome 83 (if client has disabled all updates)
35+
- **Reference**: [Windows Browser: Minimum specs](https://app.asana.com/1/137249556945/project/908478224964033/task/1209367367171662?focus=true)
36+
37+
#### Extensions
38+
39+
- **Chrome**: Version 96+ - [Chrome manifest reference](https://github.com/duckduckgo/duckduckgo-privacy-extension/blob/249d8d6ebe38b9b8265ba311909c8971c422122c/browsers/chrome/manifest.json#L6)
40+
- **Firefox**: Version 91+ - [Firefox manifest reference](https://github.com/duckduckgo/duckduckgo-privacy-extension/blob/249d8d6ebe38b9b8265ba311909c8971c422122c/browsers/firefox/manifest.json#L6)
41+
742
## Platform-Specific Implementation Details
843

944
### Firefox

injected/docs/testing-guide.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,21 @@ To produce all artefacts that are used by platforms, just run the `npm run build
5050
```shell
5151
npm run build
5252
```
53+
54+
## Test Builds for Ship Review
55+
56+
Test builds are created with a GitHub workflow. The assets for Content Scope Scripts will be created on demand if they are absent (which they will be, if you're pointing to a branch of CSS).
57+
58+
1. Commit any changes to CSS and push a branch to the remote
59+
2. Make sure you commit the submodule reference update in the Windows PR
60+
3. Continue with "Build an installer for ship review / test"
61+
62+
## Debugging
63+
64+
### Adding Breakpoints
65+
66+
If you drop a `debugger;` line in the scripts and open DevTools window, the DevTools will breakpoint and navigate to that exact line in code when the debug point has been hit.
67+
68+
### Verifying CSS is Loaded
69+
70+
Open DevTools, go to the Console tab and enter `navigator.duckduckgo`. If it's defined, then Content Scope Scripts is running.

special-pages/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,68 @@
1+
# Special Pages
2+
3+
## Overview
4+
5+
Special Pages gives us a single place to implement isolated HTML/CSS/Javascript projects that can be loaded into a web context that has privileged access to API.
6+
7+
## Getting Started with Special Pages Development
8+
9+
### Prerequisites
10+
11+
Before starting Special Pages development, ensure you have completed the initial setup:
12+
13+
> **Repository access and initial setup**: See [Development Utilities - Development Setup](../injected/docs/development-utilities.md#development-setup) for repository access, cloning, and initial build setup.
14+
15+
### Step 1: Make a Change to the 'Example' Special Page
16+
17+
Edit the file `App.jsx` within `special-pages/pages/example/app/components`
18+
19+
### Step 2: Rebuild
20+
21+
Since Content Scope Scripts contains additional projects, you can just rebuild the special-pages parts:
22+
23+
```shell
24+
cd special-pages
25+
npm run build
26+
```
27+
28+
### Step 3: Review Your Change
29+
30+
Still within `special-pages`, you can now serve the built pages:
31+
32+
```shell
33+
npm run serve
34+
```
35+
36+
Then access the Example page you edited via: `http://127.0.0.1:3210/example/`
37+
38+
> **Note**: The output of the build command is just plain HTML/CSS/JS, so you can serve the build directory in any way that suits you.
39+
40+
### Step 4: Watch Mode
41+
42+
The build command builds every special page, but to run just 1 in isolation:
43+
44+
```shell
45+
npm run watch -- --page=<page-directory-name>
46+
```
47+
48+
Check the terminal for the dev URL, but it's normally `localhost:8000`.
49+
50+
> **Note**: Any changes you make here will not be automatically reflected in the build folder output.
51+
52+
### Step 5: Create a PR + Preview the Change
53+
54+
Content Scope Scripts uses Netlify preview deployments, so opening a PR will create a preview URL.
55+
56+
During the deployment:
57+
- Docs are generated
58+
- All special pages are built
59+
60+
When you access the Netlify URL, you'll land on the docs homepage. Append `/build/pages/example` to the URL to see the changes you made to the Example application.
61+
62+
**Example URLs:**
63+
- Preview: `https://content-scope-scripts.netlify.app/build/pages/example/`
64+
- Production: `https://content-scope-scripts.netlify.app`
65+
166
## Architecture
267

368
Special Pages gives us a single place to implement isolated HTML/CSS/Javascript projects that can be loaded into a web context that has privileged access to API.

0 commit comments

Comments
 (0)