9Voltaire / Weird-Stuff-Generator

https://9voltaire.github.io/Weird-Stuff-Generator/
0 stars 0 forks source link

Decode script from base64 #1

Open dylarm opened 6 years ago

dylarm commented 6 years ago

I feel it's a little disingenuous (not on your part though) to have the script that does the actual processing encoded in base64, when it would just be plain text normally. Especially because it's formally released into the public domain.

function more_random(){var a=document.getElementById("output"),b=parseInt(a.rows);if(b<1)b=1;b=generate_list("main",b);a.value=b.join("\n")}function generate_text(a){if(a=gen_data[a])if(a=select_from(a))return expand_tokens(a);return""}function generate_list(a,b){var c=[],d;for(d=0;d<b;d++)c.push(generate_text(a));return c}function select_from(a){return a.constructor==Array?select_from_array(a):select_from_table(a)}function select_from_array(a){return a[Math.floor(Math.random()a.length)]} function select_from_table(a){var b;if(b=scale_table(a)){b=Math.floor(Math.random()b)+1;var c;for(c in a){var d=key_range(c);if(b>=d[0]&&b<=d[1])return a[c]}}return""}function scale_table(a){var b=0,c;for(c in a){var d=key_range(c);if(d[1]>b)b=d[1]}return b}function key_range(a){var b;return(b=/(\d+)-00/.exec(a))?[parseInt(b[1]),100]:(b=/(\d+)-(\d+)/.exec(a))?[parseInt(b[1]),parseInt(b[2])]:a=="00"?[100,100]:[parseInt(a),parseInt(a)]} function expand_tokens(a){for(var b;b=/{(\w+)}/.exec(a);){b=b[1];var c;a=(c=generate_text(b))?a.replace("{"+b+"}",c):a.replace("{"+b+"}",b)}return a}more_random();



Obviously, a little cleanup is needed, but this is a start.
dylarm commented 6 years ago

A quick usage of jsbeautifier.org

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// random.js
//
// written and released to the public domain by drow <drow@bin.sh>
// http://creativecommons.org/publicdomain/zero/1.0/
function more_random() {
    var a = document.getElementById("output"),
        b = parseInt(a.rows);
    if (b < 1) b = 1;
    b = generate_list("main", b);
    a.value = b.join("\n")
}

function generate_text(a) {
    if (a = gen_data[a])
        if (a = select_from(a)) return expand_tokens(a);
    return ""
}

function generate_list(a, b) {
    var c = [],
        d;
    for (d = 0; d < b; d++) c.push(generate_text(a));
    return c
}

function select_from(a) {
    return a.constructor == Array ? select_from_array(a) : select_from_table(a)
}

function select_from_array(a) {
    return a[Math.floor(Math.random() * a.length)]
}

function select_from_table(a) {
    var b;
    if (b = scale_table(a)) {
        b = Math.floor(Math.random() * b) + 1;
        var c;
        for (c in a) {
            var d = key_range(c);
            if (b >= d[0] && b <= d[1]) return a[c]
        }
    }
    return ""
}

function scale_table(a) {
    var b = 0,
        c;
    for (c in a) {
        var d = key_range(c);
        if (d[1] > b) b = d[1]
    }
    return b
}

function key_range(a) {
    var b;
    return (b = /(\d+)-00/.exec(a)) ? [parseInt(b[1]), 100] : (b = /(\d+)-(\d+)/.exec(a)) ? [parseInt(b[1]), parseInt(b[2])] : a == "00" ? [100, 100] : [parseInt(a), parseInt(a)]
}

function expand_tokens(a) {
    for (var b; b = /{(\w+)}/.exec(a);) {
        b = b[1];
        var c;
        a = (c = generate_text(b)) ? a.replace("{" + b + "}", c) : a.replace("{" + b + "}", b)
    }
    return a
}
more_random();