You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
support broader set of data types
+ add customClone
+ serialize: Symbol, Set, Map, +/-Infinity, NaN, BigInt, undefine
+ tune function serialization
+ add pseudo ids for potentionally recurring instances
+ update documentation features and limitations
Chrome devtools extension intended to display result of deep in-memory object
6
-
comparisons with the help of dedicated console commands.
5
+
Chrome extension to compare objects in memory with console.diff(old, new) devtools function.
7
6
8
7
<details>
9
8
<summary> <strong>Screenshots</strong> </summary>
@@ -23,23 +22,54 @@ comparisons with the help of dedicated console commands.
23
22
24
23
### Features
25
24
26
-
- compare objects between multiple [sub]domains, chrome tabs, or single page reloads
27
-
- function code included in comparison result in form of a string, may help to see if it was altered
28
-
- document, dom-elements and other non-serializable objects are filtered-out from the results
29
-
- self recurring references displayed only once, the rest of occurrences are filtered-out
30
-
- basic integration with search functionality within devtools
31
-
- if search query contains upper-case letter - the search will be case-sensitive
25
+
- Symple user interface:
32
26
33
-
### Limitations and workarounds
27
+
- Button to hide/show unchanged properties.
28
+
- Button to copy changed properties in format of `jsondiffpatch` diff object.
29
+
- Button to clear current result.
30
+
- Indicator of the last update time.
31
+
- Indicator of a fatal error (out of storage memory).
34
32
35
-
- some instances of objects may cause exception during preparations for comparison
36
-
- try to narrow compared contexts
37
-
- if it's some Browser API that causes an exception and not a framework, consider opening an issue,
38
-
so it will be possible to solve it on a permanent basis
39
-
- while paused in debug mode, JSDiff panel won't reflect the result until runtime is resumed ([#10][i10])
33
+
- Compare objects between multiple [sub]domains, chrome tabs, or single page reloads.
34
+
35
+
- JSDiff devtools panel reflects current state of comparison, regardless the tab[s] it was opened from.
36
+
37
+
- Basic integration with search functionality within devtools:
38
+
39
+
- If search query contains at least one upper-case letter - the search will be case-sensitive.
40
+
41
+
- Using `console.diff` functions from within online code editors like: [codesandbox.io](https://codesandbox.io), [coderpad.io](https://coderpad.io), [flems.io](https://flems.io), [codepen.io](https://codepen.io), [jsfiddle.net](https://jsfiddle.net).
42
+
43
+
- Functions are included in comparison result in order to detect possible alterations, in form of a string combined from a function name (if present) and a SHA-256 hash of a `function.toString()` body. Native functions are shown as silmply as `ƒ⟪native⟫`.
44
+
45
+
- Some DOM objects like Document or Element are not worth to be shown entirely, since that is not the purpose of this extension. So if they are present anywhere, they are serialized as `0x####: ⟪unserializable⟫`.
46
+
47
+
- Object, Array, Map, Set - serialized only once and the rest of their ocurrances are mentioned with unique reference like: `0x####: {♻️}`, `0x####: [♻️]`, `0x####: Map{♻️}`, `0x####: Set[♻️]` respectivly.
48
+
49
+
- Map keys, unless they are primitive types, serialized by their pseudo ids.
50
+
51
+
- Symbols serialized with his pseudo id like: `0x####: Symbol(name)`.
52
+
53
+
- Serialization of numerics like `+/-Infinity`, `NaN`, `BigInt`, or `undefined` serialized like: `Number⟪Infinity⟫`, `Number⟪NaN⟫`, `BigInt⟪#⟫`, `⟪undefined⟫` respectivly.
54
+
55
+
- Failsafe serialization of objects having security issues while accessing their properties.
56
+
57
+
- Failsefe serialization of objects having `toJSON()` function (when instead of serialization of all object properties, - only toJSON() return value is serialized, similar to the way native `JSON.strigify()` works).
58
+
59
+
### Legend
60
+
61
+
- Pseudo id, assigned to non-primitive data types, used in order to detect reference recurrences and, in case of Symbols - symbol uniqueness. Id for an object shown in the output only if it seen more than once. It being assigned in the scope of serialization of a high level argument instance, while comparing left or right side; that means if some object, having id 0x0001 on the left side, is not guarantied to have same id on the right side.
62
+
63
+
### Limitations
64
+
65
+
- While paused in debug mode, JSDiff panel won't reflect the result until runtime is resumed (see [#10][i10]).
-**console.diff\_(\*)** - deprecated, left for backward compatibility, uses `nativeClone` based of JSON.parse(JSON.stringify(...)) serialization method
106
+
75
107
### Usage basics
76
108
77
109
Historically, left side represents the old state and right side the new state.
78
110
79
111
- Things that are present on the left side but missing on the right side are colour-coded as red (old).
112
+
80
113
- Things that are missing on the left side but present on the right side are colour-coded as green (new).
81
114
82
-
To track changes of the same variable in timed manner you can push it with `diffPush` or `diff`
83
-
with a single argument, that will shift objects from right to left, showing differences with previous push state.
115
+
- To track changes of the same variable in timed manner you can push it with `diffPush` or `diff` with a single argument, - that will shift objects from right to left, showing differences with previous push state.
84
116
85
117
### How it works
86
118
87
-
-`jsdiff-devtools.js` registers devtools panel
88
-
- injects `console.diff` commands into inspected window's console interface
89
-
- each function clones arguments and sends them via `postMessage` to `jsdiff-proxy.js` in `jsdiff-console-to-proxy` message
90
-
- injects `jsdiff-proxy.js` that listens on window `jsdiff-console-to-proxy` message and sends it further to chrome runtime in `jsdiff-proxy-to-devtools` message
91
-
- listens on `jsdiff-proxy-to-devtools` and prepares payload for `view/panel.vue` and sends it with `jsdiff-devtools-to-panel-compare` message
92
-
- when user invokes devtools search command - informs `view/panel.vue` with `jsdiff-devtools-to-panel-search` message
93
-
- when `view/panel.vue` is visible in devtools
94
-
- reflects result of last compare request
95
-
- listens on `jsdiff-devtools-to-panel-compare` requests
96
-
- listens on `jsdiff-devtools-to-panel-search` and tries to find query in DOM
119
+
-`manifest.json` injects content scripts to each visited site (except for chrome web store site and google-protected alike):
120
+
-`jsdiff-console.ts` as [MAIN](https://developer.chrome.com/docs/extensions/reference/scripting/#type-ExecutionWorld) world (has access to the target site memory)
121
+
- sends messages to `jsdiff-proxy.ts`.
122
+
-`jsdiff-proxy.ts` as `ISOLATED` world (has access to the chrome runtime)
123
+
- stores data from `jsdiff-console.ts` in `chrome.storage.local` and sends runtime messages to `panel.vue`.
124
+
-`jsdiff-devtools.ts` registers `panel.vue` as a JSDiff devtools panel that reads current state of `chorme.storage.local` and listens to incomming `chrome.runtime` mesages from `jsdiff-proxy.ts`.
125
+
126
+
### How to build
127
+
128
+
- requires npm/nodejs
129
+
- requires pnpm `npm i -g pnpm`
130
+
131
+
```sh
132
+
pnpm i
133
+
pnpm dev # local development
134
+
pnpm zip # make extension.zip
135
+
```
136
+
137
+
### Protection
138
+
139
+
- How to protect your site from this extension:
140
+
- Well, tests show that even `Content-Security-Policy: default-src 'none';` header won't prevent injection of extension content-scripts...
141
+
- In general, you can incapacitate console functions:
142
+
```js
143
+
for (constpropinconsole) {
144
+
if (typeofconsole[prop] ==='function'&& prop !=='error') {
0 commit comments