Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const COLUMN_START = 235; //MAKE SURE YOU UPDATE THIS TO BE CORRECT STARTING COLUMN (X), TO AVOID OVERWRITING TASKBAR ART
- const modhash = window.reddit.modhash;
- const height = 10;
- const width = 1000;
- var sec = 0, index = 1;
- const getPrevColor = (x, y) => r.place.state[x + (y * 1000)];
- setInterval(() => console.log("Drawing in " + (sec--) + " seconds"), 1e3);
- const draw = seconds => {
- index++
- index = index % (width * height);
- sec = seconds = Math.ceil(seconds)
- setTimeout(() => {
- const y = index % height;
- const x = Math.floor(index / height);
- const flagColor = 1;
- const ax = x + COLUMN_START;
- const ay = y + 985;
- const oldCol = getPrevColor(ax, ay);
- if (flagColor == oldCol) {
- return draw(0);
- }
- $.get("https://www.reddit.com/api/place/pixel.json?x=" + ax + "&y=" + ay)
- .then(res => {
- if (res.color == 0 || res.color == 1 || res.color == 2 || res.color == 3) {
- console.log("Skipping " + (ax + ", " + ay) + " because it's already correct");
- return draw(1);
- }
- console.log("Drawing at " + ax + ", " + ay + " (https://www.reddit.com/r/place/#x=" + ax + "&y=" + ay + ")");
- $.ajax({ url: "https://www.reddit.com/api/place/draw.json", type: "POST",
- headers: { "x-modhash": modhash }, data: { x: ax, y: ay, color: flagColor }
- })
- .done(data => draw(data.wait_seconds))
- .error(data => draw(data.responseJSON.wait_seconds));
- });
- }, seconds * 1000);
- }
- draw(0);
Add Comment
Please, Sign In to add comment