JSON Format

format json for Chromium based browsers

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         JSON Format
// @description  format json for Chromium based browsers
// @namespace    https://www.kookxiang.com/
// @version      1.0
// @author       kookxiang
// @match        https://*/*
// @match        http://*/*
// @grant        GM_addElement
// @run-at       document-body
// ==/UserScript==

if (document.all.length === 4 && document.contentType === 'application/json') {
    var interval;
    var pre = document.querySelector('pre');

    pre.innerHTML = JSON.stringify(JSON.parse(pre.innerHTML), null, 2);
    pre.className = 'language-json';

    GM_addElement('script', { src: 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/highlight.min.js', onload: 'hljs.highlightElement(document.querySelector("pre"))' });
    GM_addElement('link', { rel: "stylesheet", type: "text/css", href: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.0.1/styles/github.min.css" });
}