json-viewer icon indicating copy to clipboard operation
json-viewer copied to clipboard

[Feature request] window.json variable

Open KaKi87 opened this issue 4 years ago • 10 comments
trafficstars

Hello,

Would it be possible to allow access to the inspected JSON data from devtools using a window.json variable, like nikrolls/json-formatter does ?

Thanks !

KaKi87 avatar Apr 06 '21 13:04 KaKi87

up, thanks

KaKi87 avatar Feb 20 '22 18:02 KaKi87

Bit of a workaround, but you can currently extract the raw JSON data from the page's #rawdata-panel container. Should help when trying to test code from the console.

const json = JSON.parse(document.querySelector('#rawdata-panel pre.data').innerHTML)

@st-jordy-de-koning Interesting !

@pd4d10 Any news on this ?

Thanks

KaKi87 avatar May 23 '22 13:05 KaKi87

Thanks for the suggestion!

We are going to upgrade to manifest v3. There seems to be a technical limitation to inject global variables after this upgrade, due to the CSP policy.

The extension you mentioned seems still stay at manifest v2, which has already been deprecated by Chrome officially.

pd4d10 avatar Jun 04 '22 07:06 pd4d10

I'll look into that.

If creating a window.json variable turns out to be truly impossible, I would like to suggest adding a button to the UI which, on click, would copy a const json code snippet to clipboard, that could be pasted into DevTools.

I'm also wondering if an alternative extensions store will some day exist, since there's no way Chromium-based browser users like us give up on adblockers anyway.

KaKi87 avatar Jun 04 '22 08:06 KaKi87

a button to the UI which, on click, would copy a const json code snippet to clipboard, that could be pasted into DevTools.

image

Perhaps the Copy button is the feature you want

pd4d10 avatar Jun 04 '22 08:06 pd4d10

No, this only copies the JSON value, but it will still require to write const json = JSON.parse('') into DevTools.

I assure you, automating this is a huge gain of time.

KaKi87 avatar Jun 04 '22 09:06 KaKi87

OK get your point.

The original purpose of this extension is to port Firefox's corresponding JSON Viewer, so we are trying not to add too many extra features to keep it consistent with the original one.

But I also agree that it's useful if someone wants to do some debug in the console.

pd4d10 avatar Jun 04 '22 11:06 pd4d10

Hello,

Any news on this ?

I tried to add this feature as a userscript, but the #rawdata-panel element remains empty until the Raw Data button is clicked, meanwhile I won't do something as dirty as automatically clicking on it then clicking back on the JSON button.

Thanks

KaKi87 avatar Oct 24 '22 20:10 KaKi87

@pd4d10 Please ? Thanks

KaKi87 avatar Jul 26 '23 22:07 KaKi87