mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
First lookup matching stock lists when importing URLs
Related discussion: https://github.com/MasterKia/PersianBlocker/discussions/224
This commit is contained in:
parent
b0067b79d5
commit
2b16a10b82
1 changed files with 29 additions and 8 deletions
|
@ -530,6 +530,35 @@ dom.on('#lists', 'click', 'span.cache', onPurgeClicked);
|
|||
/******************************************************************************/
|
||||
|
||||
const selectFilterLists = async ( ) => {
|
||||
// External filter lists to import
|
||||
// Find stock list matching entries in lists to import
|
||||
const toImport = (( ) => {
|
||||
const textarea = qs$('#lists .listEntry[data-role="import"].expanded textarea');
|
||||
if ( textarea === null ) { return ''; }
|
||||
const lists = listsetDetails.available;
|
||||
const lines = textarea.value.split(/\s+\n|\s+/);
|
||||
const after = [];
|
||||
for ( const line of lines ) {
|
||||
if ( /^https?:\/\//.test(line) === false ) { continue; }
|
||||
for ( const [ listkey, list ] of Object.entries(lists) ) {
|
||||
if ( list.content !== 'filters' ) { continue; }
|
||||
if ( list.contentURL === undefined ) { continue; }
|
||||
if ( list.contentURL.includes(line) === false ) {
|
||||
after.push(line);
|
||||
continue;
|
||||
}
|
||||
const input = qs$(`[data-key="${list.group}"] [data-key="${listkey}"] > .detailbar input`);
|
||||
if ( input === null ) { break; }
|
||||
input.checked = true;
|
||||
toggleFilterList(input, true, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
dom.cl.remove(textarea.closest('.expandable'), 'expanded');
|
||||
textarea.value = '';
|
||||
return after.join('\n');
|
||||
})();
|
||||
|
||||
// Cosmetic filtering switch
|
||||
let checked = qs$('#parseCosmeticFilters').checked;
|
||||
vAPI.messaging.send('dashboard', {
|
||||
|
@ -569,14 +598,6 @@ const selectFilterLists = async ( ) => {
|
|||
}
|
||||
}
|
||||
|
||||
// External filter lists to import
|
||||
const textarea = qs$('#lists .listEntry[data-role="import"].expanded textarea');
|
||||
const toImport = textarea !== null && textarea.value.trim() || '';
|
||||
if ( textarea !== null ) {
|
||||
dom.cl.remove(textarea.closest('.expandable'), 'expanded');
|
||||
textarea.value = '';
|
||||
}
|
||||
|
||||
hashFromListsetDetails();
|
||||
|
||||
await vAPI.messaging.send('dashboard', {
|
||||
|
|
Loading…
Reference in a new issue