aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/cheat.js
blob: 242dd79679f36544968dd84bb577a650ae1ee76c (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
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 field = document.createElement('input');
    field.setAttribute('type', 'text');
    field.setAttribute('name', 'command');
    field.setAttribute('autocomplete', 'off');

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

    field.focus();

});