SHOW:
|
|
- or go back to the newest paste.
| 1 | - | OFFSET_X = 861; |
| 1 | + | OFFSET_X = 817; |
| 2 | - | OFFSET_Y = 361; |
| 2 | + | OFFSET_Y = 538; |
| 3 | ||
| 4 | waitDuration = 0; | |
| 5 | modHash = null; | |
| 6 | ||
| 7 | //white: 0, lightGrey: 1, grey: 2, black: 3, | |
| 8 | //pink: 4, red: 5, orange: 6, brown: 7, | |
| 9 | //yellow: 8, lightGreen: 9, green: 10, cyan: 11, | |
| 10 | //teal: 12, blue: 13, fuchsia: 14, purple: 15 | |
| 11 | f = -1; | |
| 12 | ||
| 13 | - | image = [[f,f,f,f,f,f,f,f,f,f,f,f,0,0,0,0,0,0,0,0,0,0,0,0,0,f,f,f,f,f,f,f,f,f,f,f], |
| 13 | + | image =[[-1,-1,3,3,3,3,3,-1,-1,-1,3,3,3,3,-1,-1,-1,3,3,-1,-1,-1,-1,3,3,-1,-1,3,3,3,3,3,-1,-1,], |
| 14 | - | [f,f,f,f,f,f,f,f,f,f,f,f,0,0,0,0,0,0,0,0,0,0,0,0,0,f,f,f,f,f,f,f,f,f,f,f], |
| 14 | + | [-1,3,0,0,0,0,3,3,-1,3,0,0,0,3,3,-1,3,0,3,3,-1,-1,3,0,3,3,3,0,0,0,0,3,3,-1,], |
| 15 | - | [f,f,f,f,f,f,f,f,f,f,f,f,0,0,3,3,3,3,3,3,3,3,3,0,0,f,f,f,f,f,f,f,f,f,f,f], |
| 15 | + | [3,0,3,3,3,3,3,3,3,0,3,3,3,0,3,3,3,0,0,3,3,3,0,0,3,3,3,0,3,3,3,0,3,3,], |
| 16 | - | [f,f,f,f,f,f,f,f,f,f,0,0,3,3,0,0,7,0,7,0,0,0,0,3,3,0,0,f,f,f,f,f,f,f,f,f], |
| 16 | + | [3,0,3,3,3,3,3,3,3,0,3,3,3,0,3,3,3,0,3,0,3,0,3,0,3,3,3,0,3,3,3,0,3,3,], |
| 17 | - | [f,f,f,f,f,f,f,f,f,0,0,3,0,0,0,7,0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,f,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,3,3,0,0,0,0,3,0,0], |
| 37 | + | |
| 38 | - | [f,f,f,f,0,0,3,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,3,0,0,f,f,f], |
| 38 | + | |
| 39 | - | [f,f,f,f,f,0,0,3,3,0,3,12,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,f,f,f,f], |
| 39 | + | |
| 40 | - | [f,f,f,f,f,f,0,0,0,3,12,12,12,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,f,f,f,f,f], |
| 40 | + | |
| 41 | - | [f,f,f,f,f,0,0,0,3,12,12,12,12,3,0,3,0,0,0,0,0,0,0,0,0,0,0,3,0,0,f,f,f,f,f,f], |
| 41 | + | |
| 42 | - | [f,f,f,f,0,0,3,3,12,12,12,12,12,3,0,0,3,3,3,3,3,3,3,3,3,3,3,0,0,f,f,f,f,f,f,f], |
| 42 | + | |
| 43 | - | [f,f,0,0,3,12,12,12,12,12,12,12,3,0,3,11,11,11,11,3,0,0,3,12,12,12,12,3,0,0,f,f,f,f,f], |
| 43 | + | |
| 44 | - | [f,0,0,0,3,12,12,12,12,12,12,12,12,3,3,0,11,11,11,11,3,0,0,3,12,12,12,12,12,3,0,0,f,f,f,f], |
| 44 | + | |
| 45 | - | [f,0,0,0,3,12,12,12,12,12,12,12,12,3,0,0,11,11,11,11,3,0,3,12,12,12,12,12,12,3,0,0,f,f,f,f], |
| 45 | + | |
| 46 | - | [f,0,0,3,12,12,12,12,12,12,12,12,12,0,0,0,0,11,11,0,3,3,12,12,12,12,12,12,12,12,3,0,0,f,f,f], |
| 46 | + | |
| 47 | - | [f,0,0,3,12,12,12,12,12,12,12,12,12,0,0,0,0,11,11,0,0,0,12,12,12,12,12,12,12,12,3,0,0,f,f,f], |
| 47 | + | |
| 48 | - | [f,0,0,3,12,12,12,12,12,12,12,12,12,0,0,0,0,11,11,0,0,0,12,12,12,12,12,12,12,12,3,0,0,f,f,f], |
| 48 | + | |
| 49 | - | [0,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0], |
| 49 | + | |
| 50 | - | [0,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0], |
| 50 | + | |
| 51 | - | [0,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,3,0,0,0,3,3,3,3,3,3,3,3,3,3,0,0], |
| 51 | + | |
| 52 | - | [0,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,0,3,3,3,3,3,3,3,3,3,3,3,0,0], |
| 52 | + | |
| 53 | - | [0,0,3,0,3,3,3,0,3,3,0,3,3,0,3,3,0,3,3,0,3,3,0,3,3,3,3,5,3,3,3,5,5,3,0,0], |
| 53 | + | |
| 54 | - | [0,0,3,0,3,3,3,0,3,0,3,0,3,0,3,3,0,3,0,0,3,3,0,3,5,3,5,5,5,3,5,3,3,3,0,0], |
| 54 | + | |
| 55 | - | [0,0,3,0,3,0,3,0,3,0,0,0,3,0,3,3,0,3,3,5,3,3,3,5,3,5,3,5,3,3,3,5,5,3,0,0], |
| 55 | + | |
| 56 | - | [0,0,3,0,3,0,3,0,3,0,3,0,3,0,3,3,0,3,3,5,5,5,5,5,5,5,3,5,3,5,3,3,3,5,0,0], |
| 56 | + | |
| 57 | - | [0,0,3,3,0,3,0,3,3,0,3,0,3,0,0,3,0,0,5,5,3,5,3,5,3,3,3,3,5,5,3,5,5,3,0,0], |
| 57 | + | |
| 58 | - | [0,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,3,5,3,3,5,5,3,3,3,3,3,3,3,3,0,0], |
| 58 | + | |
| 59 | - | [0,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,5,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0], |
| 59 | + | |
| 60 | - | [0,0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0], |
| 60 | + | |
| 61 | - | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], |
| 61 | + | |
| 62 | - | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]; |
| 62 | + | |
| 63 | function sendSynchronousRequest(method, url, headers, params) {
| |
| 64 | var xhr = new XMLHttpRequest(); | |
| 65 | xhr.open(method, url, false); | |
| 66 | for (var h in headers) {
| |
| 67 | xhr.setRequestHeader(h, headers[h]); | |
| 68 | } | |
| 69 | var firstParam = true; | |
| 70 | var paramString = ''; | |
| 71 | for (var p in params) {
| |
| 72 | if (firstParam) {
| |
| 73 | firstParam = false; | |
| 74 | } else {
| |
| 75 | paramString += '&'; | |
| 76 | } | |
| 77 | paramString += p + '=' + params[p]; | |
| 78 | } | |
| 79 | xhr.send(paramString); | |
| 80 | return xhr; | |
| 81 | } | |
| 82 | ||
| 83 | ||
| 84 | function getModHash() {
| |
| 85 | var xhr = sendSynchronousRequest('GET', 'api/me.json', {}, {});
| |
| 86 | ||
| 87 | if (xhr.readyState !== 4) throw 'oh shit'; | |
| 88 | if (xhr.status !== 200) {
| |
| 89 | alert("Couldn't obtain modhash. Are you logged into Reddit?");
| |
| 90 | throw 'bollocks'; | |
| 91 | } | |
| 92 | var response = JSON.parse(xhr.responseText); | |
| 93 | return response.data.modhash; | |
| 94 | } | |
| 95 | ||
| 96 | ||
| 97 | function pixelRequest(x, y) {
| |
| 98 | var url = '/api/place/pixel.json?x=' + x + '&y=' + y; | |
| 99 | ||
| 100 | var xhr = sendSynchronousRequest('GET', url, {
| |
| 101 | 'x-requested-with': 'XMLHttpRequest', | |
| 102 | 'x-modhash': modHash | |
| 103 | }, {});
| |
| 104 | ||
| 105 | if (xhr.readyState !== 4) throw 'oh shit'; | |
| 106 | if (xhr.status !== 200) {
| |
| 107 | console.log(xhr); | |
| 108 | throw 'bollocks'; | |
| 109 | } | |
| 110 | var response = JSON.parse(xhr.responseText); | |
| 111 | return response.color; | |
| 112 | } | |
| 113 | ||
| 114 | ||
| 115 | function draw(x, y, colour) {
| |
| 116 | console.log('attempting to draw a pixel at (' + x + ',' + y + ')');
| |
| 117 | var xhr = sendSynchronousRequest('POST', '/api/place/draw.json', {
| |
| 118 | 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', | |
| 119 | 'x-requested-with': 'XMLHttpRequest', | |
| 120 | 'x-modhash': modHash | |
| 121 | }, {
| |
| 122 | x: x, | |
| 123 | y: y, | |
| 124 | color: colour | |
| 125 | }); | |
| 126 | ||
| 127 | if (xhr.readyState !== 4) throw 'oh shit'; | |
| 128 | if (xhr.status !== 200 && xhr.status !== 429) {
| |
| 129 | console.log(xhr); | |
| 130 | throw 'bollocks'; | |
| 131 | } | |
| 132 | var response = JSON.parse(xhr.responseText); | |
| 133 | return response.wait_seconds * 1000; | |
| 134 | } | |
| 135 | ||
| 136 | ||
| 137 | start(); |