Update custom sites (search)

This commit is contained in:
magnolia1234 2024-03-26 17:31:50 +01:00
parent dd1f42d497
commit 7dd172c9e0
7 changed files with 36 additions and 6 deletions

View file

@ -1604,6 +1604,8 @@ ext_api.runtime.onMessage.addListener(function (message, sender) {
let article_new = doc.querySelector(message.data.selector_source);
if (article_new)
html = article_new.outerHTML;
else
html = '';
}
}
message.data.html = html;

View file

@ -4,6 +4,7 @@ Updates (install signed xpi-file): https://gitlab.com/magnolia1234/bypass-paywal
Post-release
Add Ringier Axel Springer Polska
Update custom sites (search)
* v3.6.1.0 (2024-03-24)
Add Blick.ch (Ringier Gruppe)

View file

@ -6561,6 +6561,7 @@ function getSelectorLevel(selector) {
function replaceDomElementExtSrc(url, url_src, html, proxy, base64, selector, text_fail = '', selector_source = selector, selector_archive = selector) {
let article = document.querySelector(selector);
let no_content_msg = ' | no article content found! | :';
if (html) {
if (!proxy && base64) {
html = decode_utf8(atob(html));
@ -6604,10 +6605,10 @@ function replaceDomElementExtSrc(url, url_src, html, proxy, base64, selector, te
}, 200);
}
} else
replaceTextFail(url, article, proxy, text_fail);
replaceTextFail(url, article, proxy, text_fail.replace(':', no_content_msg));
}, 200);
} else {
replaceTextFail(url, article, proxy, text_fail);
replaceTextFail(url, article, proxy, url_src ? text_fail.replace(':', no_content_msg) : text_fail);
}
}
@ -6618,7 +6619,7 @@ function replaceTextFail(url, article, proxy, text_fail) {
text_fail_div.appendChild(document.createTextNode(text_fail));
if (proxy) {
if (url.startsWith('https://archive.')) {
text_fail_div = archiveLink(url.replace(/^https:\/\/archive\.\w{2}\//, ''));
text_fail_div = archiveLink(url.replace(/^https:\/\/archive\.\w{2}\//, ''), text_fail);
} else {
let a_link = document.createElement('a');
a_link.innerText = url;

View file

@ -51,5 +51,5 @@
"webRequestBlocking",
"*://*/*"
],
"version": "3.6.1.1"
"version": "3.6.1.2"
}

View file

@ -867,5 +867,5 @@
"*://archive.vn/*",
"*://webcache.googleusercontent.com/*"
],
"version": "3.6.1.1"
"version": "3.6.1.2"
}

View file

@ -38,7 +38,8 @@
<button id="edit">Edit (re-Add)</button>
<button id="delete_default">Delete<br>default (*) sites</button>
<button id="perm_request">Request<br>permissions</button>
<button id="perm_remove">Remove<br>permissions</button><br>
<button id="perm_remove">Remove<br>permissions</button>
<input id="search" type="text" size="30" placeholder="Search (domain)name ..."><br><br>
permissions granted (for all in custom list + updated): <strong><span id="perm-custom"></span></strong>
</span>
<div style="clear:both;"></div>

View file

@ -510,6 +510,30 @@ function renderOptions() {
});
}
function handleSearch() {
let search = document.getElementById('search').value.toLowerCase().replace('www.', '');
let listItems = document.querySelectorAll('select#sites > option');
ext_api.storage.local.get({
sites_custom: {}
}, function (items) {
let sites_custom = items.sites_custom;
let grouped_sites = filterObject(sites_custom, function (val, key) {
return val.group
}, function (val, key) {
return [val.domain, val.group.split(',')]
});
for (let item of listItems) {
let itemDomain = sites_custom[item.value].domain;
let itemText = item.value.toLowerCase();
let itemGroup = itemDomain ? grouped_sites[itemDomain] : '';
if (itemText.includes(search) || (itemDomain.includes(search) || (itemGroup && itemGroup.includes(search))))
item.style.display = 'block';
else
item.style.display = 'none';
}
});
}
document.addEventListener('DOMContentLoaded', renderOptions);
document.getElementById('save').addEventListener('click', save_options);
document.getElementById('sort').addEventListener('click', sort_options);
@ -521,6 +545,7 @@ document.getElementById('add').addEventListener('click', add_options);
document.getElementById('delete').addEventListener('click', delete_options);
document.getElementById('delete_default').addEventListener('click', delete_default_options);
document.getElementById('edit').addEventListener('click', edit_options);
document.getElementById('search').addEventListener('input', handleSearch);
if (custom_switch) {
document.getElementById('perm_request').addEventListener('click', request_permissions);
document.getElementById('perm_remove').addEventListener('click', remove_permissions);