-
-
Save PhompAng/10076b7789593462ef5438a80410a242 to your computer and use it in GitHub Desktop.
Script to add to gartic.io
This file contains 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
const setNativeValue = (element, value) => { | |
const valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set; | |
const prototype = Object.getPrototypeOf(element); | |
const prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set; | |
if (valueSetter && valueSetter !== prototypeValueSetter) { | |
prototypeValueSetter.call(element, value); | |
} else { | |
valueSetter.call(element, value); | |
} | |
element.dispatchEvent(new Event('input', { bubbles: true })); | |
}; | |
const main = src => { | |
const words = src.split('\n').filter(_ => _).map(_ => _.trim()).filter((v, i, a) => a.indexOf(v) === i); | |
const $input = document.querySelector('#screens > div > div.content.bg.createTheme > div.globalSettings > div:nth-child(3) > form > div:nth-child(1) > label.text > input[type="text"]'); | |
const $difficulties = ['easy', 'medium', 'hard'].map(id => document.getElementById(id)); | |
const $btAdd = document.querySelector('#screens > div > div.content.bg.createTheme > div.globalSettings > div:nth-child(3) > form > div:nth-child(1) > label.btAdd > input'); | |
let i = 0; | |
const doSingle = () => { | |
if (i >= words.length) { window.alert('All done!'); return; } | |
const entry = words[i]; | |
setNativeValue($input, entry) | |
$difficulties[0].click(); | |
setTimeout(() => { | |
$btAdd.click(); | |
i++; | |
setTimeout(doSingle, 150); | |
}, 150); | |
}; | |
doSingle(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment