StickyNotes

Заметки для юзеров Lolzteam

  1. // ==UserScript==
  2. // @name StickyNotes
  3. // @namespace StickyNotes
  4. // @version v2
  5. // @description Заметки для юзеров Lolzteam
  6. // @author https://zelenka.guru/lays (openresty)
  7. // @match https://zelenka.guru/*
  8. // @grant GM.setValue
  9. // @grant GM.getValue
  10. // @grant unsafeWindow
  11. // @run-at document-body
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. let notices;
  16.  
  17. (async function() {
  18. notices = await GM.getValue("notices") ? GM.getValue("notices") : `{"users": {}}`;
  19. window.addEventListener("DOMContentLoaded",(event) => {
  20. profileRender();
  21. });
  22. renderFunctions();
  23. })();
  24.  
  25. async function shortcutCall() {
  26. let returnit = `[exceptids=${await shortcut}]
  27. [/exceptids]`
  28. document.querySelector(".fr-element.fr-view.fr-element-scroll-visible p").innerHTML = await returnit;
  29. }
  30.  
  31.  
  32. function setShortcut(e) {
  33. GM.setValue("adblock", e)
  34. adblock = e;
  35. XenForo.alert('AdBlock настроен', 1, 10000)
  36. }
  37.  
  38.  
  39. async function profileRender() {
  40. if (!document.querySelector(".avatarScaler")) {return false;}
  41. notices = await JSON.parse(await notices);
  42. nick_val = document.querySelector("h1.username span").innerHTML.replace(/ <i.*?>.*?<\/i>/ig,'')
  43. let noticer = document.querySelector(".insuranceDeposit");
  44. if (!notices.users[nick_val]) {
  45. notices.users[nick_val] = {
  46. 'text': 'заметка не установлена'
  47. }
  48. notice = await notices.users[nick_val]
  49. }else {
  50. notice = await notices.users[nick_val]
  51. }
  52. let notice_render = `
  53. <br>
  54. <div class="section insuranceDeposit">
  55. <div class="secondaryContent">
  56. <h3>
  57. Заметка для ${nick_val}
  58. </h3>
  59.  
  60. <h3 style="margin-bottom: 0px; font-size: 18px !important;" class="amount">
  61. ${await notice.text}
  62. </h3>
  63. <div style="margin-top: 15px; display: flex; gap: 5px;">
  64. <a class="button leftButton primary" onclick="noteSet(nick_val)">Изменить заметку</a>
  65. </div>
  66. </div>
  67. </div>`;
  68. // <a class="button leftButton primary" onclick="voteTrust(${blzt_trust_val})">Изменить рейтинг👍👎</a>
  69. let notice_block = document.createElement("div");
  70. notice_block.innerHTML = notice_render;
  71.  
  72. noticer.append(notice_block);
  73. }
  74.  
  75. function noteSet(trust) {
  76. nick_val = document.querySelector("h1.username span").innerHTML.replace(/ <i.*?>.*?<\/i>/ig,'')
  77. let html = `
  78. <i>Введите комментарий,>
  79. <input id="commentt" style=" padding: 6px;border-radius: 6px;height: 20px;background: #303030;color: white;border: 1px solid rgb(54, 54, 54); placeholder="Заметка">
  80. <div style="margin-top: 15px; display: flex; gap: 5px;">
  81. <a class="button leftButton primary" onclick="commitNote('${nick_val}')">Сохранить</a>
  82. `;
  83. XenForo.alert(html, "Изменить заметку");
  84. }
  85.  
  86. async function commitNote(nick_val) {
  87. console.log(await notices)
  88. notices = await JSON.parse(await notices);
  89. let comment = document.querySelector("#commentt").value;
  90. if (!comment) {
  91. return XenForo.alert("Укажите комментарий!", 1, 10000)
  92. }
  93. if (!notices.users[nick_val]) {
  94. notices.users[nick_val] = {
  95. 'text': comment
  96. }
  97. }else {
  98. notices.users[nick_val].text = comment;
  99. }
  100. setCache(JSON.stringify(notices))
  101. location.reload()
  102. }
  103.  
  104. async function setCache(e) {
  105. return await GM.setValue('notices', e);
  106. }
  107.  
  108. function renderFunctions() {
  109. unsafeWindow.notices = notices;
  110. unsafeWindow.setShortcut = e => setShortcut(e);
  111. let torender = [dialogWin, commitNote, noteSet, profileRender];
  112. unsafeWindow.setCache = e => setCache(e);
  113. let funcs = torender.map(e => e.toString());
  114. let script = document.createElement('script');
  115. script.appendChild(document.createTextNode(funcs.join("")));
  116. document.head.appendChild(script);
  117. }
  118.  
  119. async function dialogWin() {
  120. nickname = document.querySelector(".accountUsername.username").firstElementChild.innerText.trim().replace(/<[^>]*>/g, ' ').replace(/\s{2,}/g, ' ').trim().replace(" Premium", "").trim();
  121.  
  122. let htmlall = `
  123. <div id="settings1-content" class="settings-content">
  124. <h2>FuckMouse</h2>
  125. <label>
  126. <span>ID Юзеров (через запятую)</span><br>
  127. <input id="secretph" placeholder="123, 1234, и т.д..." style="margin-top: 4px;">
  128. <a onclick="setShortcut(document.querySelector('#secretph').value)">Сохранить</a>
  129. </label>
  130. </div>
  131.  
  132.  
  133.  
  134. <style>
  135. .errorOverlay>.baseHtml {
  136. padding: 0px;
  137. }
  138. .xenOverlay .errorOverlay .errorDetails {
  139. padding: 0px;
  140. white-space: normal;
  141. }
  142. .errorDetails {
  143. white-space: normal;
  144. padding: 0;
  145. margin: 0;
  146. font-family: sans-serif;
  147. background-color: #303030;
  148. color: white;
  149. }
  150. input {
  151. padding: 4px;
  152. border-radius: 6px;
  153. height: 20px;
  154. background: #303030;
  155. color: white;
  156. border: 1px solid rgb(0, 186, 120);
  157. }
  158. .settings-content {
  159. padding: 20px;
  160. /* border: 1px solid #ccc; */
  161. transition: 0.5s;
  162. }
  163. button {
  164. color: #fff;
  165. border: 0;
  166. background: 0;
  167. padding: 0 0 5px;
  168. margin-left: 7px;
  169. font-size: 15px;
  170. transition: 0.5s;
  171. }
  172. .customicon {
  173. background-color:#424141;
  174. padding: 10px;
  175. transition: .1s;
  176. }
  177. .customicon:hover {
  178. background-color:#242424;
  179. }
  180. .available {
  181. border-top: 1px solid rgb(0, 186, 120);
  182. }
  183. .onlyprem {
  184. border-top: 1px solid rgb(177, 0, 9);
  185. }
  186. </style>
  187. <script>
  188. var elements = document.querySelectorAll('button');
  189.  
  190. for (var i = 0; i < elements.length; i++) {
  191. elements[i].addEventListener('click', function(e) {
  192. for (let index = 1; index < 50; index++) {
  193. try {
  194. document.getElementById('settings' + index + '-content').style.display = 'none';
  195. document.getElementById('settings' + index).style.boxShadow = 'none';
  196. } catch{}
  197. }
  198.  
  199. e.target.style = "box-shadow: inset 0px -2px 0px 0px rgb(0, 186, 120);";
  200. document.getElementById(e.target.id + '-content').style.display = 'block';
  201. });
  202. }
  203. </script>
  204.  
  205. `
  206. let html_prem = `
  207. ${htmlall}
  208. `;
  209. return XenForo.alert(
  210. `${html_prem}`, 'Настройки FuckMouse.'
  211. )
  212. }