f03nix

Untitled

Apr 3rd, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // +-----------------------------------------------+
  2. // |                                               |
  3. // | Script by DollarAkshay                        |
  4. // | r/place INDIA FLAG SCRIPT                     |
  5. // | Github  : https://github.com/DollarAkshay     |
  6. // | Website : http://dollarakshay.com             |
  7. // | Reddit : u/DollarAkshay                       |
  8. // |                                               |
  9. // +-----------------------------------------------
  10.  
  11.  
  12. var modhash = window.reddit.modhash;
  13. var sec = 0;
  14. setInterval(function(){
  15.     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"]
  16.     var startX = 207, startY = 616;
  17.     var width = bitMap[0].length, height = bitMap.length;
  18.    
  19.     var xhttp = new XMLHttpRequest();
  20.     xhttp.responseType = "arraybuffer";
  21.     xhttp.open("GET", "https://www.reddit.com/api/place/board-bitmap", true);
  22.     xhttp.onload = function(t) {
  23.         var n = xhttp.response;
  24.         var s = new Uint8Array(n, 4);
  25.        
  26.         var canvas = [];
  27.         for(var i=0; i<1000; i++){
  28.             canvas.push([]);
  29.             for(var j=0; j<1000; j++){
  30.                 canvas[i].push(0);
  31.             }
  32.         }
  33.        
  34.         for(var i = 0; i<500000; i++){
  35.             var x1 = (i*2+0)%1000, y1 = Math.floor((i*2+0)/1000);
  36.             var x2 = (i*2+1)%1000, y2 = Math.floor((i*2+1)/1000);
  37.             canvas[y1][x1] = s[i]>>>4;
  38.             canvas[y2][x2] = s[i] & 15;
  39.         }
  40.        
  41.         var repairCells = [];
  42.         for(var i=0; i<height; i++){
  43.             for(var j=0; j<bitMap[i].length; j++){
  44.                 if( canvas[startY+i][startX+j] != bitMap[i][j]){
  45.                     repairCells.push([startX+j, startY+i]);
  46.                 }
  47.             }
  48.         }
  49.        
  50.         if(repairCells.length){
  51.             var cellIndex = Math.floor(Math.random() * repairCells.length);
  52.             var cx = repairCells[cellIndex][0], cy = repairCells[cellIndex][1];
  53.             var cellColour = bitMap[cy-startY][cx-startX];
  54.             console.log("################################");
  55.             console.log("Drawing at "+cx+", "+cy);
  56.             console.log("Replacing '"+colourNames[canvas[cy][cx]]+"' with '"+colourNames[bitMap[cy-startY][cx-startX]]+"' colour");
  57.             console.log("################################");
  58.             console.log("");
  59.            
  60.             $.ajax({ url: "https://www.reddit.com/api/place/draw.json",type: "POST",
  61.                 headers: { "x-modhash": modhash },  data: { x: cx,y: cy, color: cellColour }
  62.             })
  63.             .done(function(data) {
  64.                 draw(data.wait_seconds);
  65.             })
  66.             .error(function(data){
  67.                 if(data == null || data.responseJSON == null || typeof data.responseJSON.wait_seconds === 'undefined' || data.responseJSON.wait_seconds == null){
  68.                     draw(60);
  69.                 }
  70.                 else{
  71.                     draw(data.responseJSON.wait_seconds);
  72.                 }
  73.             }
  74.             );
  75.         }
  76.        
  77.     }
  78.     xhttp.send();
  79.    
  80.     }, seconds * 1000);
  81. }
  82. draw(0);
Add Comment
Please, Sign In to add comment