AdguardTeam / AdguardTeam/Scriptlets

Improve 'trusted-set-cookie' and 'trusted-set-local-storage-item' — add ability to specify base64 as encoding

未关闭
#307 4 条评论 0 个 reaction 已指派 1 人 已指派给 @maximtop 在 GitHub 查看
enhancement Priority: P4
主要语言
JavaScript
星标
195
派生
33
PR 合并指标
30 天内没有已合并 PR

描述

### _Steps to reproduce_

1. Add this user rule:
```adblock
@@||www.coolblue.be^$important,document
```
2. Go to https://www.coolblue.be/en and [refuse cookies](https://user-images.githubusercontent.com/4764956/230755586-3b52a7e8-4529-402c-b671-b8ce3df5a483.png).
3. Observe the apparition of a new _**cookie-preferences**_ cookie with this value:
```
eyJmdW5jdGlvbmFsIjp0cnVlLCJhbmFseXRpY2FsIjp0cnVlLCJtYXJrZXRpbmciOmZhbHNlfQ%3D%3D
```

### _Goal_

Replacing this rule _(comment included)_:  **#ᴄʀʏᴘᴛɪᴄ**
```adblock
! Base64 value for: {"functional":true,"analytical":true,"marketing":false}
coolblue.be#%#//scriptlet('trusted-set-cookie', 'cookie-preferences',
'eyJmdW5jdGlvbmFsIjp0cnVlLCJhbmFseXRpY2FsIjp0cnVlLCJtYXJrZXRpbmciOmZhbHNlfQ==')
```

By this one _(self-explanatory for readers)_:  **#ᴛʀᴀɴꜱᴘᴀʀᴇɴᴛ**
```adblock
coolblue.be#%#//scriptlet('trusted-set-cookie', 'cookie-preferences',
'base64:{"functional":true,"analytical":true,"marketing":false}')
```
 
### _:writing_hand: Remarks_

1. Possibly use a dedicated parameter instead.

2. ~~Consider in addition a _variant_ that does not use [`encodeURIComponent`](https://github.com/AdguardTeam/Scriptlets/blob/8edd4ec246a3acac608d67975610de11f9b0d960/src/helpers/cookie-utils.js#L37) for storing **base64** value,
for some websites reading the string _directly_ in `atob`.~~
~~- That is, the stored value will therefore include `==` instead of `%3D%3D` at the end.~~

↪️ Variant not anymore required. All situations will be handled correctly if this commit is finally merged:
[get rid of encodeURIComponent for trusted-set-cookie-* scriptlets](https://github.com/AdguardTeam/Scriptlets/commit/d03e0284d61ecc8c425c2443902c6a8d54c17fd6).
_As raw/pure base64 value generated by AdGuard will always be readable by the website:
whether the latter uses for reading atob, atob+decodeURIComponent, etc._

3. Should also apply to:
- the similar one `trusted-set-cookie-reload`;
- and, ideally, `trusted-set-local-storage-item` too.

 
### Hi and thanks in advance! :v:

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。