Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // +-----------------------------------------------+
- // | |
- // | Script by DollarAkshay |
- // | r/place INDIA FLAG SCRIPT |
- // | Github : https://github.com/DollarAkshay |
- // | Website : http://dollarakshay.com |
- // | Reddit : u/DollarAkshay |
- // | |
- // +-----------------------------------------------
- var modhash = window.reddit.modhash;
- var sec = 0;
- setInterval(function(){
- console.log("Drawing in " + (sec--) + " seconds""white", "light grey", "dark grey", "black", "pink", "red", "orange", "brown", "yellow", "light green", "dark green", "light blue", "medium blue", "dark blue", "light purple", "dark purple"]
- var startX = 207, startY = 616;
- var width = bitMap[0].length, height = bitMap.length;
- var xhttp = new XMLHttpRequest();
- xhttp.responseType = "arraybuffer";
- xhttp.open("GET", "https://www.reddit.com/api/place/board-bitmap", true);
- xhttp.onload = function(t) {
- var n = xhttp.response;
- var s = new Uint8Array(n, 4);
- var canvas = [];
- for(var i=0; i<1000; i++){
- canvas.push([]);
- for(var j=0; j<1000; j++){
- canvas[i].push(0);
- }
- }
- for(var i = 0; i<500000; i++){
- var x1 = (i*2+0)%1000, y1 = Math.floor((i*2+0)/1000);
- var x2 = (i*2+1)%1000, y2 = Math.floor((i*2+1)/1000);
- canvas[y1][x1] = s[i]>>>4;
- canvas[y2][x2] = s[i] & 15;
- }
- var repairCells = [];
- for(var i=0; i<height; i++){
- for(var j=0; j<bitMap[i].length; j++){
- if( canvas[startY+i][startX+j] != bitMap[i][j]){
- repairCells.push([startX+j, startY+i]);
- }
- }
- }
- if(repairCells.length){
- var cellIndex = Math.floor(Math.random() * repairCells.length);
- var cx = repairCells[cellIndex][0], cy = repairCells[cellIndex][1];
- var cellColour = bitMap[cy-startY][cx-startX];
- console.log("################################");
- console.log("Drawing at "+cx+", "+cy);
- console.log("Replacing '"+colourNames[canvas[cy][cx]]+"' with '"+colourNames[bitMap[cy-startY][cx-startX]]+"' colour");
- console.log("################################");
- console.log("");
- $.ajax({ url: "https://www.reddit.com/api/place/draw.json",type: "POST",
- headers: { "x-modhash": modhash }, data: { x: cx,y: cy, color: cellColour }
- })
- .done(function(data) {
- draw(data.wait_seconds);
- })
- .error(function(data){
- if(data == null || data.responseJSON == null || typeof data.responseJSON.wait_seconds === 'undefined' || data.responseJSON.wait_seconds == null){
- draw(60);
- }
- else{
- draw(data.responseJSON.wait_seconds);
- }
- }
- );
- }
- }
- xhttp.send();
- }, seconds * 1000);
- }
- draw(0);
Add Comment
Please, Sign In to add comment