Skip to content

Instantly share code, notes, and snippets.

@CoderPrans
Last active August 25, 2023 15:52
Show Gist options
  • Save CoderPrans/4fef0ec7fec3935533d4ce567d9a5819 to your computer and use it in GitHub Desktop.
Save CoderPrans/4fef0ec7fec3935533d4ce567d9a5819 to your computer and use it in GitHub Desktop.
A Min browser's userscript that pretty-prints raw JSON for slightly better view
// ==UserScript==
// @name JSON Viewer
// @match *
// @run-at document-start
// ==/UserScript==
let pretags = document.querySelectorAll(
'[style="word-wrap: break-word; white-space: pre-wrap;"]',
);
pretags.forEach(pre => {
let text = pre.textContent;
let parsed = JSON.parse(text);
pre.textContent = JSON.stringify(parsed, null, 2);
});
@manoger
Copy link

manoger commented Aug 25, 2023

Please create another gist with a sample json to test your userscript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment