Last active
January 12, 2022 05:10
-
-
Save masnormen/5972469b45f0ac8f9e1a5ef8a7524cdd to your computer and use it in GitHub Desktop.
Kuesioner SIAM UB Autofill Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// © 2022 Nourman Hajar | |
// Checkbox kuesioner akan dipilih secara acak antara nilai min dan max. | |
// Cara pakai: | |
// Buka halaman SIAM yang berisi pertanyaan kuesioner > Buka DevTools Chrome (atau pencet F12) > Copas kode ini di situ > Tekan Enter | |
// Masukkan nilai min dari pilihan | |
const min = 3 | |
// Masukkan nilai max dari pilihan | |
const max = 5 | |
const result = document.evaluate("//tr[@class='text' and descendant::input[@type='radio']]", document, null, XPathResult.ANY_TYPE, null); | |
let node, nodes = [] | |
while (node = result.iterateNext()) nodes.push(node); | |
for (node of nodes) { | |
const checkboxes = node.querySelectorAll('input'); | |
const value = Math.floor(Math.random() * (max - min + 1)) + min; | |
checkboxes[Math.min(Math.max(value, 1), checkboxes.length) - 1].checked = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment