Fix 'trusted-click-element' — scriptlet does not work on fast-growing-trees.com
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®ion_id=000036&gQT=1
Ad Blocking
EasyList
Annoyances
AdGuard Annoyances filter
Add your comment and screenshots
Screenshot 1:
Privacy
- [x] I agree to follow this condition
Caused by a bug https://github.com/AdguardTeam/CoreLibs/issues/1953
I still notice this pop up with the latest filters version
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')
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
- Add this rule:
example.org#%#//scriptlet('trusted-click-element', '#myButton')
- Go to - https://example.org/
- 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