Sorryops

Skip the half of the fun!

当前为 2024-04-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Sorryops
  3. // @namespace sorryops
  4. // @version 20240410.1
  5. // @description Skip the half of the fun!
  6. // @icon https://orioks.miet.ru/favicon.ico
  7. // @author electromagneticcyclone & angelbeautifull
  8. // @license Unlicense
  9. // @supportURL https://git.disroot.org/electromagneticcyclone/sorryops
  10. // @match https://orioks.miet.ru/student/student/test*
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @run-at document-start
  14. // ==/UserScript==
  15.  
  16. window.addEventListener('load', actionFunction);
  17.  
  18. function actionFunction() {
  19. var objects = new Object();
  20. var boxes = document.getElementsByTagName('input');
  21. var form = document.getElementById('testform-answer');
  22. for (var i = 0; i < boxes.length; i++) {
  23. if (boxes[i].type === 'checkbox' | boxes[i].type === 'radio') {
  24. var span = document.createElement('span');
  25. span.innerHTML =
  26. boxes[i].type === 'radio' && boxes[i].value == "1"
  27. ? "<b>" + boxes[i].value + ")</b> "
  28. : boxes[i].value + ") ";
  29. boxes[i].parentNode.insertBefore(span, boxes[i]);
  30. objects[boxes[i].value] = boxes[i].parentNode;
  31. }
  32. }
  33. const sorted_objects = Object.keys(objects).sort().reduce(
  34. (obj, key) => {
  35. obj[key] = objects[key];
  36. return obj;
  37. }, {}
  38. );
  39. console.log(form);
  40. for (var key in sorted_objects) {
  41. sorted_objects[key].remove();
  42. form.appendChild(sorted_objects[key]);
  43. }
  44. }