mirror of
https://github.com/gorhill/uBlock.git
synced 2025-01-31 20:21:35 +01:00
Add concept of "preferred" lists
Preferred lists will be visually listed above other lists.
This commit is contained in:
parent
7e48a03927
commit
61e916901b
@ -155,6 +155,7 @@
|
|||||||
"group": "ads",
|
"group": "ads",
|
||||||
"title": "EasyList",
|
"title": "EasyList",
|
||||||
"tags": "ads",
|
"tags": "ads",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": [
|
"contentURL": [
|
||||||
"https://ublockorigin.github.io/uAssets/thirdparties/easylist.txt",
|
"https://ublockorigin.github.io/uAssets/thirdparties/easylist.txt",
|
||||||
"assets/thirdparties/easylist/easylist.txt"
|
"assets/thirdparties/easylist/easylist.txt"
|
||||||
@ -205,6 +206,7 @@
|
|||||||
"group": "privacy",
|
"group": "privacy",
|
||||||
"title": "EasyPrivacy",
|
"title": "EasyPrivacy",
|
||||||
"tags": "privacy",
|
"tags": "privacy",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": [
|
"contentURL": [
|
||||||
"https://ublockorigin.github.io/uAssets/thirdparties/easyprivacy.txt",
|
"https://ublockorigin.github.io/uAssets/thirdparties/easyprivacy.txt",
|
||||||
"assets/thirdparties/easylist/easyprivacy.txt"
|
"assets/thirdparties/easylist/easyprivacy.txt"
|
||||||
@ -281,6 +283,7 @@
|
|||||||
"off": true,
|
"off": true,
|
||||||
"title": "EasyList – Cookie Notices",
|
"title": "EasyList – Cookie Notices",
|
||||||
"tags": "annoyances cookies",
|
"tags": "annoyances cookies",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": [
|
"contentURL": [
|
||||||
"https://ublockorigin.github.io/uAssets/thirdparties/easylist-cookies.txt",
|
"https://ublockorigin.github.io/uAssets/thirdparties/easylist-cookies.txt",
|
||||||
"https://secure.fanboy.co.nz/fanboy-cookiemonster_ubo.txt"
|
"https://secure.fanboy.co.nz/fanboy-cookiemonster_ubo.txt"
|
||||||
@ -302,6 +305,7 @@
|
|||||||
"off": true,
|
"off": true,
|
||||||
"title": "uBlock filters – Cookie Notices",
|
"title": "uBlock filters – Cookie Notices",
|
||||||
"tags": "annoyances cookies",
|
"tags": "annoyances cookies",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": "https://ublockorigin.github.io/uAssets/filters/annoyances-cookies.txt",
|
"contentURL": "https://ublockorigin.github.io/uAssets/filters/annoyances-cookies.txt",
|
||||||
"cdnURLs": [
|
"cdnURLs": [
|
||||||
"https://ublockorigin.github.io/uAssetsCDN/filters/annoyances-cookies.txt",
|
"https://ublockorigin.github.io/uAssetsCDN/filters/annoyances-cookies.txt",
|
||||||
@ -331,6 +335,7 @@
|
|||||||
"off": true,
|
"off": true,
|
||||||
"title": "EasyList – Social Widgets",
|
"title": "EasyList – Social Widgets",
|
||||||
"tags": "annoyances social",
|
"tags": "annoyances social",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": [
|
"contentURL": [
|
||||||
"https://ublockorigin.github.io/uAssets/thirdparties/easylist-social.txt",
|
"https://ublockorigin.github.io/uAssets/thirdparties/easylist-social.txt",
|
||||||
"https://secure.fanboy.co.nz/fanboy-social_ubo.txt"
|
"https://secure.fanboy.co.nz/fanboy-social_ubo.txt"
|
||||||
@ -405,6 +410,7 @@
|
|||||||
"off": true,
|
"off": true,
|
||||||
"title": "EasyList – Other Annoyances",
|
"title": "EasyList – Other Annoyances",
|
||||||
"tags": "annoyances",
|
"tags": "annoyances",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": "https://ublockorigin.github.io/uAssets/thirdparties/easylist-annoyances.txt",
|
"contentURL": "https://ublockorigin.github.io/uAssets/thirdparties/easylist-annoyances.txt",
|
||||||
"cdnURLs": [
|
"cdnURLs": [
|
||||||
"https://ublockorigin.github.io/uAssetsCDN/thirdparties/easylist-annoyances.txt",
|
"https://ublockorigin.github.io/uAssetsCDN/thirdparties/easylist-annoyances.txt",
|
||||||
@ -421,6 +427,7 @@
|
|||||||
"off": true,
|
"off": true,
|
||||||
"title": "EasyList – Chat Widgets",
|
"title": "EasyList – Chat Widgets",
|
||||||
"tags": "annoyances",
|
"tags": "annoyances",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": "https://ublockorigin.github.io/uAssets/thirdparties/easylist-chat.txt",
|
"contentURL": "https://ublockorigin.github.io/uAssets/thirdparties/easylist-chat.txt",
|
||||||
"cdnURLs": [
|
"cdnURLs": [
|
||||||
"https://ublockorigin.github.io/uAssetsCDN/thirdparties/easylist-chat.txt",
|
"https://ublockorigin.github.io/uAssetsCDN/thirdparties/easylist-chat.txt",
|
||||||
@ -437,6 +444,7 @@
|
|||||||
"off": true,
|
"off": true,
|
||||||
"title": "EasyList – Newsletter Notices",
|
"title": "EasyList – Newsletter Notices",
|
||||||
"tags": "annoyances",
|
"tags": "annoyances",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": [
|
"contentURL": [
|
||||||
"https://ublockorigin.github.io/uAssets/thirdparties/easylist-newsletters.txt"
|
"https://ublockorigin.github.io/uAssets/thirdparties/easylist-newsletters.txt"
|
||||||
],
|
],
|
||||||
@ -455,6 +463,7 @@
|
|||||||
"off": true,
|
"off": true,
|
||||||
"title": "EasyList – Notifications",
|
"title": "EasyList – Notifications",
|
||||||
"tags": "annoyances",
|
"tags": "annoyances",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": [
|
"contentURL": [
|
||||||
"https://ublockorigin.github.io/uAssets/thirdparties/easylist-notifications.txt"
|
"https://ublockorigin.github.io/uAssets/thirdparties/easylist-notifications.txt"
|
||||||
],
|
],
|
||||||
@ -497,6 +506,7 @@
|
|||||||
"updateAfter": 13,
|
"updateAfter": 13,
|
||||||
"title": "Peter Lowe’s Ad and tracking server list",
|
"title": "Peter Lowe’s Ad and tracking server list",
|
||||||
"tags": "ads privacy security",
|
"tags": "ads privacy security",
|
||||||
|
"preferred": true,
|
||||||
"contentURL": [
|
"contentURL": [
|
||||||
"https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext",
|
"https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext",
|
||||||
"assets/thirdparties/pgl.yoyo.org/as/serverlist.txt",
|
"assets/thirdparties/pgl.yoyo.org/as/serverlist.txt",
|
||||||
|
@ -19,11 +19,9 @@
|
|||||||
Home: https://github.com/gorhill/uBlock
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
import { onBroadcast } from './broadcast.js';
|
|
||||||
import { dom, qs$, qsa$ } from './dom.js';
|
import { dom, qs$, qsa$ } from './dom.js';
|
||||||
import { i18n, i18n$ } from './i18n.js';
|
import { i18n, i18n$ } from './i18n.js';
|
||||||
|
import { onBroadcast } from './broadcast.js';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@ -32,6 +30,10 @@ const obsoleteTemplateString = i18n$('3pExternalListObsolete');
|
|||||||
const reValidExternalList = /^[a-z-]+:\/\/(?:\S+\/\S*|\/\S+)/m;
|
const reValidExternalList = /^[a-z-]+:\/\/(?:\S+\/\S*|\/\S+)/m;
|
||||||
const recentlyUpdated = 1 * 60 * 60 * 1000; // 1 hour
|
const recentlyUpdated = 1 * 60 * 60 * 1000; // 1 hour
|
||||||
|
|
||||||
|
// https://eslint.org/docs/latest/rules/no-prototype-builtins
|
||||||
|
const hasOwnProperty = (o, p) =>
|
||||||
|
Object.prototype.hasOwnProperty.call(o, p);
|
||||||
|
|
||||||
let listsetDetails = {};
|
let listsetDetails = {};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -182,6 +184,9 @@ const renderFilterLists = ( ) => {
|
|||||||
if ( depth !== 0 ) {
|
if ( depth !== 0 ) {
|
||||||
const reEmojis = /\p{Emoji}+/gu;
|
const reEmojis = /\p{Emoji}+/gu;
|
||||||
treeEntries.sort((a ,b) => {
|
treeEntries.sort((a ,b) => {
|
||||||
|
const ap = a[1].preferred === true;
|
||||||
|
const bp = b[1].preferred === true;
|
||||||
|
if ( ap !== bp ) { return ap ? -1 : 1; }
|
||||||
const as = (a[1].title || a[0]).replace(reEmojis, '');
|
const as = (a[1].title || a[0]).replace(reEmojis, '');
|
||||||
const bs = (b[1].title || b[0]).replace(reEmojis, '');
|
const bs = (b[1].title || b[0]).replace(reEmojis, '');
|
||||||
return as.localeCompare(bs);
|
return as.localeCompare(bs);
|
||||||
@ -241,7 +246,7 @@ const renderFilterLists = ( ) => {
|
|||||||
}
|
}
|
||||||
for ( const [ listkey, listDetails ] of Object.entries(response.available) ) {
|
for ( const [ listkey, listDetails ] of Object.entries(response.available) ) {
|
||||||
let groupkey = listDetails.group2 || listDetails.group;
|
let groupkey = listDetails.group2 || listDetails.group;
|
||||||
if ( listTree.hasOwnProperty(groupkey) === false ) {
|
if ( hasOwnProperty(listTree, groupkey) === false ) {
|
||||||
groupkey = 'unknown';
|
groupkey = 'unknown';
|
||||||
}
|
}
|
||||||
const groupDetails = listTree[groupkey];
|
const groupDetails = listTree[groupkey];
|
||||||
@ -251,6 +256,9 @@ const renderFilterLists = ( ) => {
|
|||||||
if ( lists[parent] === undefined ) {
|
if ( lists[parent] === undefined ) {
|
||||||
lists[parent] = { title: parent, lists: {} };
|
lists[parent] = { title: parent, lists: {} };
|
||||||
}
|
}
|
||||||
|
if ( listDetails.preferred === true ) {
|
||||||
|
lists[parent].preferred = true;
|
||||||
|
}
|
||||||
lists = lists[parent].lists;
|
lists = lists[parent].lists;
|
||||||
}
|
}
|
||||||
lists[listkey] = listDetails;
|
lists[listkey] = listDetails;
|
||||||
@ -596,7 +604,7 @@ const selectFilterLists = async ( ) => {
|
|||||||
const toRemove = [];
|
const toRemove = [];
|
||||||
for ( const liEntry of qsa$('#lists .listEntry[data-role="leaf"]') ) {
|
for ( const liEntry of qsa$('#lists .listEntry[data-role="leaf"]') ) {
|
||||||
const listkey = liEntry.dataset.key;
|
const listkey = liEntry.dataset.key;
|
||||||
if ( listsetDetails.available.hasOwnProperty(listkey) === false ) {
|
if ( hasOwnProperty(listsetDetails.available, listkey) === false ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const listDetails = listsetDetails.available[listkey];
|
const listDetails = listsetDetails.available[listkey];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user