First lookup matching stock lists when importing URLs

Related discussion:
https://github.com/MasterKia/PersianBlocker/discussions/224
This commit is contained in:
Raymond Hill 2024-02-29 07:51:08 -05:00
parent b0067b79d5
commit 2b16a10b82
No known key found for this signature in database
GPG key ID: 25E1490B761470C2

View file

@ -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', {