blob: 05b7b943f3bc5c1878cea20417ab3d1cfa897f41 [file] [log] [blame]
user254f2719812026-02-09 16:50:17 +09001/**
2 * This site uses weird type of CAPTCHA. It downloads code from captcha-code.php
3 * and puts it into span tag to display the code. This script extracts the code
4 * with MutationObserver and skips entire download form because its only purpose
5 * is to annoy the user with shitty CAPTCHA. CSS is included to hide the form.
6 */
7
8const ctaBlock = document.querySelector('#cta-block')
9const captchaInput = document.querySelector('#captcha')
10const downloadForm = document.querySelector('#form_download')
11const submitButton = document.querySelector('#form_download button[type=submit]')
12
13const observer = new MutationObserver((mutationList, observer) => {
14 for (const mutation of mutationList) {
15 if (mutation.type === 'childList') {
16 const code = mutation.addedNodes[0].textContent
17 console.log('Found and inserted code: ', code)
18 captchaInput.value = code
19 console.log('Submitting download form')
20 downloadForm.requestSubmit(submitButton)
21 }
22 }
23})
24observer.observe(ctaBlock, {
25 childList: true,
26 subtree: true
27})
28
29console.log('observer installed: ', observer)