-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hackthis.co.uk coding level 1.js
36 lines (33 loc) · 1.14 KB
/
Hackthis.co.uk coding level 1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// ==UserScript==
// @name Hackthis.co.uk coding level 1
// @namespace urn://https://www.georgegillams.co.uk/greasemonkey/hackthis_coding_1
// @include https://www.hackthis.co.uk/levels/coding/1
// @exclude none
// @version 3.0.0
// @description Calculates and fills in the solution to coding level 1 on hackthis.co.uk
// @description:en Calculates and fills in the solution to coding level 1 on hackthis.co.uk
// @grant none
// ==/UserScript==
let sortedString = 'INCOMPLETE';
function solveLevel() {
if (sortedString !== 'INCOMPLETE') {
return;
}
const allElements = document.getElementsByTagName('textarea');
for (let i = 0; i < allElements.length; i += 1) {
const element = allElements[i];
if (element.style.height === '140px') {
element.style.backgroundColor = '#44aeff';
if (sortedString === 'INCOMPLETE') {
const value = element.value.split(',').join('');
const values = value.split(' ');
const sorted = values.sort();
sortedString = sorted.join(', ');
} else {
element.value = sortedString;
}
}
}
}
solveLevel();
setInterval(solveLevel, 500);