Re:Show HN: A Firefox add-on to strip Google search results ...
by sequence7 on Monday May 25, 2020 @06:05AM
(#23299638)
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);
> The plugin maintains a persistent and customizable list of URLs (keywords) that are used as a 'blacklist' for stripping results.
Could you explain a little more about how the stripping of the 'blacklist' works.