Skip to content
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

Change consent to pending to avoid youtube tracking #2207

Closed
wants to merge 1 commit into from

Conversation

unixfox
Copy link
Member

@unixfox unixfox commented Jun 25, 2021

This is a PR that is part of fixing #2191.

We don't have to accept the YouTube consent, we can set it to pending with a random number after, and it works.

The major drawback of doing that is that we need to append ucbcb=1 to every request that requires the consent to be either pending (PENDING) or accept (YES).

I tried to cover all the needed URLs, but I probably missed some of them. So that's why the PR is still a draft and I need help for finding all the part of the code that I would have missed.

@unixfox unixfox added the help wanted Extra attention is needed label Jun 25, 2021
@unixfox unixfox changed the title Change consent to pending to avoid tracking Change consent to pending to avoid youtube tracking Jun 25, 2021
@@ -10,7 +10,7 @@ def add_yt_headers(request)
request.headers["x-youtube-client-name"] ||= "1"
request.headers["x-youtube-client-version"] ||= "2.20200609"
# Preserve original cookies and add new YT consent cookie for EU servers
request.headers["cookie"] = "#{request.headers["cookie"]?}; CONSENT=YES+"
request.headers["cookie"] = "#{request.headers["cookie"]?}; CONSENT=PENDING+#{Random.new.rand(900)}"
Copy link
Member

@SamantazFox SamantazFox Jun 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch out, the random number should be >=100 and <= 999!
See what the peeps at NewPipe did

Copy link
Contributor

@B0pol B0pol Jun 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how that happened but it can be over 1000, it is sometimes over 100 000

Oh, okay. I've never seen it being over 3 digits on youtube

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should go with Random.new.rand(100..999) for now, so we can merge this PR and change that later, if needed...

@SamantazFox
Copy link
Member

Can you please rebase this changes on master?

@unixfox
Copy link
Member Author

unixfox commented Aug 12, 2021

Youtube doesn't block the real HTML page anymore, so we probably may remove the CONSENT cookie at all:
image

@TheFrenchGhosty TheFrenchGhosty added the unfinished More work is needed on this PR, or on something this PR uses. label Oct 3, 2021
@syeopite
Copy link
Member

Closable?

@unixfox
Copy link
Member Author

unixfox commented Nov 17, 2021

Like I said on matrix if you really want to close it then feel free to do it. It doesn't hurt to let it open.

@syeopite syeopite closed this Nov 18, 2021
return42 pushed a commit to return42/searxng that referenced this pull request Jul 25, 2022
This change the previous bypass method for Google consent using
``ucbcb=1`` (6face21) to accept the consent using ``CONSENT=YES+``.

The youtube_noapi and google have a similar API, at least for the consent[1].

Get CONSENT cookie from google reguest::

    curl -i "https://www.google.com/search?q=time&tbm=isch" \
         -A "Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101 Firefox/102.0" \
         | grep -i consent
    ...
    location: https://consent.google.com/m?continue=https://www.google.com/search?q%3Dtime%26tbm%3Disch&gl=DE&m=0&pc=irp&uxe=eomtm&hl=en-US&src=1
    set-cookie: CONSENT=PENDING+936; expires=Wed, 24-Jul-2024 11:26:20 GMT; path=/; domain=.google.com; Secure
    ...

PENDING & YES [2]:

  Google change the way for consent about YouTube cookies agreement in EU
  countries. Instead of showing a popup in the website, YouTube redirects the
  user to a new webpage at consent.youtube.com domain ...  Fix for this is to
  put a cookie CONSENT with YES+ value for every YouTube request

[1] iv-org/invidious#2207
[2] TeamNewPipe/NewPipeExtractor#592

Closes: searxng#1432
kvch pushed a commit to kvch/searx that referenced this pull request Jul 30, 2022
This change the previous bypass method for Google consent using
``ucbcb=1`` (6face21) to accept the consent using ``CONSENT=YES+``.

The youtube_noapi and google have a similar API, at least for the consent[1].

Get CONSENT cookie from google reguest::

    curl -i "https://www.google.com/search?q=time&tbm=isch" \
         -A "Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101 Firefox/102.0" \
         | grep -i consent
    ...
    location: https://consent.google.com/m?continue=https://www.google.com/search?q%3Dtime%26tbm%3Disch&gl=DE&m=0&pc=irp&uxe=eomtm&hl=en-US&src=1
    set-cookie: CONSENT=PENDING+936; expires=Wed, 24-Jul-2024 11:26:20 GMT; path=/; domain=.google.com; Secure
    ...

PENDING & YES [2]:

  Google change the way for consent about YouTube cookies agreement in EU
  countries. Instead of showing a popup in the website, YouTube redirects the
  user to a new webpage at consent.youtube.com domain ...  Fix for this is to
  put a cookie CONSENT with YES+ value for every YouTube request

[1] iv-org/invidious#2207
[2] TeamNewPipe/NewPipeExtractor#592

Closes: searxng/searxng#1432
kvch added a commit to searx/searx that referenced this pull request Jul 30, 2022
* [fix] google engine: results XPath

* [fix] google & youtube - set EU consent cookie

This change the previous bypass method for Google consent using
``ucbcb=1`` (6face21) to accept the consent using ``CONSENT=YES+``.

The youtube_noapi and google have a similar API, at least for the consent[1].

Get CONSENT cookie from google reguest::

    curl -i "https://www.google.com/search?q=time&tbm=isch" \
         -A "Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101 Firefox/102.0" \
         | grep -i consent
    ...
    location: https://consent.google.com/m?continue=https://www.google.com/search?q%3Dtime%26tbm%3Disch&gl=DE&m=0&pc=irp&uxe=eomtm&hl=en-US&src=1
    set-cookie: CONSENT=PENDING+936; expires=Wed, 24-Jul-2024 11:26:20 GMT; path=/; domain=.google.com; Secure
    ...

PENDING & YES [2]:

  Google change the way for consent about YouTube cookies agreement in EU
  countries. Instead of showing a popup in the website, YouTube redirects the
  user to a new webpage at consent.youtube.com domain ...  Fix for this is to
  put a cookie CONSENT with YES+ value for every YouTube request

[1] iv-org/invidious#2207
[2] TeamNewPipe/NewPipeExtractor#592

Closes: searxng/searxng#1432

* [fix] sjp engine - convert enginename to a latin1 compliance name

The engine name is not only a *name* its also a identifier that is used in
logs, HTTP headers and more.  Unicode characters in the name of an engine could
cause various issues.

Closes: searxng/searxng#1544
Signed-off-by: Markus Heiser <[email protected]>

* [fix] engine tineye: handle 422 response of not supported img format

Closes: searxng/searxng#1449
Signed-off-by: Markus Heiser <[email protected]>

* bypass google consent with ucbcb=1

* [mod] Adds Lingva translate engine

Add the lingva engine (which grabs data from google translate).  Results from
Lingva are added to the infobox results.

* openstreetmap engine: return the localized named.

For example: display "Tokyo" instead of "東京都" when the language is English.

* [fix] engines/openstreetmap.py typo: user_langage --> user_language

Signed-off-by: Markus Heiser <[email protected]>

* Wikidata engine: ignore dummy entities

* Wikidata engine: minor change of the SPARQL request

The engine can be slow especially when the query won't return any answer.
See https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/MWAPI#Find_articles_in_Wikipedia_speaking_about_cheese_and_see_which_Wikibase_items_they_correspond_to

Co-authored-by: Léon Tiekötter <[email protected]>
Co-authored-by: Emilien Devos <[email protected]>
Co-authored-by: Markus Heiser <[email protected]>
Co-authored-by: Emilien Devos <[email protected]>
Co-authored-by: ta <[email protected]>
Co-authored-by: Alexandre Flament <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed unfinished More work is needed on this PR, or on something this PR uses.
Projects
Status: Work In progress
Development

Successfully merging this pull request may close these issues.

5 participants