PostText/assets/js/captcha.js

32 lines
890 B
JavaScript
Raw Normal View History

2023-06-14 01:25:55 -04:00
'use strict';
2023-06-14 18:49:30 -04:00
(() => {
2023-06-14 20:17:07 -04:00
// Make 'em work for it!
let doCryptoStuff = window.crypto.subtle.generateKey({
name: 'RSA-OAEP',
modulusLength: 4096,
publicExponent: new Uint8Array([1, 0, 1]),
hash: 'SHA-512'
}, false, ['encrypt', 'decrypt']);
2023-06-14 18:49:30 -04:00
let captchaValue = document
2023-06-14 01:25:55 -04:00
.querySelector('label[for="captcha"]')
.textContent
.match(/'(flag|bump)'/)[1];
2023-06-14 18:49:30 -04:00
let captchaForm = document
.querySelector('form[class="form-body"]');
2023-06-14 20:17:07 -04:00
captchaForm.captcha.readOnly = true;
captchaForm.captcha.value = '⏳';
doCryptoStuff
.then(() => {
captchaForm.captcha.value = captchaValue;
captchaForm.submit();
})
.catch((err) => {
captchaForm.captcha.value = null;
captchaForm.captcha.readOnly = false;
console.log(err);
});
2023-06-14 18:49:30 -04:00
})();