Closed
Description
Here's the problem description:
- There are some applications that open new ad popups randomly.
- The problem is that we cannot handle them with
$popup
rules for several reasons. First, this may be a new browser instance (so the extension is not yet initialized and the popup rule does not match). Second, a new browser window is not counted as a popup. - Instead of that we could add a scriptlet rule that would handle those cases and simply close the window.
There's a real demand for that, see AceStream example:
https://github.com/AdguardTeam/AdguardFilters/issues?q=is%3Aissue+acestream
The solution would be to use this rule:
acestream.com[$path='/plan/select?popup=noads']#%#//scriplet('window-close')
Alternatively (for older versions of AdGuard) we should also allow specifying the path pattern in the parameter:
acestream.com#%#//scriplet('window-close', '/plan/select?popup=noads')
Also, I see a couple of rules in the filters that could be replaced with this new scriptlet (maybe there are more):
deloplen.com#%#!function(){setTimeout(function() { window.close(); }, 1000);}();
givirsou.net#%#window.close();
⚡️ window-close
This scriptlet immediately closes the browser tab.
Syntax
example.org#%#//scriptlet('window-close'[, path])
path
- optional, string or a regular expression that must match the current location's path (window.location.pathname + window.location.search
). If not specified, the scriptlet is executed on every page.
Examples
! Closes the window if it's URL is like `http(s)://example.org/path/param=value`:
`example.org#%#//scriplet('window-close', '/path/param=value')`
! Closes the window if it's URL is like `http(s)://example.org/0123.html`:
`example.org#%#//scriplet('window-close', '/[0-9]+.html/')`
Alternatively, instead of specifying path as a scriptlet parameter, you can use the $path
modifier:
! Closes the window if it's URL is like `http(s)://example.org/0123.html`:
`[$path=/[0-9]+.html/]example.org#%#//scriplet('window-close')`