Skip to content

Instantly share code, notes, and snippets.

@MalikAQayum
Last active December 7, 2020 11:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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