just something to make easier to read the json on steam pages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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