From f6954430d1970ef54cc00bcd45cb6db52aa35f75 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 21 Jun 2023 09:11:21 -0400 Subject: [PATCH] Add support for sublist at any tree depth in "Filter lists" pane --- assets/assets.dev.json | 52 +++++++++++++++++++++++++++--------------- src/js/3p-filters.js | 13 ++++++----- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/assets/assets.dev.json b/assets/assets.dev.json index 25a6f8fbc..63b6a50f3 100644 --- a/assets/assets.dev.json +++ b/assets/assets.dev.json @@ -272,7 +272,7 @@ "adguard-cookies": { "content": "filters", "group": "annoyances", - "parent": "AdGuard – Annoyances", + "parent": "AdGuard – Annoyances|AdGuard/uBO – Cookie Notices", "off": true, "title": "AdGuard – Cookie Notices", "tags": "annoyances cookies", @@ -280,6 +280,22 @@ "supportURL": "https://github.com/AdguardTeam/AdguardFilters#adguard-filters", "instructionURL": "https://kb.adguard.com/en/general/adguard-ad-filters" }, + "ublock-cookies-adguard": { + "content": "filters", + "group": "annoyances", + "parent": "AdGuard – Annoyances|AdGuard/uBO – Cookie Notices", + "off": true, + "title": "uBlock filters – Cookie Notices", + "tags": "annoyances cookies", + "contentURL": "https://ublockorigin.github.io/uAssets/filters/annoyances-cookies.txt", + "cdnURLs": [ + "https://ublockorigin.github.io/uAssetsCDN/filters/annoyances-cookies.txt", + "https://ublockorigin.pages.dev/filters/annoyances-cookies.txt", + "https://cdn.jsdelivr.net/gh/uBlockOrigin/uAssetsCDN@main/filters/annoyances-cookies.txt", + "https://cdn.statically.io/gh/uBlockOrigin/uAssetsCDN/main/filters/annoyances-cookies.txt" + ], + "supportURL": "https://github.com/uBlockOrigin/uAssets" + }, "adguard-popup-overlays": { "content": "filters", "group": "annoyances", @@ -368,7 +384,7 @@ "fanboy-cookiemonster": { "content": "filters", "group": "annoyances", - "parent": "EasyList/uBO – Cookie Notices", + "parent": "EasyList – Annoyances|EasyList/uBO – Cookie Notices", "off": true, "title": "EasyList – Cookie Notices", "tags": "annoyances cookies", @@ -385,6 +401,22 @@ ], "supportURL": "https://github.com/easylist/easylist#fanboy-lists" }, + "ublock-cookies-easylist": { + "content": "filters", + "group": "annoyances", + "parent": "EasyList – Annoyances|EasyList/uBO – Cookie Notices", + "off": true, + "title": "uBlock filters – Cookie Notices", + "tags": "annoyances cookies", + "contentURL": "https://ublockorigin.github.io/uAssets/filters/annoyances-cookies.txt", + "cdnURLs": [ + "https://ublockorigin.github.io/uAssetsCDN/filters/annoyances-cookies.txt", + "https://ublockorigin.pages.dev/filters/annoyances-cookies.txt", + "https://cdn.jsdelivr.net/gh/uBlockOrigin/uAssetsCDN@main/filters/annoyances-cookies.txt", + "https://cdn.statically.io/gh/uBlockOrigin/uAssetsCDN/main/filters/annoyances-cookies.txt" + ], + "supportURL": "https://github.com/uBlockOrigin/uAssets" + }, "easylist-newsletters": { "content": "filters", "group": "annoyances", @@ -441,22 +473,6 @@ ], "supportURL": "https://easylist.to/" }, - "ublock-cookies": { - "content": "filters", - "group": "annoyances", - "parent": "EasyList/uBO – Cookie Notices", - "off": true, - "title": "uBlock filters – Cookie Notices", - "tags": "annoyances cookies", - "contentURL": "https://ublockorigin.github.io/uAssets/filters/annoyances-cookies.txt", - "cdnURLs": [ - "https://ublockorigin.github.io/uAssetsCDN/filters/annoyances-cookies.txt", - "https://ublockorigin.pages.dev/filters/annoyances-cookies.txt", - "https://cdn.jsdelivr.net/gh/uBlockOrigin/uAssetsCDN@main/filters/annoyances-cookies.txt", - "https://cdn.statically.io/gh/uBlockOrigin/uAssetsCDN/main/filters/annoyances-cookies.txt" - ], - "supportURL": "https://github.com/uBlockOrigin/uAssets" - }, "ublock-annoyances": { "content": "filters", "group": "annoyances", diff --git a/src/js/3p-filters.js b/src/js/3p-filters.js index ca249dd04..98fc477dd 100644 --- a/src/js/3p-filters.js +++ b/src/js/3p-filters.js @@ -236,13 +236,14 @@ const renderFilterLists = ( ) => { } const groupDetails = listTree[groupKey]; if ( listDetails.parent !== undefined ) { - if ( groupDetails.lists[listDetails.parent] === undefined ) { - groupDetails.lists[listDetails.parent] = { - title: listDetails.parent, - lists: {}, - }; + let lists = groupDetails.lists; + for ( const parent of listDetails.parent.split('|') ) { + if ( lists[parent] === undefined ) { + lists[parent] = { title: parent, lists: {} }; + } + lists = lists[parent].lists; } - groupDetails.lists[listDetails.parent].lists[listkey] = listDetails; + lists[listkey] = listDetails; } else { listDetails.title = listNameFromListKey(listkey); groupDetails.lists[listkey] = listDetails;