AdguardTeam / Scriptlets

AdGuard scriptlets library
GNU General Public License v3.0
138 stars 27 forks source link

Improve 'trusted-click-element' — add an ability to click on an element containing a given text #409

Closed Sergey-Lyapin closed 1 month ago

Sergey-Lyapin commented 4 months ago

For example, to replace this rule with a scriptlet:

audioteka.com,jastrzabpost.pl,deliciousmagazine.pl,finansowysupermarket.pl,genialne.pl,pysznosci.pl,nocowanie.pl#%#AG_onLoad(function(){if(!(-1<document.cookie.indexOf("OAX")||"undefined"!=typeof localStorage&&null!==localStorage.getItem("crdab"))){var a=new MutationObserver(function(){var b=document.evaluate("//button[contains(text(), 'PRZECHODZ')]",document,null,XPathResult.ANY_TYPE,null).iterateNext();b&&(a.disconnect(),setTimeout(function(){b.click()},1E3))});a.observe(document,{childList:!0,subtree:!0});setTimeout(function(){a.disconnect()},1E4)}});

Something like: example.com#%#//scriptlet('trusted-click-element', 'button[name="agree"]', 'containsText:/agree|accept/')