Repository navigation
Commit d7df476
committed
Share one safeSelf() cache between the scriptlets in a frame.
Context: Each scriptlet has its own copy of safeSelf(). It saves the
functions that it finds when it first runs, and those were often already
the wrappers that earlier scriptlets had installed, not the browser's own
functions. So each hook called all earlier hooks again. With six hooks on
JSON.stringify (as on youtube.com), one JSON.stringify call from the page
became 2^6=64 native calls.
The extension gives each scriptlet its own copy of scriptletGlobals, so
the first scriptlet in a frame (and world) now keeps the cache on
globalThis, and the later scriptlets use it. The property is read-only,
and its key has the uBO version, so other versions do not share it. This
works for all injection paths (registered scripts and executeScript),
without changes in the extension.
refs ghostery/ghostery-extension#36721 parent 44cbeb1 commit d7df476
2 files changed
Lines changed: 734 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
21 | 34 | | |
22 | 35 | | |
23 | 36 | | |
| |||
67 | 80 | | |
68 | 81 | | |
69 | 82 | | |
70 | | - | |
| 83 | + | |
71 | 84 | | |
72 | 85 | | |
73 | 86 | | |
| |||
0 commit comments