Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
just something to make easier to read the json on steam pages.
// ==UserScript==
// @name Make JSON readable.
// @namespace https://gist.github.com/MalikQayum
// @version 0.1
// @description just something to make easier to read the json on steam pages.
// @author MalikQayum
// @include /^https?://(store.steampowered|steamcommunity|partner.steam-api|partner.steamgames|(partner|api).steampowered).com/*/
// @include /^https?://(steamcdn-a.akamaihd).net/*/
// @grant none
// ==/UserScript==
var el = document.getElementsByTagName('pre')[0];
if (typeof(el) != 'undefined' && el != null)
{
var MjsonR = JSON.stringify(JSON.parse(document.getElementsByTagName('pre')[0].innerHTML), undefined, 4);
if (/^[\],:{}\s]*$/.test(MjsonR.replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
document.getElementsByTagName('pre')[0].innerHTML = "";
output(MjsonR);
}else{
//do nothing.
}
}
function output(MJR) {
document.body.appendChild(document.createElement('pre')).innerHTML = MJR;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment