Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent-addEventListener not working with jQuery #362

Closed
tumatanquang opened this issue Sep 28, 2023 · 1 comment
Closed

prevent-addEventListener not working with jQuery #362

tumatanquang opened this issue Sep 28, 2023 · 1 comment

Comments

@tumatanquang
Copy link

The AdGuard version I use: AdGuard AdBlock extension 4.2.162 for Google Chrome.

I wrote two rules to prevent the click event below:

Code 1:

$('#btn-download').click(function () {
     window.open('https://adsdomain.com/uuid-to-ads', '_blank');
 });

Rule: example.com#%#//scriptlet('prevent-addEventListener', 'click', 'window.open')
With the above rule, I want to block the click event when it contains window.open inside.
Rule: example.com#%#//scriptlet('prevent-addEventListener', 'click', 'adsdomain.com')
With the above rule, I want to block the click event when it contains adsdomain.com inside.
However, both of the above filter rules are inactive, the click event is still activated when it is clicked on the #btn-download.

Code 2:

$("#btn-download").click(function () {
    timeDownload = 30;
    countdownDownload();
    document.getElementById("btn-download").disabled = true;
    function countdownDownload() {
        timeDownload--;
        document.getElementById("download-media").innerHTML = String(timeDownload);
        if (timeDownload > 0) {
            setTimeout(countdownDownload, 1000);
        }
        else {
            document.getElementById("download-media").innerHTML = '<span>Download</span>';
            document.getElementById("btn-download").disabled = false;
        }
    };
});

Rule: example.com#%#//scriptlet('prevent-addEventListener', 'click', 'countdownDownload')
With the above rule, I want to block the click event when it contains countdownDownload inside.
Rule: example.com#%#//scriptlet('prevent-addEventListener', 'click', 'btn-download')
With the above rule, I want to block the click event when it contains btn-download inside.
The same situation is the same as the above case, they are not working, unable to prevent the click event added.

@maximtop
Copy link
Contributor

The issue arises because the actual function provided inside of the addEventListener doesn't contain the text specified in the scriptlet. I believe this can't be resolved unless a separate scriptlet for jQuery is created, though the likelihood of this happening seems low.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants