AdguardTeam / AdguardTeam/Scriptlets

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

Đang mở
#307 4 bình luận 0 reaction 1 người được giao Được giao cho @maximtop Xem trên GitHub
enhancement Priority: P4
Ngôn ngữ chính
JavaScript
Star
195
Fork
33
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### _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:

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.