I'm trying to use DNR to force safe search with Qwant search engine.
Under certain circumstances (scenario described below) the search is performed with an API which contains the safe search level in a URL parameter. A typical query URL is https://api.qwant.com/v3/search/web?q=test&count=10&locale=fr_FR&offset=0&device=desktop&tgp=1&safesearch=0&displayed=true&llm=true
.
I want a DNR rule to force safesearch
to be 2 (= strict) (from some javascript code) :
{
id: 1,
priority: 1,
action: {
type: 'redirect',
"redirect": {
"transform": {
"queryTransform": {
"addOrReplaceParams": [{ "key": "safesearch", "value": "2" }]
}
}
}
},
condition: { "urlFilter": "api.qwant.com/v3/search", "resourceTypes": ["xmlhttprequest"] },
}
When this rule is activated, I end up with a URL with the original safesearch
parameter AND the forced one : https://api.qwant.com/v3/search/web?q=test&count=10&locale=fr_FR&offset=0&device=desktop&tgp=1&safesearch=0&displayed=true&llm=true&safesearch=2
.
To reproduce this request (with the previous DNR rule in place) :
- navigate to
https://www.qwant.com
- search for some string (
test
in my case). This displays the list of results ; - click the engine button at the top right to display the settings pane ;
- inspect network request performed by this page ;
- change the Adult filter in the list -> the results are automatically updated with the new settings. The web request shows URL with the 2
safesearch
parameters.
I already used addOrReplaceParams
in 'standard' contexts (main_frame) and it works just fine. Any hint on what goes on ?
Thank you.