Last active
April 4, 2022 19:09
-
-
Save dt-rush/93cd04b7c3dd7b2ef315cf1853b9ab95 to your computer and use it in GitHub Desktop.
Revisions
-
dt-rush revised this gist
Apr 2, 2022 . 1 changed file with 8 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -111,14 +111,17 @@ function getRandomPixelFromRange(xy1, xy2) { }; function expectedColor(y) { // white if (y >= 448 && y <= 456) { return 31; } // light pink if ((y >= 439 && y <= 447) || (y >= 457 && y <= 465)) { return 23; } // light blue if ((y >= 430 && y <= 438) || (y >= 466 && y <= 475)) { return 14; } }; -
dt-rush created this gist
Apr 2, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,156 @@ // MISSION: OPERATION TRANS LIBERATION // // USAGE: // 1) Navigate to https://new.reddit.com/r/place/ // 2) Open the "Developer Tools" (CTRL+SHIFT+I) // 3) Make sure the context dropdown is set to: "embed" (https://i.imgur.com/YfCY4WP.png) // 4) Paste the code below in the console and hit enter. (https://i.imgur.com/YAHjJXP.png) // 5) Leave window open and a pixel will be placed in the set // range every time your timer goes down // // NOTE: In the console panel in "Developer Tools", window // MUST be set to: hot-potato.reddit.com (embed) // Code won't work unless your source is that hot-potato iframe!! // // < ------- CODE BELOW -------> let monalisaEmbed = document.querySelector('mona-lisa-embed'); let monalisaContainer = monalisaEmbed.shadowRoot.querySelector('mona-lisa-share-container'); let camera = monalisaEmbed.camera; let status_pill = monalisaContainer.querySelector('mona-lisa-status-pill'); String.prototype.convertToRGB = function(){ let str = this.replace('#', ''); if(str.length != 6){ throw "Only six-digit hex colors are allowed."; } var aRgbHex = str.match(/.{1,2}/g); var aRgb = [ parseInt(aRgbHex[0], 16), parseInt(aRgbHex[1], 16), parseInt(aRgbHex[2], 16) ]; return aRgb; } let colors = { 1: {"hex": "#BE0039", "text": "dark red"}, 2: {"hex": "#FF4500", "text": "red"}, 3: {"hex": "#FFA800", "text": "orange"}, 4: {"hex": "#FFD635", "text": "yellow"}, 6: {"hex": "#00A368", "text": "dark green"}, 7: {"hex": "#00CC78", "text": "green"}, 8: {"hex": "#7EED56", "text": "light green"}, 9: {"hex": "#00CC78", "text": "dark teal"}, 10: {"hex": "#009EAA", "text": "teal"}, 12: {"hex": "#2450A4", "text": "dark blue"}, 13: {"hex": "#3690EA", "text": "blue"}, 14: {"hex": "#51E9F4", "text": "light blue"}, 15: {"hex": "#493AC1", "text": "indigo"}, 16: {"hex": "#6A5CFF", "text": "periwinkle"}, 18: {"hex": "#811E9F", "text": "dark purple"}, 19: {"hex": "#B44AC0", "text": "purple"}, 22: {"hex": "#FF3881", "text": "pink"}, 23: {"hex": "#FF99AA", "text": "light pink"}, 24: {"hex": "#6D482F", "text": "dark brown"}, 25: {"hex": "#9C6926", "text": "brown"}, 27: {"hex": "#000000", "text": "black"}, 29: {"hex": "#898D90", "text": "gray"}, 30: {"hex": "#D4D7D9", "text": "light gray"}, 31: {"hex": "#FFFFFF", "text": "white"} } function getColorXY(x, y) { let rangeMin = -4; let rangeMax = 4; let hexColor = monalisaContainer.getCanvasPixelColor({x: x, y: y}).toUpperCase(); for (i in colors) { let rgb1 = hexColor.convertToRGB(); let rgb2 = colors[i].hex.convertToRGB(); let c1 = rgb1[0] - rgb2[0]; let c2 = rgb1[0] - rgb2[0]; let c3 = rgb1[0] - rgb2[0]; if (c1 > rangeMin && c1 < rangeMax && c2 > rangeMin && c2 < rangeMax && c3 > rangeMin && c3 < rangeMax) { colors[i].number = i; return colors[i]; } } } // camera.animatePosition({x: index, y: index, zoom: 20}) function getNextSeconds() { return typeof status_pill.nextTileAvailableIn == 'number' ? status_pill.nextTileAvailableIn : 0; } function getRndInteger(min, max) { return Math.floor(Math.random() * (max - min) ) + min; } function getRnd(min, max) { return Math.floor(Math.random() * (max - min + 1) ) + min; } function placePixel(x, y, color) { monalisaEmbed.setFullScreen(true); monalisaEmbed.showColorPicker = true; camera.applyPosition({x: x, y: y, zoom: 50}); monalisaEmbed.selectedColor = color; setTimeout(()=> { let pixel = monalisaContainer.querySelector('mona-lisa-color-picker'); pixel.confirmPixel(); setTimeout(()=>{monalisaEmbed.showColorPicker = false;},100) }, 200); } function getRandomPixelFromRange(xy1, xy2) { let x = getRnd(xy1[0], xy2[0]); let y = getRnd(xy1[1], xy2[1]); return [x, y]; }; function expectedColor(y) { if ((y >= 430 && y <= 438) || (y >= 466 && y <= 475)) { return 14; } else if ((y >= 439 && y <= 447) || (y >= 457 && y <= 465)) { return 23; } else { return 31; } }; function placePixelRandomRange(xy1, xy2) { let rndPixelXY = getRandomPixelFromRange(xy1, xy2); let expected = expectedColor(rndPixelXY[1]); try { if (getColorXY(rndPixelXY[0], rndPixelXY[1]).number == expected) { console.log(`expected color already at (${rndPixelXY[0]}, ${rndPixelXY[1]})`); return placePixelRandomRange(xy1, xy2); } else { console.log(`expected color not found at (${rndPixelXY[0]}, ${rndPixelXY[1]}); painting...`); placePixel(rndPixelXY[0], rndPixelXY[1], expected); }; } catch (error) { console.log('Error: placePixelRandomRange', error); } } async function Main() { while (true) { await new Promise((resolve, reject) => setTimeout(resolve, 1000)); monalisaEmbed.wakeUp(); if (getNextSeconds() <= 1) { placePixelRandomRange(selection_xy1, selection_xy2); } } } let target_color = 27; let selection_xy1 = [481, 430]; let selection_xy2 = [691, 475]; Main();