[LZT] UP Threads with Hundle

Поднятие темы без задержки

  1. // ==UserScript==
  2. // @name [LZT] UP Threads with Hundle
  3. // @namespace [LZT] UP Threads with Hundle
  4. // @version 0.1
  5. // @description Поднятие темы без задержки
  6. // @author molihan
  7. // @match https://zelenka.guru/?tab=mythreads*
  8. // @match https://lolz.guru/?tab=mythreads*
  9. // @icon https://zelenka.guru/favicon.ico
  10. // @grant Не украл, а спиздил
  11. // @license molihan
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. const inputElement = document.querySelector('input[type="hidden"][name="_xfToken"]');
  17. const xfTokenValue = inputElement.value;
  18. let _unixTime = Math.floor(Date.now() / 1000);
  19. function init() {
  20. if(xfTokenValue) {
  21. const elements_threads = document.querySelectorAll('[id*="thread-"]');
  22. elements_threads.forEach(function(element) {
  23. const idValue = element.getAttribute('id');
  24. const parts = idValue.split('thread-');
  25. if (parts.length > 1) {
  26. const deleteIcon = element.querySelector(".fa-arrow-to-top");
  27. if(deleteIcon) {
  28. deleteIcon.remove();
  29. const thread_id = parts[1];
  30. let _lockIcon = element.querySelector('.iconKey.fa.fa-lock.Tooltip');
  31. const Tooltip = element.querySelector('.controls');
  32. if(Tooltip) {
  33. const copyElement = document.createElement("a");
  34. copyElement.setAttribute("class", "StarContent threadControl far fa-arrow-to-top Tooltip");
  35. copyElement.setAttribute("title", "Поднять тему");
  36. Tooltip.appendChild(copyElement);
  37. copyElement.addEventListener('click', function(event) {
  38. event.preventDefault();
  39. const currentUnixtime = Math.floor(Date.now() / 1000);
  40. const time = (_unixTime >= currentUnixtime) ? (_unixTime - currentUnixtime) * 1000 : 0;
  41. console.log(_unixTime, currentUnixtime, time);
  42. setTimeout(function(thread_id, xfToken) {
  43. fetch("https://zelenka.guru/threads/" + thread_id + "/bump?from_list=1&&_xfRequestUri=%2F%3Ftab%3Dmythreads&_xfNoRedirect=1&_xfToken=" + xfToken + "&_xfResponseType=json", {
  44. "headers": {
  45. "accept": "application/json, text/javascript, */*; q=0.01",
  46. "cache-control": "no-cache",
  47. "pragma": "no-cache",
  48. "x-ajax-referer": "https://zelenka.guru/?tab=mythreads&order=last_post_date&direction=desc",
  49. "x-requested-with": "XMLHttpRequest",
  50. "Referer": "https://zelenka.guru/?tab=mythreads&order=last_post_date&direction=desc",
  51. "Referrer-Policy": "strict-origin-when-cross-origin"
  52. },
  53. "body": null,
  54. "method": "GET"
  55. });
  56. XenForo.alert("Запрос на поднятие темы был отправлен.", "Оповещение", 2000);
  57. }, time, thread_id, xfTokenValue);
  58. if(_unixTime >= currentUnixtime) _unixTime += 6;
  59. else _unixTime = Math.floor(Date.now() / 1000) + 6;
  60. });
  61. }
  62. }
  63. }
  64. });
  65. }
  66. }
  67. async function ones(element) {
  68. if(xfTokenValue) {
  69. try {
  70. const idValue = element.getAttribute('id');
  71. if(idValue) {
  72. const parts = idValue.split('thread-');
  73. if (parts.length > 1) {
  74. const deleteIcon = element.querySelector(".fa-arrow-to-top");
  75. if(deleteIcon) {
  76. deleteIcon.remove();
  77. const thread_id = parts[1];
  78. let _lockIcon = element.querySelector('.iconKey.fa.fa-lock.Tooltip');
  79. const Tooltip = element.querySelector('.controls');
  80. if(Tooltip) {
  81. const copyElement = document.createElement("a");
  82. copyElement.setAttribute("class", "StarContent threadControl far fa-arrow-to-top Tooltip");
  83. copyElement.setAttribute("title", "Поднять тему");
  84. Tooltip.appendChild(copyElement);
  85. copyElement.addEventListener('click', function(event) {
  86. event.preventDefault();
  87. const currentUnixtime = Math.floor(Date.now() / 1000);
  88. const time = (_unixTime >= currentUnixtime) ? (_unixTime - currentUnixtime) * 1000 : 0;
  89. setTimeout(function(thread_id, xfToken) {
  90. fetch("https://zelenka.guru/threads/" + thread_id + "/bump?from_list=1&&_xfRequestUri=%2F%3Ftab%3Dmythreads&_xfNoRedirect=1&_xfToken=" + xfToken + "&_xfResponseType=json", {
  91. "headers": {
  92. "accept": "application/json, text/javascript, */*; q=0.01",
  93. "cache-control": "no-cache",
  94. "pragma": "no-cache",
  95. "x-ajax-referer": "https://zelenka.guru/?tab=mythreads&order=last_post_date&direction=desc",
  96. "x-requested-with": "XMLHttpRequest",
  97. "Referer": "https://zelenka.guru/?tab=mythreads&order=last_post_date&direction=desc",
  98. "Referrer-Policy": "strict-origin-when-cross-origin"
  99. },
  100. "body": null,
  101. "method": "GET"
  102. });
  103. XenForo.alert("Запрос на поднятие темы был отправлен.", "Оповещение", 2000);
  104. }, time, thread_id, xfTokenValue);
  105. if(_unixTime >= currentUnixtime) _unixTime += 6;
  106. else _unixTime = Math.floor(Date.now() / 1000) + 6;
  107. });
  108. }
  109. }
  110. }
  111. }
  112. } catch(error) {};
  113. }
  114. }
  115. const observer = new MutationObserver((mutationsList, observer) => {
  116. for (const mutation of mutationsList) {
  117. if (mutation.type === 'childList') {
  118. mutation.addedNodes.forEach(addedNode => {
  119. if (addedNode.nodeType === Node.ELEMENT_NODE) {
  120. ones(addedNode);
  121. }
  122. });
  123. }
  124. }
  125. });
  126. const config = { childList: true, subtree: true };
  127. observer.observe(document.body, config);
  128. init();
  129. })();