3 ms·
OK, I suppose I could be slightly less lazy and read the source, which shows that you're iterating through the blacklist then iterating through the results page
by sequence7 6y ago
OK, I suppose I could be slightly less lazy and read the source, which shows that you're iterating through the blacklist then iterating through the results page and removing elements that match. There are some default offenders blacklisted automatically by the look of it, nice and simple.
var blacklist = new RegExp('https?:\/\/.*\.(geeksforgeeks|tutorialspoint).*\.*');
function clearURLs(urls) {
var i, j, arr, res, url;
arr = [];
res = document.querySelectorAll('div.rc');
for (i = 0; i < res.length; i++) {
for (j = 0; j < urls.blacklistURLs.length; j++) {
if (res[i].firstChild.firstChild.getAttribute('href').indexOf(urls.blacklistURLs[j]) !== -1) {
arr.push(i);
}
}
}
arr = [...new Set(arr)];
for (i = 0; i < arr.length; i++) {
url = res[arr[i]].firstChild.firstChild.getAttribute('href');
url = 'Wiper blacklisted URL: <a href="' + url + '">' + url + '</a>';
res[arr[i]].parentElement.innerHTML = url;
}
}
browser.storage.local.get('blacklistURLs').then(clearURLs);