diff --git a/assets/assetpack.def b/assets/assetpack.def index e2a5c19..95a23dc 100644 --- a/assets/assetpack.def +++ b/assets/assetpack.def @@ -3,3 +3,6 @@ < css/elements.css < css/simple.css < css/nested.css + +! app.js +< js/captcha.js diff --git a/assets/js/captcha.js b/assets/js/captcha.js index eb3fddf..8fd0ace 100644 --- a/assets/js/captcha.js +++ b/assets/js/captcha.js @@ -1,13 +1,20 @@ -/* 'use strict'; -document.getElementById('captcha').value = -*/ - -'use strict'; - -let captchaValue = - document +(() => { + let captchaValue = document .querySelector('label[for="captcha"]') .textContent .match(/'(flag|bump)'/)[1]; + let captchaForm = document + .querySelector('form[class="form-body"]'); + + captchaForm.captcha.value = captchaValue; + // Make 'em work for it + window.crypto.subtle.generateKey({ + name: 'RSA-OAEP', + modulusLength: 4096, + publicExponent: new Uint8Array([1, 0, 1]), + hash: 'SHA-512' + }, false, ['encrypt', 'decrypt']) + .finally(() => captchaForm.submit()); +})(); diff --git a/templates/remark/flag.html.ep b/templates/remark/flag.html.ep index 0e468a0..be69738 100644 --- a/templates/remark/flag.html.ep +++ b/templates/remark/flag.html.ep @@ -10,6 +10,7 @@ <% } =%> <%= label_for captcha => "Enter the word 'flag' to confirm:" %> <%= text_field captcha => id => 'captcha' %> + <%= asset 'app.js' %> diff --git a/templates/thread/bump.html.ep b/templates/thread/bump.html.ep index 2280204..7ec8625 100644 --- a/templates/thread/bump.html.ep +++ b/templates/thread/bump.html.ep @@ -10,6 +10,7 @@ <% } =%> <%= label_for captcha => "Enter the word 'bump' to confirm:" %> <%= text_field captcha => id => 'captcha' %> + <%= asset 'app.js' %> diff --git a/templates/thread/flag.html.ep b/templates/thread/flag.html.ep index 30ba7bf..1aba7cd 100644 --- a/templates/thread/flag.html.ep +++ b/templates/thread/flag.html.ep @@ -10,6 +10,7 @@ <% } =%> <%= label_for captcha => "Enter the word 'flag' to confirm:" %> <%= text_field captcha => id => 'captcha' %> + <%= asset 'app.js' %>