AdguardTeam / AdguardTeam/Scriptlets

Add new scriptlet — 'trusted-set-object-defineproperty'

Aperta
#421 1 commento 1 reazione 1 assegnatario Rivendicata da @maximtop Vedi su GitHub
Feature request Priority: P4
Lingua principale
JavaScript
Stelle
195
Fork
33
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Introduction

Since Netflix uses `Object.defineProperty` to define functions related to advertisement [^1], it seems that new scriptlet setting inbound and outbound of `Object.defineProperty` and `Object.defineProperties` is required for the advanced filtering quality.
Also, bundlers and transpilers like Babel often use `Object.defineProperty` to emulate certain ES6+ features in a way that's compatible with older JavaScript environments as GitHub Copilot said.

Screenshot

![Screenshot from 2024-04-04 20-41-00](https://github.com/AdguardTeam/Scriptlets/assets/98787049/ad805881-50cf-4153-b4e6-eb8f18f88806)


[^1]: https://github.com/AdguardTeam/AdguardFilters/pull/135052

### Proposed Syntax
```adblock
example.org#%#//scriptlet('trusted-set-object-defineproperty', [NonFunctionalBoolean [, ReturnAs [, FilledWith [, stack]]]])
```
- `NonFunctionalBoolean` — Non-functional comparative text like `Object.entries.name === 'entries'`. `_Inbound` (inbound argument for the mocked functions) and `_Outbound` (`Reflect.apply` result of the `object.defineproperty` or `object.defineproperties`) should be revealed in the non-functional comparative text to compare.
- `ReturnAs` — Like `value` argument of `set-constant` scriptlet, a returned value instead of the actual outbound result.
- `FilledWith` — (boolean) If it is true and the actual outbound result is `Object`, all entries of the object will be filled with `ReturnAs`. Otherwise, `FilledWith` argument will be ignored.

Usage with no arguments will log inbound arguments and outbound result to browser console.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.