aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/cheat.js
blob: c774e9fbea88462120da21f4a64a79f51e8f2397 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var konamiActivated = false;

new Konami(function () {

    if (konamiActivated) return;
    konamiActivated = true;

    console.log('Cheat console activated. Have fun!');

    // play nice soundtrack
    (new Audio('/assets/medias/sims2-university-theme.ogg')).play();

    // substitute currency symbols with §
    var currencySymbols = /[\$\xA2-\xA5\u058F\u060B\u09F2\u09F3\u09FB\u0AF1\u0BF9\u0E3F\u17DB\u20A0-\u20BD\uA838\uFDFC\uFE69\uFF04\uFFE0\uFFE1\uFFE5\uFFE6]/;
    document.body.innerHTML = document.body.innerHTML.replace(currencySymbols, "§");

    // display cheat console
    var form = document.createElement('form');
    form.classList.add('cheat-form');
    form.setAttribute('method', 'post');
    form.setAttribute('action', '/console');

    var csrfToken = document.createElement('input');
    csrfToken.setAttribute('type', 'hidden');
    csrfToken.setAttribute('name', 'csrfToken');
    csrfToken.setAttribute('value', document.body.dataset.token);

    var field = document.createElement('input');
    field.setAttribute('type', 'text');
    field.setAttribute('name', 'command');
    field.setAttribute('autocomplete', 'off');

    form.appendChild(csrfToken);
    form.appendChild(field);
    document.getElementsByTagName('body')[0].appendChild(form);

    field.focus();

});