View difference between Paste ID: ztec68rV and eyBkzE5d
SHOW: | | - or go back to the newest paste.
1-
const COLUMN_START = 220; //MAKE SURE YOU UPDATE THIS TO BE CORRECT STARTING COLUMN (X), TO AVOID OVERWRITING TASKBAR ART
1+
const COLUMN_START = 235; //MAKE SURE YOU UPDATE THIS TO BE CORRECT STARTING COLUMN (X), TO AVOID OVERWRITING TASKBAR ART
2
const modhash = window.reddit.modhash;
3
const height = 10;
4
const width = 1000;
5
var sec = 0, index = 1;
6
const getPrevColor = (x, y) => r.place.state[x + (y * 1000)];
7
8
setInterval(() => console.log("Drawing in " + (sec--) + " seconds"), 1e3);
9
const draw = seconds => {
10
    index++
11
    index = index % (width * height);
12
    sec = seconds = Math.ceil(seconds)
13
    setTimeout(() => {
14
        const y = index % height;
15
        const x = Math.floor(index / height);
16
        const flagColor = 1;
17
        
18
        const ax = x + COLUMN_START;
19
        const ay = y + 985;
20
        const oldCol = getPrevColor(ax, ay);
21
        if (flagColor == oldCol) {
22
            return draw(0);
23
        }
24
25
        $.get("https://www.reddit.com/api/place/pixel.json?x=" + ax + "&y=" + ay)
26
        .then(res => {
27
            if (res.color == 0 || res.color == 1 || res.color == 2 || res.color == 3) {
28
                console.log("Skipping " + (ax + ", " + ay) + " because it's already correct");
29
                return draw(1);
30
            }
31
            console.log("Drawing at " + ax + ", " + ay + " (https://www.reddit.com/r/place/#x=" + ax + "&y=" + ay + ")");
32
            $.ajax({ url: "https://www.reddit.com/api/place/draw.json", type: "POST",
33
                headers: { "x-modhash": modhash }, data: { x: ax, y: ay, color: flagColor }
34
            })
35
            .done(data => draw(data.wait_seconds))
36
            .error(data => draw(data.responseJSON.wait_seconds));
37
        });
38
    }, seconds * 1000);
39
}
40
draw(0);