Advertisement
fernozzle

Gay OWOT CP Chat Links

Sep 15th, 2023
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.36 KB | None | 0 0
  1. // The ultimate discord owot chat combo
  2.  
  3. /* OWOT ECF BY E_G. */
  4. send = function(msg){
  5. w.chat.send(msg);
  6. }
  7. random = function(min, max){
  8. return Math.random() * max + min;
  9. }
  10. bot = function(command, func){
  11. w.on("chatmod", function(e){
  12. e.id += "";
  13. if(Function("data", "return " + command)(e)){
  14. func(e, e.message.split(" ").slice(1), e.realUsername || e.nickname || e.id);
  15. };
  16. });
  17. };
  18. client_commands.bot = function(args){
  19. bot(args[0], Function("data, args, name", args.slice(1).join(" ")));
  20. }
  21. var hasDoneAction = false;
  22. function findReply(e){
  23. var message = (e.message || [...e.element.children].at(-1).innerHTML);
  24. var extractedReply = message.substring(!e.message * 6, message.indexOf(")") + 2);
  25. var matchesSyntax = extractedReply.match(/^reply\(\d+\) /g);
  26. if(!matchesSyntax) return false;
  27. var replyDate = matchesSyntax[0].match(/\d+/)[0];
  28. var reply = [...chatRecordsPage, ...chatRecordsGlobal].filter(x => x.date == replyDate);
  29. if(reply[0] == undefined) return false;
  30. addChat(e.location || (e.field.id.startsWith("page") ? "page" : "global"), reply[0].id, "anon", "template", "<span id='template'></span>", "template", true);
  31. var template = document.getElementById("template").parentNode.parentNode;
  32. if(e.element) template.parentNode.insertBefore(template, e.element);
  33. template.outerHTML = reply[0].element.outerHTML;
  34. var finalReply = [...elm[(e.message ? e.location : e.field.id.startsWith("page") ? "page" : "global")+"_chatfield"].children].filter(x => x.outerHTML == reply[0].element.outerHTML);
  35. [...[...finalReply].at(-1).children].forEach(y => {y.style.fontSize = "10px"; y.id = ""});
  36. return finalReply;
  37. };
  38.  
  39. w.on("chatmod", function(e){
  40. var field = e.location == "page" ? "Page" : "Global";
  41. e.replyOfMessage = findReply(e);
  42. if(e.replyOfMessage){
  43. e.message = e.message.replace(/reply\(\d+\) /, "");
  44. };
  45. setTimeout(function(){
  46. var div = window["chatRecords" + field].filter(x=>x.date == e.date && x.id == e.id)[0].element;
  47. var matchLink = [...div.children].at(-1).innerHTML.match(/link\(.+\) /);
  48. if(matchLink){
  49. [...div.children].at(-1).outerHTML = `<a> </a><a href=${matchLink[0].substring(5,matchLink[0].length-2)} style="color: #0070E0"><u>${[...div.children].at(-1).innerHTML.replace(/link\(.+\) /, "").substring(6)}</u></a>`;
  50. return;
  51. };
  52. var string = [...div.children].at(-1).children.length ? [...div.children].at(-1).children[0].innerHTML : [...div.children].at(-1).innerHTML;
  53. var hexValues = string.match(/#[0-9A-F]{6}|#[0-9A-F]{3}|rgb\(\d{1,3}, ?\d{1,3}, ?\d{1,3}\)/g);
  54. var stringSpan = "<span>" + (string.split(/#[0-9A-F]{6}|#[0-9A-F]{3}|rgb\(\d{1,3}, ?\d{1,3}, ?\d{1,3}\)/g).join`</span><span style="color: ">` + "</span>");
  55. if(hexValues){
  56. hexValues.forEach(x => stringSpan = stringSpan.replace(/<span style="color: ">/, `<span style="color: ${x}">`));
  57. if(stringSpan.startsWith("<span>&gt;")) return;
  58. [...div.children].at(-1).outerHTML = stringSpan;
  59. };
  60. div.onclick = function(x){
  61. if(!x.shiftKey) return;
  62. div.remove();
  63. if(!e.replyOfMessage) return;
  64. e.replyOfMessage.remove();
  65. };
  66. [...div.children].forEach(function(i){
  67. i.onclick = function(x){
  68. if(x.ctrlKey){
  69. elm.chatbar.value = "reply(" + e.date + ") ";
  70. elm.chatbar.focus();
  71. };
  72. };
  73. });
  74. });
  75. if(hasDoneAction) return;
  76. hasDoneAction = true;
  77. [...chatRecordsPage, ...chatRecordsGlobal].forEach(function(e){
  78. var field = e.location == "page" ? "Page" : "Global";
  79. e.replyOfMessage = findReply(e);
  80. if(e.replyOfMessage){
  81. [...e.element.children].at(-1).innerHTML = [...e.element.children].at(-1).innerHTML.replace(/reply\(\d+\) /, "");
  82. };
  83. var matchLink = [...e.element.children].at(-1).innerHTML.match(/link\(.+\) /);
  84. if(matchLink){
  85. [...e.element.children].at(-1).outerHTML = `<a> </a><a href=${matchLink[0].substring(5,matchLink[0].length-2)} style="color: #0070E0"><u>${[...e.element.children].at(-1).innerHTML.replace(/link\(.+\) /, "").substring(6)}</u></a>`;
  86. return;
  87. };
  88. var string = [...e.element.children].at(-1).innerHTML;
  89. var hexValues = string.match(/#[0-9A-F]{6}|#[0-9A-F]{3}|rgb\(\d{1,3}, ?\d{1,3}, ?\d{1,3}\)/g);
  90. var stringSpan = "<span>" + (string.split(/#[0-9A-F]{6}|#[0-9A-F]{3}|rgb\(\d{1,3}, ?\d{1,3}, ?\d{1,3}\)/g).join`</span><span style="color: ">` + "</span>");
  91. if(hexValues){
  92. hexValues.forEach(x => stringSpan = stringSpan.replace(/<span style="color: ">/, `<span style="color: ${x}">`));
  93. if(stringSpan.startsWith('<span>&nbsp;<span style="color: </span><span style="color: #789922">">&gt;')) return;
  94. [...e.element.children].at(-1).outerHTML = stringSpan;
  95. };
  96. });
  97. [...chatRecordsPage, ...chatRecordsGlobal].forEach(function(x){
  98. x.element.onclick = function(e){
  99. if(e.shiftKey) x.element.remove();
  100. };
  101. [...x.element.children].forEach(function(i){
  102. i.onclick = function(e){
  103. if(e.ctrlKey) elm.chatbar.value = "reply(" + x.date + ") ";
  104. elm.chatbar.focus();
  105. };
  106. });
  107. });
  108. });
  109.  
  110. /* OWOT USER INDICATOR BY E_G. */
  111.  
  112. let warn = true;
  113. let people = [];
  114. let timeout;
  115.  
  116. //Part made by KKosty4ka
  117. var chat_upper = document.getElementById("chat_upper");
  118. chat_upper.appendChild(document.createElement("br"));
  119. var typing_display = chat_upper.appendChild(document.createElement("span"));
  120. typing_display.style.display = "flex";
  121. typing_display.style.justifyContent = "center";
  122. typing_display.style.alignItems = "center";
  123. //Part made by KKosty4ka
  124.  
  125. menu.addCheckboxOption('Online Offline warning', function(){
  126. warn = true;
  127. }, function(){
  128. warn = false;
  129. }, true);
  130.  
  131. w.broadcastReceive(true);
  132. w.on('cmd', function(e){
  133. if(!e.username || !warn) return;
  134. if(e.data.startsWith('online')){
  135. clientChatResponse(e.username + " is online!");
  136. }
  137. else if(e.data.startsWith('offline')){
  138. clientChatResponse(e.username + " is now offline.");
  139. }
  140. else if(e.data.startsWith('back')){
  141. clientChatResponse(e.username + " is back.");
  142. }
  143. else if(e.data.startsWith('afk')){
  144. clientChatResponse(e.username + " is AFK. (Idle)");
  145. }
  146. else if(e.data.startsWith('typing')){
  147. if(!people.includes(e.username)) people.push(e.username);
  148. typing_display.innerText = people.join(" and ") + " " + (people.length > 1 ? "are" : "is") + " typing...";
  149. }
  150. else if(e.data.startsWith('untyping')){
  151. people = people.filter((x, i)=>i != people.indexOf(e.username))
  152. typing_display.innerText = people.length ? people.join(" and ") + " " + (people.length > 1 ? "are" : "is") + " typing..." : "Currently, no one is typing";
  153. };
  154. });
  155.  
  156. setTimeout(function(){
  157. w.broadcastCommand('online', true);
  158. }, 1000);
  159.  
  160. window.addEventListener('beforeunload', function(){
  161. w.broadcastCommand('offline', true)
  162. });
  163.  
  164. window.onblur = function(){w.broadcastCommand('afk', true)};
  165.  
  166. window.onfocus = function(){w.broadcastCommand('back', true)};
  167.  
  168. elm.chatbar.oninput = function(e){
  169. if(timeout) clearTimeout(timeout);
  170. if(!elm.chatbar.value.length) w.broadcastCommand("untyping", true);
  171. if(!!elm.chatbar.value.length && !people.includes(state.userModel.username)) w.broadcastCommand('typing', true);
  172. timeout = setTimeout(function(){
  173. w.broadcastCommand("untyping", true);
  174. }, 5000);
  175. };
  176.  
  177. /* DARK MODE CHAT BY YAGTON */
  178.  
  179. (() => {
  180. const changes = [
  181. ["#chat_window", "backgroundColor", "#3c3836"],
  182. ["#chat_close", "backgroundColor", "#cc241d"],
  183. ["#chat_upper", "color", "#fbf1c7"],
  184. ["#chatbar", "backgroundColor", "#282828"],
  185. ["#chatbar", "color", "#fbf1c7"],
  186. ["#chatbar", "border", "1px solid #1d2021"],
  187. ["#chatsend", "backgroundColor", "#282828"],
  188. ["#chatsend", "color", "#fbf1c7"],
  189. ["#chatsend", "border", "1px solid #1d2021"],
  190. [".unread", "color", "#fb4934"],
  191. [".chatfield", "backgroundColor", "#282828"],
  192. [".chatfield", "color", "#fbf1c7"],
  193. ];
  194.  
  195. for (let i of changes)
  196. for (let e of document.querySelectorAll(i[0]))
  197. e.style[i[1]] = i[2];
  198.  
  199. // because .chat_tab_selected has to be done differently :ohno:
  200. let head = document.getElementsByTagName('head')[0];
  201. let st = document.createElement('style');
  202. st.innerHTML = ".chat_tab_selected { background-color: #504945; }";
  203. head.appendChild(st);
  204. })();
  205.  
  206. /* DISCORD SOUNDS BY GUEST-1052 (SPAGHETTI CODE WARNING) */
  207. sa=new Audio ("https://www.myinstants.com/media/sounds/discordmute.mp3");la=new Audio("https://www.myinstants.com/media/sounds/discord-message.mp3");w.on('chatmod',e=>{if(/@silent/i.test(e.message)){} else{if(e.realUsername=="[ Server ]"&&/deleted|blocked|muted/i.test(e.message)){sa.currentTime=0;sa.play()} else{la.currentTime=0;la.play()}}});
  208.  
  209. /* KEYBOARD SOUNDS (USELESS) */
  210.  
  211. onkeydown=_=>{ze=new Audio("https://www.myinstants.com/media/sounds/pressing-a-pc-key.mp3");ze.playbackRate=3.2;ze.volume=0.25;ze.play(
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement