View difference between Paste ID: JKBEZahp and xAk8kSB7
SHOW: | | - or go back to the newest paste.
1
(function(_n, data, ut) {
2
    //pobranie localStorage
3
    let dane = {};
4
    if (localStorage.getItem("adiherosybrutus")) {
5
        dane = JSON.parse(localStorage.getItem("adiherosybrutus"));
6
    }
7
    if (dane) {
8
        for (let i in dane) {
9
            if (ut() > dane[i].time) {
10
                delete dane[i];
11
            }
12
        }
13
    }
14
    //getTime
15
    function getTime() {
16
        let czas = new Date(),
17
            godzina = czas.getHours(),
18
            sekunda = czas.getSeconds(),
19
            minuta = czas.getMinutes();
20
        if (godzina < 10) godzina = `0${godzina}`;
21
        if (minuta < 10) minuta = `0${minuta}`;
22
        if (sekunda < 10) sekunda = `0${sekunda}`;
23
        return `${godzina}:${minuta}:${sekunda}`;
24
    }
25
    //funkcja wysłania na diskordzika
26
    function sendToDiscord(lvl, nick, icon, x, y) {
27
        $.ajax({
28
            url: data[0],
29
            type: 'POST',
30
            data: JSON.stringify({
31
                'embeds': [{
32
                    'title': `${hero.nick} · ${hero.lvl}${hero.prof} znalazł herosa/tytana!`,
33
                    'color': ((Math.floor(lvl / 300 * 221) + 32) * 256 + (Math.floor(lvl / 300 * (-112)) + 120)) * 256 + Math.floor(lvl / 300 * (-204)) + 217,
34
                    'description': `${nick} (${lvl}lvl)\n${map.name} (${x}, ${y})\n${getTime()}\n${g.worldname[0].toUpperCase() + g.worldname.substring(1)}`,
35
                    'thumbnail': {
36
                        'url': `http://berufs.margonem.pl${icon}`
37
                    }
38
                }],
39
                content: `@here Znaleźli mnie na mapie ${map.name}`,
40
                username: nick,
41
                avatar_url: `http://berufs.margonem.pl${icon}`
42
            }),
43
            contentType: 'application/json; charset=utf-8',
44
            dataType: 'json',
45
            async: false
46
        });
47
    }
48
    //funkcja sprawdzajaca czy dane id z ts istnieje
49
    function checkHerosData(id) {
50
        if (dane[id]) {
51
            if (ut() > dane[id].time) {
52
                delete dane[id];
53
                return true;
54
            } else {
55
                return false;
56
            }
57
        }
58
        return true;
59
    }
60
    newNpc = function(e) {
61
        _n.apply(this, arguments);
62
        for (let i in e) {
63
            let heros = e[i];
64
            if (map.mode != 5 && heros.wt > 79 && g.worldname != "experimental" && checkHerosData(heros.id)) {
65
                dane[heros.id] = {
66
                    time: ut() + (10 * 60)
67
                }
68
                localStorage.setItem("adiherosybrutus", JSON.stringify(dane));
69
                sendToDiscord(heros.lvl, heros.nick, heros.icon, heros.x, heros.y);
70
                break;
71
            }
72
        }
73
    }
74-
})(newNpc, ["https://discordapp.com/api/webhooks/602488315421392896/lt5IGjq9_YgcFPOejVFV2JqYUvGVtzUS3H8f64zP_kccn-gysZDOB6y7nAJkeAvP81jm"], unix_time)
74+
})(newNpc, ["https://discordapp.com/api/webhooks/602793798480953374/MoWCx6JLJvo-xyQdw76IMv3kZcuGIKRfGQ5WOBkmOS3JF9nPeMd9OpYul14_IjhJXN4t"], unix_time)