GREEN   34   0
   521 5.3 KB    154

EO chat script

By Guest
Created: 2024-02-01 07:05:16
Expiry: Never

  1. // ==UserScript==
  2. // @name Everfree Outpost Chat Extensions
  3. // @description Adds extra chat functionalities to Everfree Outpost.
  4. // @author "Thorn Rose", "Green", "Script Anon", "haypone"
  5. // @version 0.5.2
  6. // @namespace everfree-outpost
  7. // @match *://play.everfree-outpost.com/*
  8. // @grant GM_addStyle
  9. // @connect play.everfree-outpost.com
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. var my_name="haypone"; //Your name on EO so it won't notify your own messages, it can be changed.
  14. //var audio = new Audio("https://notificationsounds.com/storage/sounds/file-sounds-1127-beyond-doubt.mp3"); //The sound it will play, it can be changed
  15. //-----------------------------
  16.  
  17. var GREEN="#306030";
  18. var PURPLE="#8844CC";
  19. var BLUE="#303090";
  20. var LIGHTBLUE="#306090";
  21. var RED="#903030";
  22. var DARKCYAN="#2D5B60";
  23. var userMap = { //Change these to actual names and other colors
  24. "True Lime": GREEN,
  25. "Derpy": "#71797E",
  26. "C": "#0047AB",
  27. "Stubenhocker": "#f36044",
  28. "Z": "#903060",
  29. "E": PURPLE,
  30. "F": PURPLE,
  31. "G": "#686772",
  32. "H": "#96663B",
  33. "I": "#606090",
  34. "J": "#609030",
  35. "K": DARKCYAN,
  36. "L": RED,
  37. "M": "#FFE085",
  38. "N": "#FDBFFF",
  39. "O": RED,
  40. "P": BLUE,
  41. "Q": LIGHTBLUE
  42. };
  43.  
  44. let lastLine = '';
  45.  
  46. var unreadMessages = 0;
  47. var original_title = document.title; //Do not change
  48. var blink_interval;
  49. var is_blinking=false; //Do not change
  50. addEventListener("mousemove", stop_blinking);
  51.  
  52. const config = { attributes: false, childList: true, subtree: false };
  53. // Callback function to execute when mutations are observed
  54. const callback = (mutationList, observer) => {
  55. for (const mutation of mutationList) {
  56. if (mutation.type === "childList") {
  57. newChatLine();
  58. }
  59. }};
  60. // Create an observer instance linked to the callback function
  61. const observer = new MutationObserver(callback);
  62.  
  63. let chat;
  64. //UI is created after the site is loaded, so we need to wait for it to exist
  65. function init() {
  66. let chats = document.getElementsByClassName("chat");
  67. if(chats.length >= 2) {
  68. chat = chats[1];
  69. unreadMessages = 0;
  70. const chatMessages = document.getElementsByClassName("chat-line");
  71. for(let i = 1; i < chatMessages.length; i++) {
  72. unreadMessages++;
  73. modifyChatLine(chatMessages[i]);
  74. }
  75. observer.observe(chat, config);
  76. clearInterval(initTimer);
  77. }
  78. }
  79. const initTimer = setInterval(init, 150);
  80.  
  81. window.onfocus = function() {
  82. unreadMessages = 0;
  83. stop_blinking();
  84. }
  85.  
  86. function stop_blinking(_) {
  87. document.title = original_title;
  88. clearInterval(blink_interval)
  89. is_blinking = false;
  90. }
  91.  
  92. function blink_title(message) {
  93. if (document.title===message) {
  94. document.title=original_title;
  95. } else {
  96. document.title=message;
  97. }
  98. }
  99.  
  100. function formatDate(date) {
  101. var hours = date.getHours();
  102. var minutes = date.getMinutes();
  103. minutes = minutes < 10 ? '0'+minutes : minutes;
  104. var strTime = hours + ':' + minutes;
  105. return strTime;
  106. }
  107.  
  108. function urlify(text) {
  109. var urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
  110. return text.replace(urlRegex, function(url,b,c) {
  111. var url2 = (c == 'www.') ? 'http://' +url : url;
  112. return '<a href="' +url2+ '" target="_blank">' + url + '</a>';
  113. })
  114. }
  115.  
  116. function modifyChatLine(lastChatMessage) {
  117. const wasScrolled = Math.abs(chat.scrollHeight - chat.scrollTop - chat.clientHeight) <= 5; //how many pixels
  118. const user = lastChatMessage.children[0];
  119. const text = lastChatMessage.children[1];
  120. //lastLine = text;
  121.  
  122. const userInnerText = user.innerText;
  123. if(userInnerText.length == 0) return;
  124. const username = userInnerText.substr(1, userInnerText.length - 2);
  125.  
  126. if(userInnerText[0] == '[') return;
  127. user.innerText = `[${formatDate(new Date)}] ${userInnerText}`;
  128.  
  129. text.innerHTML = urlify(text.innerHTML);
  130. if (my_name !== username && username !== "*") {
  131. unreadMessages += 1;
  132. //audio.play();
  133. if (!is_blinking && !document.hasFocus()) { //Title blinks only if it is not currently blinking or if the user is not on EO tab
  134. blink_interval = setInterval(function(){blink_title(`${unreadMessages} New message!`);},1000)
  135. is_blinking=true
  136. }
  137. }
  138.  
  139. /*if (username in userMap) {
  140. user.css("color", userMap[username]);
  141. user.css("font-weight", "bold");
  142. user.css("text-shadow", "0px 0px 6px #fff");
  143. }*/
  144.  
  145. if(wasScrolled) chat.scrollTop = chat.scrollHeight - chat.clientHeight;
  146. }
  147.  
  148. function newChatLine () {
  149. stop_blinking();
  150. const chatMessages = document.getElementsByClassName("chat-line");
  151. const lastChatMessage = chatMessages[chatMessages.length-1];
  152. modifyChatLine(lastChatMessage);
  153. }

Yandere Thread - Yandere Applejack (completed)

by Guest

Bonding with Nature

by Guest

The Long and Short of It (RGRE)

by Guest

incest relationships piece of the whole pie (lewd) by Frostybox[...]

by Guest

incest thread piece of the (non-canon) pie, limestone's pie by[...]

by Guest