topic.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. function opennamu_do_remove_blind_thread() {
  3. const style = document.querySelector('#opennamu_remove_blind');
  4. if(style !== null) {
  5. if(style.innerHTML !== "") {
  6. style.innerHTML = '';
  7. } else {
  8. style.innerHTML = `
  9. .opennamu_comment_blind_js {
  10. display: none;
  11. }
  12. `;
  13. }
  14. }
  15. }
  16. function opennamu_thread_blind() {
  17. let do_true = 0;
  18. for(let for_a = 0; for_a < document.getElementsByClassName("opennamu_blind_button").length; for_a++) {
  19. let id = document.getElementsByClassName("opennamu_blind_button")[for_a].id;
  20. id = id.replace(/^opennamu_blind_/, '');
  21. id = id.split('_');
  22. let checked = document.getElementsByClassName("opennamu_blind_button")[for_a].checked;
  23. if(checked) {
  24. fetch("/thread/" + id[0] + '/comment/' + id[1] + '/blind', { method : 'GET' });
  25. do_true = 1;
  26. }
  27. }
  28. if(do_true === 1) {
  29. history.go(0);
  30. }
  31. }
  32. function opennamu_thread_where() {
  33. for(let for_a = 0; for_a < document.getElementsByClassName('opennamu_comment_data_main').length; for_a++) {
  34. let data = document.getElementsByClassName('opennamu_comment_data_main')[for_a].innerHTML;
  35. let id = document.getElementsByClassName('opennamu_comment_data_main')[for_a].id.replace(/^thread_/, '');
  36. let match = Array.from(data.matchAll(/<a href="#(?:[0-9]+)">#([0-9]+)<\/a>/g)).map(match => match[1]);
  37. console.log(data);
  38. if(match) {
  39. console.log(match);
  40. for(let for_b = 0; for_b < match.length; for_b++) {
  41. if(document.getElementById('opennamu_topic_req_' + match[for_b])) {
  42. if(document.getElementById('opennamu_topic_req_' + match[for_b]).innerHTML === '') {
  43. document.getElementById('opennamu_topic_req_' + match[for_b]).innerHTML += '<hr>'
  44. }
  45. document.getElementById('opennamu_topic_req_' + match[for_b]).innerHTML += '<a href="#' + id + '">#' + id + '</a> ';
  46. }
  47. }
  48. }
  49. }
  50. }