<commit_before>// ==UserScript==
// @name            JSON prettifier.
// @namespace       https://github.com/kilfu0701
// @description     Prettify json string, use 'shift + p' to run this script.
// @match           http://*/*
// @match           https://*/*
// @run-at          document-end
// @include         *
// @require         http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @version         1.0
// ==/UserScript==
 
//"use strict";
var debug_mode = 1;
 
(function(window, document) {
    //console.log("script starting");
    document.onkeypress = function(e) {
        e = e || window.event;

        // charCode = 80, shift + p
        var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
        var t = document.body.textContent;
        var pre = document.createElement('pre');

        document.body.textContent = '';
        pre.textContent = JSON.stringify(JSON.parse(t), undefined, 4);        
        document.body.appendChild(pre);
    };
})(window, document);<commit_msg>change hotkey to alt + p, bug fixes.<commit_after>// ==UserScript==
// @name            JSON prettifier.
// @namespace       https://github.com/kilfu0701
// @description     Prettify json string, use 'alt + p' to run this script.
// @match           http://*/*
// @match           https://*/*
// @run-at          document-end
// @include         *
// @require         http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @version         1.0
// ==/UserScript==
 
//"use strict";
var debug_mode = 1;
 
(function(window, document) {
    //console.log("script starting");
    document.onkeypress = function(e) {
        e = e || window.event;

        // charCode = 960, alt + p
        var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
        var t = document.body.textContent;
        var pre = document.createElement('pre');

        //console.log(charCode);
        if(charCode === 960) {
            document.body.textContent = '';
            pre.textContent = JSON.stringify(JSON.parse(t), undefined, 4);        
            document.body.appendChild(pre);
        }
    };
})(window, document);
{'fraction_non_alphanumeric': 0.1679035250463822, 'fraction_numerical': 0.013914656771799629, 'mean_word_length': 1.9710743801652892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '809222', 'n_tokens_mistral': 678, 'n_tokens_neox': 644, 'n_words': 146}