Scriptlets icon indicating copy to clipboard operation
Scriptlets copied to clipboard

Fix 'trusted-click-element' — scriptlet does not work on fast-growing-trees.com

Open rthfhgyhy567 opened this issue 10 months ago • 4 comments

Prerequisites

  • [x] This site DOES NOT contain sexually explicit material, otherwise use NSFW-specific form;
  • [x] Filters were updated before reproducing an issue;
  • [x] AdGuard product version is up-to-date;
  • [x] Browser version is up-to-date;
  • [x] If the site or app is broken, disabling AdGuard protection resolves an issue.

What product do you use?

Other ad blocker

AdGuard version

Ublock

What type of problem have you encountered?

Annoyances — pop-ups, cookie warnings, etc.

Which browser(s) do you use?

Chrome

Which device do you use?

Mobile

Where is the problem encountered?

https://www.fast-growing-trees.com/products/austrian-pine-tree?variant=13940888961076&utm_source=google_shopping&utm_medium=organic&region_id=000036&gQT=1

Ad Blocking

EasyList

Annoyances

AdGuard Annoyances filter

Add your comment and screenshots

Screenshot 1:

Image

Privacy

  • [x] I agree to follow this condition

rthfhgyhy567 avatar Apr 26 '25 19:04 rthfhgyhy567

Caused by a bug https://github.com/AdguardTeam/CoreLibs/issues/1953

Alex-302 avatar Apr 29 '25 13:04 Alex-302

Image

I still notice this pop up with the latest filters version

rthfhgyhy567 avatar Jun 19 '25 21:06 rthfhgyhy567

The rule to close the popup does not work.

fast-growing-trees.com#%#//scriptlet('trusted-click-element', 'form[aria-label="Welcome offer for new customers"] > button[value="verify"] + button')

or with 3s delay

fast-growing-trees.com#%#//scriptlet('trusted-click-element', 'form[aria-label="Welcome offer for new customers"] > button[value="verify"] + button', '', '3000')

Alex-302 avatar Jun 20 '25 10:06 Alex-302

It seems that the problem is that website removes content by something like:

document.removeChild(document.documentElement);

and due to this observed element does not exist, so later when popup element is added to new created content, it's not clicked.


In the case if website will change something. Steps to reproduce

  1. Add this rule:
example.org#%#//scriptlet('trusted-click-element', '#myButton')
  1. Go to - https://example.org/
  2. In browser console run:
const removeContentAndAddButton = () => {
    const doc = document;
    const clone = doc.documentElement.cloneNode(true);

    doc.removeChild(doc.documentElement);
    doc.appendChild(clone);

    const button = document.createElement('button');
    button.textContent = 'Click me';
    button.id = 'myButton';
    button.onclick = () => alert('Button clicked!');
    doc.body.appendChild(button);
};

removeContentAndAddButton();

Button is not clicked.

It works if element is just added like (keep in mind that mutationObserver is disconnected automatically after 10 seconds):

const addButton = () => {
    const button = document.createElement('button');
    button.textContent = 'Click me';
    button.id = 'myButton';
    button.onclick = () => alert('Button clicked!');
    document.body.appendChild(button);
};

addButton();

Probably to fix it, we could change document.documentElement to document here: https://github.com/AdguardTeam/Scriptlets/blob/d12f6bf7f1cec5c54a83677a01f2485211adf40e/src/scriptlets/trusted-click-element.ts#L511

AdamWr avatar Jun 20 '25 11:06 AdamWr