JS help for beginner - Remove amazon sponsored results
You should try your code with the debug console (Ctrl-Alt-K). sponsored
is not a collection.
PS. Those elements can be blocked by "uBlock Origin", with the rule amazon.*###s-results-list-atf > .s-result-item:has(:scope > .s-item-container h5.s-sponsored-list-header)
in the built-in list "uBlock filters".
Thanks for the hint, I could now make it work like this:
function remSponsored() { var sponsored = document.getElementsByClassName("s-sponsored-list-header"); for (var i = 0; i < sponsored.length; i++) { sponsored[i].parentNode.parentNode.parentNode.parentNode.parentNode.setAttribute("style", "display:none;"); // yes, I want to overwrite and don't know if the "style" attribute is already present. Not using .style.display } console.log("GM Userscript: Advertising search results removed."); } remSponsored();
Although that uBlock rule might be another push for me to finally switch from ABP to uBO.
[SOLVED]
JS help for beginner - Remove amazon sponsored results
Hi,
the sponsored results in amazon search are only identifyable at a low level, so it is not possible to remove them with CSS / adblocker.
I'm a JS noob but still tried to write a script to remove the ads but I don't get a console output:
I'd appreciate if anyone could help.
Thanks,
Graphen