JKFORUM

enter something useful

  1. // ==UserScript==
  2. // @name JKFORUM
  3. // @namespace http://your.homepage/
  4. // @version 0.5
  5. // @description enter something useful
  6. // @author You
  7. // @match https://www.jkforum.net/forum-*.html
  8. // @match https://www.jkforum.net/thread-*.html
  9. // @match https://www.jkforum.net/forum.php?mod=viewthread&*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. function forEach(elems, func) {
  14. for (var i = 0; i < elems.length; i++) {
  15. func(elems[i]);
  16. }
  17. return elems.length > 0;
  18. }
  19.  
  20. function automate() {
  21. forEach(document.querySelectorAll('p'),
  22. function(i) { if (i.textContent.trim()=='已經感謝過此篇文章') location.reload(); });
  23. forEach(document.querySelectorAll('#fwin_k_thankauthor'),
  24. function(i) { hideWindow('k_thankauthor'); });
  25. forEach(document.querySelectorAll('#fwin_dialog #periodaggre18'),
  26. function(i) { i.checked=true; });
  27. forEach(document.querySelectorAll('#fwin_dialog #fwin_dialog_submit'), function(i) { i.click(); });
  28. if (document.querySelectorAll('.status_loginned').length) {
  29. forEach(document.querySelectorAll('.like_locked #k_thankauthor'), function(i) {
  30. if (i.offsetHeight) i.click();
  31. });
  32. }
  33. }
  34.  
  35. var func = function() {
  36. automate();
  37. setTimeout(func, 1000);
  38. };
  39.  
  40. setTimeout(func, 1000);
  41.  
  42. (function(){
  43. var e = document.createElement('div');
  44. e.setAttribute('style','padding:5px;border:1px solid black;background:white;position:fixed;right:5px;bottom:5px;');
  45. var b = document.createElement('button');
  46. b.innerHTML='Open all thread';
  47. b.onclick = function() {
  48. var i = 0;
  49. var list = [];
  50. forEach(document.querySelectorAll('#threadlist a'), function(a) {
  51. var href = a.href;
  52. if (href.match(/thread.*html$/) && list.indexOf(href) == -1) {
  53. list.push(href);
  54. window.open(href,'_blank');
  55. i++;
  56. }
  57. });
  58. console.log(i);
  59. };
  60. e.appendChild(b);
  61. document.body.appendChild(e);
  62. })();