Skip to content

PoC v5 #2948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: jkt/multiArray
Choose a base branch
from
Draft

PoC v5 #2948

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .github/scripts/diff-directories.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ function readFilesRecursively(directory) {

if (fileStats.isDirectory()) {
const nestedFiles = readFilesRecursively(filePath);
for (const [nestedFilePath, nestedFileContent] of Object.entries(nestedFiles)) {
for (const [
nestedFilePath,
nestedFileContent,
] of Object.entries(nestedFiles)) {
files[path.join(filename, nestedFilePath)] = nestedFileContent;
}
} else {
Expand Down Expand Up @@ -64,7 +67,10 @@ function displayDiffs(dir1Files, dir2Files, isOpen) {
rollupGrouping[summary].files.push(fileName);
rollupGrouping[summary].string = string;
}
for (const [filePath, fileContent] of Object.entries(dir1Files)) {
for (const [
filePath,
fileContent,
] of Object.entries(dir1Files)) {
let diffOut = '';
let compareOut;
if (filePath in dir2Files) {
Expand Down Expand Up @@ -145,7 +151,10 @@ const sections = {
latest: {},
};
function sortFiles(dirFiles, dirName) {
for (const [filePath, fileContent] of Object.entries(dirFiles)) {
for (const [
filePath,
fileContent,
] of Object.entries(dirFiles)) {
if (filePath.startsWith(`v${CURRENT_CONFIG_VERSION}`)) {
sections.latest[dirName] = sections.latest[dirName] || {};
sections.latest[dirName][filePath] = fileContent;
Expand All @@ -164,7 +173,10 @@ if (!fs.existsSync(`${dir1}/v${CURRENT_CONFIG_VERSION}`)) {
sortFiles(readFilesRecursively(dir1), 'dir1');
sortFiles(readFilesRecursively(dir2), 'dir2');

for (const [section, files] of Object.entries(sections)) {
for (const [
section,
files,
] of Object.entries(sections)) {
const isOpen = section === 'latest';
const fileOut = displayDiffs(files.dir1, files.dir2, isOpen);
console.log(renderDetails(section, fileOut, isOpen));
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/publish-test-url.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,23 @@ jobs:
id: generate_preview_links
run: |
PR_NUMBER=${{ github.event.pull_request.number || 'unknown' }}
// Import the config file
CONFIG_FILE="generated/v4/config.json"
if [ ! -f "$CONFIG_FILE" ]; then
echo "Config file not found: $CONFIG_FILE"
exit 1
fi
// Read the config file
CONFIG_CONTENT=$(cat "$CONFIG_FILE")
// Extract the config name
CURRENT_CONFIG_VERSION=$(echo "$CONFIG_CONTENT" | jq -r '.CURRENT_CONFIG_VERSION')
if [ -z "$CURRENT_CONFIG_VERSION" ]; then
echo "Config name not found in $CONFIG_FILE"
exit 1
fi
PREVIEW_LINKS=$(find generated/v4 -type f | while read -r file; do
RELATIVE_PATH=${file#generated/v4/}
echo "- [${RELATIVE_PATH}](https://${{ github.repository_owner }}.github.io/$(basename "${{ github.repository }}")/pr-${PR_NUMBER}/v4/${RELATIVE_PATH})"
echo "- [${RELATIVE_PATH}](https://${{ github.repository_owner }}.github.io/$(basename "${{ github.repository }}")/pr-${PR_NUMBER}/v${CURRENT_CONFIG_VERSION}/${RELATIVE_PATH})"
done)
LAST_UPDATED=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
echo "preview_links<<EOF" >> $GITHUB_OUTPUT
Expand Down
6 changes: 5 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"singleQuote": true,
"printWidth": 140,
"tabWidth": 4
"tabWidth": 4,
"multilineArraysWrapThreshold": 1,
"plugins": [
"prettier-plugin-multiline-arrays"
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ All feature files contain an `exceptions` property which contains a list of site

This repo also contains the code to build and deploy the configuration files.
These files (in the `generated` directory once built) are served from
https://staticcdn.duckduckgo.com/trackerblocking/config/v4/...
https://staticcdn.duckduckgo.com/trackerblocking/config/v5/...

Please see the [Related Resources](#Related-Resources) section for a list of
files used by each platform.
Expand Down
50 changes: 45 additions & 5 deletions compatibility.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
function versionToInt(version) {
// convert v2 to 2
return parseInt(version.replace('v', ''));
}

const { versionToInt, stripReasons } = require('./util.js');
/**
* Remove features from `config` that have reached their end of life.
* This function will also remove the `eol` key from features when it
Expand Down Expand Up @@ -117,9 +113,53 @@ const compatFunctions = {

return v3Config;
},
v4: (config) => {
// Breaking changes: none
const v4Config = JSON.parse(JSON.stringify(config));

// Remove exceptions from sub-features
for (const feature of Object.keys(v4Config.features)) {
const subFeatures = v4Config.features[feature].features;
if (subFeatures) {
for (const subFeature of Object.keys(subFeatures)) {
if (subFeatures[subFeature].exceptions) {
delete subFeatures[subFeature].exceptions;
}
}
}
}
// Remove description, rollout and targets from parent features
for (const feature of Object.keys(v4Config.features)) {
if (v4Config.features[feature].description) {
delete v4Config.features[feature].description;
}
if (v4Config.features[feature].rollout) {
delete v4Config.features[feature].rollout;
}
if (v4Config.features[feature].targets) {
delete v4Config.features[feature].targets;
}
}
// Ensure exceptions key is present for parent features
for (const feature of Object.keys(v4Config.features)) {
if (!v4Config.features[feature].exceptions) {
v4Config.features[feature].exceptions = [];
}
}

return v4Config;
},
};

const outputFilterFunctions = {
v4: (config) => {
stripReasons(config);
return config;
},
};

module.exports = {
removeEolFeatures,
outputFilterFunctions,
compatFunctions,
};
7 changes: 0 additions & 7 deletions constants.js

This file was deleted.

7 changes: 7 additions & 0 deletions constants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"CURRENT_CONFIG_VERSION": 5,
"OVERRIDE_DIR": "overrides",
"GENERATED_DIR": "generated",
"LISTS_DIR": "features",
"BROWSERS_SUBDIR": "browsers/"
}
4 changes: 3 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import json from 'eslint-plugin-json';
export default [
...ddgConfig,
{
files: ['**/*.json'],
files: [
'**/*.json',
],
...json.configs.recommended,
},
{
Expand Down
16 changes: 15 additions & 1 deletion features/amp-links.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@
"^https?:\\/\\/(?:w{3}\\.)?google\\.\\S{2,}\\/amp\\/s\\/(\\S+)$",
"^https?:\\/\\/\\S+ampproject\\.org\\/\\S\\/s\\/(\\S+)$"
],
"keywords": ["amp=", "=amp", "&amp", "amp&", "/amp", "amp/", ".amp", "amp.", "%amp", "amp%", "_amp", "amp_", "?amp"]
"keywords": [
"amp=",
"=amp",
"&amp",
"amp&",
"/amp",
"amp/",
".amp",
"amp.",
"%amp",
"amp%",
"_amp",
"amp_",
"?amp"
]
}
}
4 changes: 3 additions & 1 deletion features/autoconsent.json
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,9 @@
}
],
"settings": {
"disabledCMPs": ["healthline-media"],
"disabledCMPs": [
"healthline-media"
],
"filterlistExceptions": [
"google.ae",
"google.at",
Expand Down
8 changes: 6 additions & 2 deletions features/click-to-load.json
Original file line number Diff line number Diff line change
Expand Up @@ -898,10 +898,14 @@
],
"settings": {
"Facebook, Inc.": {
"ruleActions": ["block-ctl-fb"]
"ruleActions": [
"block-ctl-fb"
]
},
"Youtube": {
"ruleActions": ["block-ctl-yt"]
"ruleActions": [
"block-ctl-yt"
]
}
}
}
4 changes: 3 additions & 1 deletion features/click-to-play.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"settings": {
"Facebook": {
"clicksBeforeSimpleVersion": 3,
"ruleActions": ["block-ctl-fb"]
"ruleActions": [
"block-ctl-fb"
]
}
}
}
7 changes: 6 additions & 1 deletion features/cookie.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
"threshold": 604800,
"maxAge": 604800
},
"thirdPartyCookieNames": ["user_id", "__Secure-3PAPISID", "SAPISID", "APISID"]
"thirdPartyCookieNames": [
"user_id",
"__Secure-3PAPISID",
"SAPISID",
"APISID"
]
},
"exceptions": [
{
Expand Down
18 changes: 14 additions & 4 deletions features/duck-player.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,29 @@
"youtubePath": "watch",
"youtubeEmbedUrl": "youtube-nocookie.com",
"youTubeUrl": "youtube.com",
"youTubeReferrerHeaders": ["Referer"],
"youTubeReferrerQueryParams": ["embeds_referring_euri"],
"youTubeReferrerHeaders": [
"Referer"
],
"youTubeReferrerQueryParams": [
"embeds_referring_euri"
],
"youTubeVideoIDQueryParam": "v",
"overlays": {
"youtube": {
"state": "disabled",
"selectors": {
"thumbLink": "a[href^='/watch']",
"excludedRegions": ["#playlist", "ytd-movie-renderer", "ytd-grid-movie-renderer"],
"excludedRegions": [
"#playlist",
"ytd-movie-renderer",
"ytd-grid-movie-renderer"
],
"videoElement": "#player video",
"videoElementContainer": "#player .html5-video-player",
"hoverExcluded": [],
"clickExcluded": ["ytd-thumbnail-overlay-toggle-button-renderer"],
"clickExcluded": [
"ytd-thumbnail-overlay-toggle-button-renderer"
],
"allowedEventTargets": [
".ytp-inline-preview-scrim",
".ytd-video-preview",
Expand Down
28 changes: 25 additions & 3 deletions features/element-hiding.json
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,23 @@
"reason": "https://github.com/duckduckgo/privacy-configuration/pull/2821"
}
],
"hideTimeouts": [0, 100, 300, 500, 1000, 1500, 2000, 3000, 5000],
"unhideTimeouts": [1250, 2250, 3250, 5250],
"hideTimeouts": [
0,
100,
300,
500,
1000,
1500,
2000,
3000,
5000
],
"unhideTimeouts": [
1250,
2250,
3250,
5250
],
"mediaAndFormSelectors": "video,canvas,embed,object,audio,map,form,input,textarea,select,option",
"adLabelStrings": [
"ad",
Expand Down Expand Up @@ -1274,7 +1289,14 @@
]
},
{
"domain": ["ebay.com", "ebay.ca", "ebay.co.uk", "ebay.de", "ebay.fr", "ebay.com.au"],
"domain": [
"ebay.com",
"ebay.ca",
"ebay.co.uk",
"ebay.de",
"ebay.fr",
"ebay.com.au"
],
"rules": [
{
"selector": "#g-yolo-overlay-holder",
Expand Down
Loading
Loading