Last active
April 2, 2017 02:47
-
-
Save mbarkhau/1b1995cac86e2867a0b13947cac1e449 to your computer and use it in GitHub Desktop.
placepaintbot.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name PlacePaintBot | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.2 | |
| // @description Domination of Place! | |
| // @author mbarkhau | |
| // @match https://www.reddit.com/place?webview=true | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| var imageX = 357; | |
| var imageY = 892; | |
| var image = [ | |
| " ", | |
| " ##### ", | |
| " ## # # ", | |
| " # # ", | |
| " # ## ## ", | |
| " # # ", | |
| " # ### # ### ### ## ### ### ### ", | |
| " # # # # # # # # # # ", | |
| " ## # ## ### # ## ### ### # # ", | |
| " ##### ", | |
| " ", | |
| " ", | |
| "#################################", | |
| ]; | |
| var colors = { | |
| "#": 3, // black | |
| " ": 6, // gold | |
| }; | |
| var image_data = []; | |
| for (var relY = 0; relY < image.length; relY++) { | |
| var row = image[relY]; | |
| for (var relX = 0; relX < row.length; relX++) { | |
| var color = colors[row[relX]] || -1; | |
| if (color < 0) { | |
| continue; | |
| } | |
| var absX = imageX + relX; | |
| var absY = imageY + relY; | |
| image_data.push(absX); | |
| image_data.push(absY); | |
| image_data.push(color); | |
| } | |
| } | |
| var default_panX = 120; | |
| var default_panY = -380; | |
| var p = r.place; | |
| p.panX = default_panX; | |
| p.panY = default_panY; | |
| r.placeModule("placePaintBot", function(loader) { | |
| var c = loader("canvasse"); | |
| setInterval(function() { | |
| if (p.getCooldownTimeRemaining() > 200) { | |
| return; | |
| } | |
| for (var i = 0; i < image_data.length; i += 3) { | |
| var j = Math.floor((Math.random() * image_data.length) / 3) * 3; | |
| var x = image_data[j + 0]; | |
| var y = image_data[j + 1]; | |
| var color = image_data[j + 2]; | |
| var currentColor = p.state[c.getIndexFromCoords(x, y)]; | |
| if (currentColor != color) { | |
| console.log("set color for", x, y, "old", currentColor, "new", color); | |
| p.setColor(color); | |
| p.drawTile(x, y); | |
| return; | |
| } | |
| } | |
| console.log("noop"); | |
| }, 1500); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment