Hackthis.co.uk coding level 1

Calculates and fills in the solution to coding level 1 on hackthis.co.uk

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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
// @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);