Display unique question variant
This commit is contained in:
parent
27498c3409
commit
e6b5d74962
26
user.js
26
user.js
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name Sorryops
|
||||
// @namespace sorryops
|
||||
// @version 20240410.1
|
||||
// @version 20240410.2
|
||||
// @description Skip the half of the fun!
|
||||
// @icon https://orioks.miet.ru/favicon.ico
|
||||
// @author electromagneticcyclone & angelbeautifull
|
||||
|
@ -15,11 +15,20 @@
|
|||
|
||||
window.addEventListener('load', actionFunction);
|
||||
|
||||
// https://stackoverflow.com/a/15710692
|
||||
function hashCode(s) {
|
||||
return s.split("").reduce(function(a, b) {
|
||||
a = ((a << 5) - a) + b.charCodeAt(0);
|
||||
return a & a;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function actionFunction() {
|
||||
var i;
|
||||
var objects = new Object();
|
||||
var boxes = document.getElementsByTagName('input');
|
||||
var form = document.getElementById('testform-answer');
|
||||
for (var i = 0; i < boxes.length; i++) {
|
||||
for (i = 0; i < boxes.length; i++) {
|
||||
if (boxes[i].type === 'checkbox' | boxes[i].type === 'radio') {
|
||||
var span = document.createElement('span');
|
||||
span.innerHTML =
|
||||
|
@ -36,9 +45,18 @@ function actionFunction() {
|
|||
return obj;
|
||||
}, {}
|
||||
);
|
||||
console.log(form);
|
||||
for (var key in sorted_objects) {
|
||||
sorted_objects[key].remove();
|
||||
form.appendChild(sorted_objects[key]);
|
||||
}
|
||||
}
|
||||
var variant = document.getElementById('w0').parentNode.textContent;
|
||||
variant = variant.slice(variant.indexOf("Вопрос:"));
|
||||
var pboxes = document.getElementsByTagName('p');
|
||||
for (i = 0; i < pboxes.length; i++) {
|
||||
var pbox = pboxes[i];
|
||||
if (pbox.textContent == "Вопрос:") {
|
||||
pbox.innerHTML = "<i>(Вариант " + hashCode(variant) + ")</i><br>" + pbox.textContent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue