-
Notifications
You must be signed in to change notification settings - Fork 333
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
Scriptlets are injected too late on website reload/navigation #2855
Comments
I guess that the problem might be like mentioned here - AdguardTeam/AdguardFilters#182479 (comment) Steps to reproduce:
fiddle.jshell.net#%#//scriptlet('set-constant', 'alert', 'noopFunc')
fiddle.jshell.net#%#debugger; 2 Go to - https://jsfiddle.net/1tmha0g8/ Code:<script>
debugger;
alert(1);
</script> Alert dialog should be prevented by scriptlet. On "hard reload", scriptlet is injected in time, but when I click on "Run" button or reload website then almost always rules are injected too late. VideoScreen.Recording.2024-06-29.121904.mp4I have checked old version 4.2.110 and it doesn't occur in this version (I have checked this version, because it was easy to download it from - https://github.com/AdguardTeam/AdguardBrowserExtension/releases, newer versions require to build them). |
Also happens on first visit too. Another issue: AdguardTeam/AdguardFilters#182571 Refresh the page (no hard refresh) anti-adblock appears and some rare popups. Update: This issue a bit different (may not related), take a look this video: Video
Trigger.mp4Update 2: After some test, yes it's related. See the video: Video 2
trigger.2.mp4Update 3: On this comment, somehow issue has been fixed, see: AdguardTeam/AdguardFilters#182902 |
Possibility another one: AdguardTeam/AdguardFilters#182802 |
Just tested again 4.1.55 vs 4.3.53 see the video: Video
uzay.manga.mp4This is a serious issue as end user. |
Another issue: AdguardTeam/AdguardFilters#182795 Tested AdGuard extension v4.1.55 vs v4.3.53 see the video: Video
dizikorea.vip.mp4I think different sites and different tests are enough. 😄 |
Another issue AdguardTeam/AdguardFilters#183315. cety.app#%#//scriptlet('prevent-addEventListener', 'click', 'openPopup')
cety.app#%#//scriptlet('set-constant', 'openPopup', 'noopFunc')
cety.app#%#//scriptlet('remove-node-text', 'script', 'openPopup') To reproduce this, you should add the exception |
AdguardTeam/AdguardFilters#183713
|
This is a valid issue. We were trying to be too smart about injecting scriptlets. Here's what we do now:
We made this too complicated while the proper solution is much, much easier. Just do this: const injectDoTalogo = (tabId, injectDetails, attemptNumber = 0) => {
console.log(`injecting to ${tabId}, attempt ${attemptNumber}`);
// Use some reasonably big number, 100 or 1000.
if (attemptNumber >= 100) {
console.log('Stop trying, something is very wrong');
}
chrome.tabs.executeScript(tabId, injectDetails, () => {
if (chrome.runtime.lastError) {
injectDoTalogo(tabId, injectDetails, attemptNumber + 1);
} else {
console.log('Now we need to clean up');
}
});
};
chrome.webRequest.onResponseStarted.addListener((details) => {
if (details.type !== 'main_frame') {
return;
}
injectDoTalogo(details.tabId, {
code: 'console.log(new Date().getTime() + " executing scripts!")',
frameId: details.frameId,
runAt: 'document_start',
matchAboutBlank: true,
});
}, { urls: ['<all_urls>'] }); My testing shows that it guarantees the fastest injection. It also simplifies the code a lot. You can test it here: Add this rule to AG to see the difference: |
This issue causes many problems. Like in reporting and even solving the problem. See: AdguardTeam/AdguardFilters@516850f I hope it gets fixed as soon as possible. 😄 |
Same problem from time to time |
Please answer the following questions for yourself before submitting an issue
AdGuard Extension version
4.3.53
Browser version
Chrome 126.0.6478.127
OS version
Windows 10
Ad Blocking
AdGuard Base filter
Privacy
AdGuard Tracking Protection filter, AdGuard URL Tracking filter
Social
AdGuard Social Media filter
Annoyances
AdGuard Annoyances filter
Security
No response
Other
No response
Language-specific
AdGuard Turkish filter
What Stealth Mode options do you have enabled?
No response
Issue Details
First of all, the issue was that pop-ups were appearing on different sites when they were first opened or in certain situations and when I wanted to verify the issue again at same time, I could not reproduce it, so I did a test.
During the testing phase, I only used AdGuard filters in the uBO extension. There seems to be a issue with the AdGuard extension. It can also be noticed that the uBO extension functions faster and more fluidly than the AdGuard extension.
Steps to reproduce:
Expected Behavior
The AdGuard extension does not leak pop-ups.
Actual Behavior
The AdGuard extension leaks pop-ups.
Videos
AdGuard
AdGuard.P.mp4
uBO
uBO.P.mp4
Additional Information
No response
The text was updated successfully, but these errors were encountered: