Meklin Shutdownchat Script

Modified Shutdownchat, unmatched scripts, brace to be thunderstruck

当前为 2024-01-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Meklin Shutdownchat Script
  3. // @version 1.8
  4. // @description Modified Shutdownchat, unmatched scripts, brace to be thunderstruck
  5. // @author MeKLiN
  6. // @namespace https://greasyfork.org/en/scripts/483405-meklin-shutdownchat-script
  7. // @match https://www.shutdown.chat/rooms*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=shutdown.chat
  9. // @license MIT
  10. // @grant none
  11. // @exclude https://www.shutdown.chat/profiles*
  12. // @exclude https://www.shutdown.chat/manage*
  13. // @run-at document-start
  14. // @require https://cdnjs.cloudflare.com/ajax/libs/jshint/2.9.7/jshint.js
  15. // @require https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.5/es6-shim.min.js
  16. // ==/UserScript==
  17. // Declare global variables
  18. var blocked_uuids = JSON.parse(localStorage.getItem('blocked_uuids')) || [];
  19. var observer;
  20. var chatbox = document.querySelector('.chatbox');
  21. var customChatmsg;
  22. var customInputWindow;
  23. var customInputWindow2;
  24. var customInputWindow3;
  25. var customInputWindow4; // Declare only once
  26. var clonedGridboxTools;
  27. var ignoreListDiv = document.getElementById('your-ignore-list-div-id');
  28. // Function to initialize the script
  29. function initializeScript() {
  30. console.log("MSS 1.1 STARTED");
  31. debugger;
  32. // Call the function to create the toggle button
  33. createToggleButton();
  34. // Call the initial function to start handling new chat messages
  35. handleNewChatMessages();
  36. // Call the function to observe mutations in the chatbox
  37. observeChatboxMutations();
  38. // Call the function to create the ignore list button
  39. createButtons();
  40. // Call the function to create the save and load buttons
  41. createSaveLoadButtons();
  42. // Call the function to create the ignore button in the user menu
  43. createIgnoreButton();
  44. // Call the function to create the clear cache button
  45. createClearCacheButton();
  46. // Call the function to create the collapse button
  47. createCollapseButton();
  48. // Clone gridbox
  49. cloneGridbox();
  50. // Create the custom input window
  51. createCustomInputWindow();
  52. // Create additional custom input window
  53. createAdditionalCustomInputWindow();
  54. // Now, you should be able to access customInputWindow
  55. console.log(customInputWindow);
  56. // Call the function to ignore a user
  57. ignoreUser('example_uuid');
  58. // Call the cloneGridbox function when needed
  59. cloneGridbox();
  60. // Call the function to create Ignore List Button
  61. createIgnoreListButton();
  62. // Call the function to initialize the observer
  63. initializeObserver();
  64. // Create customInputWindow4
  65. customInputWindow4 = document.createElement("div");
  66. customInputWindow4.className = "your-custom-class";
  67. // Clone gridbox
  68. function cloneGridbox() {
  69. var gridboxTools = document.querySelector('.gridbox_tools');
  70. var clonedGridboxTools = gridboxTools.cloneNode(true);
  71. // Append the new button to the custom input window
  72. customInputWindow4.appendChild(clonedGridboxTools);
  73.  
  74. // ... other logic related to cloneGridbox ...
  75.  
  76. // Append the custom input window to the body
  77. document.body.appendChild(customInputWindow4);
  78. }
  79. }
  80. // Call the function to initialize the script
  81. initializeScript();
  82. // Function to initialize the observer
  83. function initializeObserver() {
  84. // Check if the .chatbox element is found
  85. if (chatbox) {
  86. // Initialize the observer if not already initialized
  87. if (!observer) {
  88. observer = new MutationObserver(function (mutations) {
  89. // Handle mutations
  90. console.log("Mutations:", mutations);
  91. // You can add your logic to handle mutations here
  92. });
  93. // Start observing the .chatbox element
  94. observer.observe(chatbox, { childList: true });
  95. }
  96. }
  97. }
  98. // Call the function to initialize the observer
  99. initializeObserver();
  100. console.log("MAIN OBSERVER INITIALIZED")
  101. function createToggleButton() {
  102. // Add a button to the body
  103. var toggleBackgroundButton = document.createElement("button");
  104. toggleBackgroundButton.textContent = "Toggle Background";
  105. document.body.appendChild(toggleBackgroundButton);
  106.  
  107. // Add an event listener to the button
  108. toggleBackgroundButton.addEventListener("click", function() {
  109. // Get the container element
  110. var container = document.querySelector("#container");
  111.  
  112. // Toggle the background style
  113. if (container.style.background === "") {
  114. // Set the background color when it's not set
  115. container.style.background = "#e0e0e0";
  116. } else {
  117. // Remove the background color when it's set
  118. container.style.background = "";
  119. }
  120. });
  121. }
  122. // Function to observe mutations in the chatbox
  123. function observeChatboxMutations() {
  124. var chatbox = document.querySelector('.chatbox')
  125. if (chatbox instanceof Node && !observer) {
  126. // Create a mutation observer to monitor changes in the chatbox
  127. observer = new MutationObserver(function (mutations) {
  128. mutations.forEach(function (mutation) {
  129. mutation.addedNodes.forEach(function (node) {
  130. if (node.nodeName === "P" && node.dataset.t === "c") {
  131. // Your logic for handling new chat messages goes here
  132. console.log("Processing Chatbox Now");
  133. }
  134. });
  135. });
  136. });
  137. // Start observing the chatbox
  138. observer.observe(chatbox, { childList: true });
  139. } else {
  140. console.error("Chatbox element not found or is not a valid Node. Cannot add event listener.");
  141. }
  142. }
  143. // Function to create a MutationObserver for the chatbox
  144. function observeChatbox() {
  145. // Get the chatbox element
  146. var chatbox = document.querySelector('.chatbox');
  147. // Check if the chatbox element is found
  148. if (chatbox) {
  149. // Initialize the observer if not already initialized
  150. if (!observer) {
  151. observer = new MutationObserver(function (mutations) {
  152. // Handle mutations
  153. console.log("Mutations:", mutations);
  154. // You can add your logic to handle mutations here
  155. });
  156. // Start observing the chatbox
  157. observer.observe(chatbox, { childList: true });
  158. }
  159. } else {
  160. console.error("Chatbox element not found. Cannot add event listener.");
  161. }
  162. }
  163. // Function to handle system messages
  164. function handleSystemMessage(systemNode) {
  165. // Move system messages to the bottom right in their own DIV
  166. var systemDiv = document.createElement("div");
  167. systemDiv.className = "system-message";
  168. systemDiv.style.position = "fixed";
  169. systemDiv.style.bottom = "10px";
  170. systemDiv.style.right = "10px";
  171. systemDiv.style.backgroundColor = "#f0f0f0";
  172. systemDiv.style.padding = "10px";
  173. systemDiv.appendChild(systemNode.cloneNode(true));
  174. document.body.appendChild(systemDiv);
  175.  
  176. // Call the function to observe the chatbox
  177. observeChatbox();
  178. }
  179. // Now you can call observeChatbox() from any other function that needs to observe the chatbox
  180. function createCollapseButton() {
  181. console.log("createCollapseButton function is called");
  182. var collapseButton = document.createElement("button");
  183. // Set the inner HTML with an SVG and additional text
  184. collapseButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
  185. <path fill="none" d="M0 0h24v24H0z"/>
  186. <path d="M8 4v5l-2.5-1.5L3 9V4l5-2zm8 0l5 2v5l-2.5-1.5L16 9V4zM3 11l3.5-1.5L8 11V9L3 7zm13 0l3.5-1.5L21 11V9l-5-2z"/>
  187. </svg>min`;
  188. // Adjust the font size of the text
  189. collapseButton.style.fontSize = "12px"; // Adjust the font size as needed
  190. collapseButton.style.position = "fixed";
  191. collapseButton.style.top = "90px";
  192. collapseButton.style.left = "10px";
  193. // Function to append the button to the body
  194. function appendButtonToBody() {
  195. document.body.appendChild(collapseButton);
  196. }
  197. // Check if the body is available
  198. if (document.body) {
  199. // Append the collapseButton to the body
  200. appendButtonToBody();
  201. } else {
  202. // If the body is not available, wait for DOMContentLoaded event
  203. document.addEventListener("DOMContentLoaded", appendButtonToBody);
  204. }
  205. collapseButton.addEventListener("click", function () {
  206. // Toggle visibility of the chatbox
  207. var chatbox = document.querySelector('.chatbox');
  208. chatbox.style.display = (chatbox.style.display === 'none' || chatbox.style.display === '') ? 'block' : 'none';
  209. });
  210. // Get the chatbox element after creating the button
  211. var chatbox = document.querySelector('.chatbox');
  212. // Check if the chatbox element is found
  213. if (chatbox) {
  214. // Initialize the observer if not already initialized
  215. if (!observer) {
  216. observer = new MutationObserver(function (mutations) {
  217. // Handle mutations
  218. console.log("Mutations:", mutations);
  219. // You can add your logic to handle mutations here
  220. });
  221. // Start observing the chatbox
  222. observer.observe(chatbox, { childList: true });
  223. }
  224. // Log the chatbox element to the console
  225. console.log("Chatbox element:", chatbox);
  226. }
  227. }
  228. function handleNewChatMessages() {
  229. // Get the chatbox element
  230. console.log("Attempting to get chatbox element");
  231. var chatbox = document.querySelector('.chatbox');
  232. // Check if the chatbox element is found
  233. if (!chatbox) {
  234. console.error("Chatbox element not found. Cannot add event listener.");
  235. return;
  236. }
  237. console.log("Chatbox element found. Proceeding with event listener setup.");
  238. // Use the existing observer if not already initialized
  239. if (!observer) {
  240. observer = new MutationObserver(function (mutations) {
  241. // Handle mutations
  242. mutations.forEach(function (mutation) {
  243. mutation.addedNodes.forEach(function (node) {
  244. handleChatMessage(node);
  245. console.log("Mutations:", mutations);
  246. // You can add your logic to handle mutations here
  247. });
  248. });
  249. });
  250. // Start observing the chatbox if observer is defined
  251. if (typeof observer !== 'undefined' && observer !== null) {
  252. observer.observe(chatbox, { childList: true });
  253. } else {
  254. console.error("Observer not defined. Cannot add event listener.");
  255. }
  256. }
  257. // Continue with handling new chat messages
  258. var chatboxElems = chatbox.getElementsByTagName('p');
  259. for (var i = 0; i < chatboxElems.length; i++) {
  260. var chatElem = chatboxElems[i];
  261. if (!chatElem.handled) {
  262. chatElem.handled = true;
  263. // Additional logic for handling specific types of messages
  264. // Remove text containing 'roll'
  265. if (chatElem.textContent.toLowerCase().includes('roll')) {
  266. chatElem.style.display = 'none'; // hide the message
  267. }
  268. // Alter messages of the type .fs_3
  269. if (chatElem.classList.contains('fs_3')) {
  270. chatElem.style.fontSize = '12px';
  271. chatElem.style.color = 'white';
  272. }
  273. // Check if the message is a system message
  274. var systemMessage = chatElem.classList.contains('system');
  275. if (systemMessage) {
  276. // Add a button to hide the system message
  277. addHideButtonToSystemMessage(chatElem);
  278. } else {
  279. // Check if the user is ignored
  280. var fcuserSpan = chatElem.querySelector('.nm.fcuser, .nm.fcmod, .user');
  281. var uuid = fcuserSpan ? fcuserSpan.dataset.uuid : null;
  282. console.log("fcuserSpan:", fcuserSpan); // Add this line to log fcuserSpan
  283. console.log("uuid:", uuid); // Add this line to log uuid
  284. if (uuid) {
  285. // Check if the user is ignored
  286. var isIgnored = blocked_uuids.includes(uuid);
  287. // Modify the appearance based on whether the user is ignored or not
  288. if (isIgnored) {
  289. chatElem.style.display = 'none'; // hide the message
  290. } else {
  291. // Add an "ignore" button to the user menu
  292. addIgnoreButtonToUserMenu(uuid);
  293. }
  294. }
  295. }
  296. }
  297. }
  298. }
  299. // Function to get the user UUID from the user list within FreeChat context
  300. function getUserUUIDFromUserList() {
  301. var userContainer = document.querySelector("#chat > div.fc > div.gridbox_list > div.userlist p.user.fcuser[data-uuid]");
  302. if (userContainer) {
  303. return userContainer.dataset.uuid;
  304. } else {
  305. // If user container is not found, set up a MutationObserver to wait for changes
  306. var observer = new MutationObserver(function (mutations) {
  307. userContainer = document.querySelector("#chat > div.fc > div.gridbox_list > div.userlist p.user.fcuser[data-uuid]");
  308. if (userContainer) {
  309. console.log("User container found after mutation.");
  310. console.log("User UUID: ", userContainer.dataset.uuid);
  311. // Stop observing once the user container is found
  312. observer.disconnect();
  313. }
  314. });
  315. // Start observing changes in the user list
  316. observer.observe(document.querySelector("#chat > div.fc > div.gridbox_list > div.userlist"), { childList: true, subtree: true });
  317. console.error("User container not found in the user list within FreeChat context. Waiting for mutations...");
  318. return null;
  319. }
  320. }
  321. // Wrap function calls inside DomContentLoaded event listener ensuring page load
  322. document.addEventListener('DOMContentLoaded', function () {
  323. // Function to be called after DOMContentLoaded
  324. function afterDOMContentLoaded() {
  325. console.log("dom loaded!")
  326. }
  327. // Use MutationObserver to detect when userlist and chatbox are added to the DOM
  328. var observer = new MutationObserver(function (mutations) {
  329. mutations.forEach(function (mutation) {
  330. mutation.addedNodes.forEach(function (node) {
  331. if (node.classList && (node.classList.contains('userlist') || node.classList.contains('chatbox'))) {
  332. // Userlist or chatbox added to the DOM, stop observing and call functions
  333. observer.disconnect();
  334. afterDOMContentLoaded();
  335. }
  336. });
  337. });
  338. });
  339. // Start observing the body for added nodes
  340. observer.observe(document.body, { childList: true, subtree: true });
  341. // Check if userlist and chatbox are already present
  342. var userlist = document.querySelector('.userlist');
  343. var chatbox = document.querySelector('.chatbox');
  344. if (userlist && chatbox) {
  345. // Function to create a button to view the ignore list
  346. function createIgnoreListButton() {
  347. console.log("createIgnoreListButton function is called");
  348. var ignoreListButton = document.createElement("button");
  349. ignoreListButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M20 18V8a6 6 0 0 0-12 0v10h12zM12 2C6.48 2 2 6.48 2 12v10h2V12a5.978 5.978 0 0 1 5.985-6H12V2zm8.293 2.293a1 1 0 0 1 1.414 0l1.414 1.414a1 1 0 0 1 0 1.414L19.414 10l3.707 3.707a1 1 0 0 1 0 1.414l-1.414 1.414a1 1 0 0 1-1.414 0L18 13.414l-3.707 3.707a1 1 0 0 1-1.414 0l-1.414-1.414a1 1 0 0 1 0-1.414L14.586 12 10.88 8.293a1 1 0 0 1 0-1.414L12.294 5.465a1 1 0 0 1 1.414 0z"/></svg>lst`;
  350. ignoreListButton.style.position = "fixed";
  351. ignoreListButton.style.top = "100px";
  352. ignoreListButton.style.left = "10px";
  353. ignoreListButton.addEventListener("click", function () {
  354. // Display the ignore list (you can customize this part)
  355. alert("Ignore List:\n" + blocked_uuids.join(", "));
  356. });
  357. document.body.appendChild(ignoreListButton);
  358. }
  359. createIgnoreListButton(); // Call the function to create the button
  360. } else {
  361. console.error("The userlist element is not found.");
  362. }
  363. // Proceed with querying for .fcuser elements
  364. var users = userlist.querySelectorAll(".fcuser");
  365. users.forEach(function (user) {
  366. // Your code for each user
  367. var uuid = user.dataset.uuid;
  368. // Create the block button
  369. var muteButton = document.createElement("button");
  370. muteButton.innerText = "Mute";
  371. muteButton.addEventListener("click", function() {
  372. muteUser(uuid);
  373. });
  374. // Create the ignore button with a unique class
  375. var ignoreButton = document.createElement("button");
  376. ignoreButton.innerText = "Ignore";
  377. ignoreButton.setAttribute("data-btntype", "ignore"); // Set a new attribute for identification
  378. ignoreButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16"><path fill="none" d="M0 0h24v24H0z"/><path d="M20 18V8a6 6 0 0 0-12 0v10h12zM12 2C6.48 2 2 6.48 2 12v10h2V12a5.978 5.978 0 0 1 5.985-6H12V2zm8.293 2.293a1 1 0 0 1 1.414 0l1.414 1.414a1 1 0 0 1 0 1.414L19.414 10l3.707 3.707a1 1 0 0 1 0 1.414l-1.414 1.414a1 1 0 0 1-1.414 0L18 13.414l-3.707 3.707a1 1 0 0 1-1.414 0l-1.414-1.414a1 1 0 0 1 0-1.414L14.586 12 10.88 8.293a1 1 0 0 1 0-1.414L12.294 5.465a1 1 0 0 1 1.414 0z"/></svg>`;
  379. ignoreButton.style.marginLeft = "5px";
  380. ignoreButton.style.cursor = "pointer";
  381. // Add a unique class to the ignore button
  382. ignoreButton.classList.add("ignoreButtonClass");
  383. ignoreButton.addEventListener("click", function () {
  384. // Dynamically fetch the user UUID when the "Ignore" button is clicked
  385. var clickedUserUUID = user.dataset.uuid;
  386. blockUser(clickedUserUUID);
  387. });
  388. // Create a container div for the buttons
  389. var buttonContainer = document.createElement("div");
  390. buttonContainer.style.display = "flex";
  391. buttonContainer.style.alignItems = "center";
  392. // Append the buttons to the container
  393. buttonContainer.appendChild(blockButton);
  394. buttonContainer.appendChild(ignoreButton);
  395. // Append the container to the user element
  396. user.parentElement.appendChild(buttonContainer);
  397. });
  398. });
  399. // Function to show a notification
  400. function showNotification(message) {
  401. var notification = document.createElement("div");
  402. notification.style.position = "fixed";
  403. notification.style.top = "10px";
  404. notification.style.left = "10px";
  405. notification.style.backgroundColor = "#000000";
  406. notification.style.padding = "10px";
  407. notification.style.border = "1px solid #ccc";
  408. notification.style.borderRadius = "5px";
  409. notification.style.fontSize = "12px";
  410. notification.style.color = "#C0FF00";
  411. notification.style.opacity = 1;
  412. notification.style.transition = "opacity 2s ease-in-out";
  413. notification.innerHTML = message;
  414. document.body.appendChild(notification);
  415. // Set a timeout to fade out the notification
  416. setTimeout(function () {
  417. notification.style.opacity = 0;
  418. }, 5000); // Adjust the timeout value as needed
  419. // Remove the notification from the DOM after fading out
  420. setTimeout(function () {
  421. document.body.removeChild(notification);
  422. }, 6000); // Adjust the timeout value to match the fade-out duration
  423. }
  424. // Function to create a button to clear the JSON local saved cache
  425. function createClearCacheButton() {
  426. console.log("createClearCacheButton function is called");
  427. var clearCacheButton = document.createElement("button");
  428. clearCacheButton.innerText = "clr";
  429. clearCacheButton.style.position = "fixed";
  430. clearCacheButton.style.top = "50px";
  431. clearCacheButton.style.left = "10px";
  432. clearCacheButton.addEventListener("click", function () {
  433. // Clear the JSON local saved cache
  434. localStorage.removeItem('blocked_uuids');
  435. showNotification("Cache cleared. Please refresh the page.");
  436. });
  437. // Check if the body is available
  438. if (document.body) {
  439. // Append the clearCacheButton to the body
  440. document.body.appendChild(clearCacheButton);
  441. } else {
  442. // If the body is not available, wait for DOMContentLoaded event
  443. document.addEventListener("DOMContentLoaded", function () {
  444. // Append the clearCacheButton to the body
  445. document.body.appendChild(clearCacheButton);
  446. });
  447. }
  448. }
  449. // Function to create a button to collapse the view
  450. function getNickname(fcuserSpan) {
  451. if (!fcuserSpan) return;
  452. // Check if fcuserSpan is a direct child of p
  453. var isDirectChild = fcuserSpan.parentNode.nodeName === "P";
  454. var nickname;
  455. if (isDirectChild) {
  456. nickname = fcuserSpan.innerText.replace(/[:\-]/g, '').trim();
  457. } else {
  458. // If not a direct child, assume it's under an anchor tag (a) in the user list
  459. nickname = fcuserSpan.parentNode.querySelector('.fcuser').innerText.replace(/[:\-]/g, '').trim();
  460. }
  461. return nickname;
  462. }
  463. // Function to handle the new chat messages
  464.  
  465. // Function to add a button to hide system messages
  466. function addHideButtonToSystemMessage(chatElem) {
  467. var hideButton = document.createElement('button');
  468. hideButton.textContent = 'Hide';
  469. hideButton.style.marginLeft = '5px';
  470. hideButton.addEventListener('click', function () {
  471. chatElem.style.display = 'none'; // hide the system message
  472. });
  473. // Append the button to the system message
  474. chatElem.appendChild(hideButton);
  475. }
  476. // Function to add an "ignore" button to the user menu
  477. function addIgnoreButtonToUserMenu(chatElem) {
  478. // Check if the user menu exists
  479. var userMenu = document.querySelector('.usermenu');
  480. if (userMenu && chatElem && chatElem.querySelector) {
  481. // Check if the user is already ignored
  482. var uuid = chatElem.querySelector('.nm.fcuser, .nm.fcmod')?.dataset.uuid;
  483. var isIgnored = blocked_uuids.includes(uuid);
  484. // Create a button for either ignoring or unignoring the user
  485. var ignoreButton = document.createElement('button');
  486. ignoreButton.textContent = isIgnored ? 'Unignore' : 'Ignore';
  487. // Add an event listener to handle ignoring/unignoring the user
  488. ignoreButton.addEventListener('click', function () {
  489. if (isIgnored) {
  490. // Unignore the user
  491. unignoreUser(uuid);
  492. } else {
  493. // Ignore the user
  494. ignoreUser(uuid);
  495. }
  496. });
  497. // Append the button to the user menu
  498. userMenu.appendChild(ignoreButton);
  499. } else {
  500. console.error("Invalid userMenu, chatElem, or querySelector is not supported. Conditions: userMenu=" + userMenu + ", chatElem=" + chatElem + ", chatElem.querySelector=" + (chatElem ? chatElem.querySelector : null));
  501. }
  502. }
  503. // Function to ignore a user
  504. function ignoreUser(uuid) {
  505. // Add your logic here to handle ignoring a user
  506. // For example, you can add the user's UUID to the blocked_uuids array
  507. blocked_uuids.push(uuid);
  508. // Save the updated blocked_uuids to localStorage
  509. localStorage.setItem('blocked_uuids', JSON.stringify(blocked_uuids));
  510. // You can also add additional logic as needed
  511. console.log("Ignoring user with UUID:", uuid);
  512. }
  513. // Function to unignore a user
  514. function unignoreUser(uuid) {
  515. blocked_uuids = blocked_uuids.filter(function (blockedUuid) {
  516. return blockedUuid !== uuid;
  517. });
  518. // Add additional logic as needed
  519. console.log("Unignoring user with UUID:", uuid);
  520. }
  521. // Function to get the user UUID from a chat message
  522. function getUserUUIDFromChatMessage(messageNode) {
  523. var uuidElement = messageNode.querySelector('.nm.fcuser, .nm.fcmod');
  524. if (uuidElement) {
  525. return uuidElement.dataset.uuid;
  526. } else {
  527. console.error("UUID element not found in the chat message:", messageNode);
  528. return null;
  529. }
  530. }
  531. // Function to handle different types of chat messages
  532. function handleChatMessage(node) {
  533. // Check if the node is a chat message
  534. if (node.nodeName === "P" && node.dataset.t === "c") {
  535. // Get the uuid of the user who sent the message
  536. var uuid = getUserUUIDFromChatMessage(node);
  537. if (uuid) {
  538. console.log("Found message with UUID:", uuid);
  539. // Check if the uuid is in the blocked list
  540. if (blocked_uuids.includes(uuid)) {
  541. console.log("Blocking message with UUID:", uuid);
  542. // Hide the message
  543. node.style.display = "none";
  544. } else {
  545. // Alter messages of the type .fs_3
  546. if (node.classList.contains('fs_3')) {
  547. node.style.fontSize = '12px';
  548. node.style.color = 'white';
  549. }
  550. // Add an "ignore" button to the user menu
  551. addIgnoreButtonToUserMenu(node);
  552. }
  553. }
  554. } else if (node.nodeName === "P" && node.querySelector(".sysmsg.fcsys")) {
  555. // Handle system messages
  556. handleSystemMessage(node);
  557. }
  558. }
  559. // Function to block/unblock a user
  560. function blockUser(uuid) {
  561. console.log("blockUser function is called");
  562. var index = blocked_uuids.indexOf(uuid);
  563. if (index !== -1) {
  564. // User is already blocked, so unblock
  565. blocked_uuids.splice(index, 1);
  566. showNotification("User unblocked!");
  567. } else {
  568. // User is not blocked, so block
  569. blocked_uuids.push(uuid);
  570. showNotification("User blocked!");
  571. }
  572. // Save the updated blocked_uuids to localStorage
  573. localStorage.setItem('blocked_uuids', JSON.stringify(blocked_uuids));
  574. }
  575. // usermenu block button event listener:
  576. document.querySelector('.usermenu button[data-btntype="block"]').addEventListener('click', function() {
  577. console.log("User menu block button clicked");
  578. // Get the parent element of the button, assuming it contains user-related data
  579. var userContainer = this.closest('.user-container');
  580. // Assuming the user UUID is stored in a data attribute called data-uuid
  581. var userUUID = userContainer ? userContainer.dataset.uuid : null;
  582. // Check if userUUID is not null before blocking
  583. if (userUUID) {
  584. // Now you have the user UUID, and you can proceed to block the user
  585. blockUser(userUUID);
  586. } else {
  587. console.error("User UUID not found. Unable to block user.");
  588. }
  589. });
  590. // Function to create an ignore button in the user menu
  591. function createIgnoreButton() {
  592. console.log("createIgnoreButton function is called");
  593. // Check if the ignore button is already created
  594. var ignoreButton = document.querySelector('.usermenu button[data-btntype="ignore"]');
  595. if (!ignoreButton) {
  596. ignoreButton = document.createElement("button");
  597. ignoreButton.innerText = "Ignore";
  598. ignoreButton.setAttribute("data-btntype", "ignore"); // Set a new attribute for identification
  599. ignoreButton.style.display = "block";
  600. ignoreButton.style.marginTop = "5px"; // Adjust the styling as needed
  601. // Insert the ignore button into the user menu
  602. var userMenu = document.querySelector('.usermenu');
  603. if (userMenu) {
  604. userMenu.insertBefore(ignoreButton, userMenu.firstChild);
  605. // Add click event directly to the button
  606. ignoreButton.addEventListener("click", function () {
  607. // Log to console to check if the button click is being registered
  608. console.log("Ignore button clicked");
  609. // Invoke the function to get the user UUID from the user list
  610. var userUUID = getUserUUIDFromUserList();
  611. // Check if the user UUID is found
  612. if (userUUID) {
  613. blockUser(userUUID);
  614. } else {
  615. console.error("User UUID not found. Ignoring user without blocking.");
  616. }
  617. });
  618. } else {
  619. console.error("User menu not found.");
  620. }
  621. }
  622. }
  623. // Function to get the user UUID from the chat log
  624. function getUserUUIDFromChatLog() {
  625. var chatLog = document.querySelector('.chatbox');
  626. if (chatLog) {
  627. // Find the first chat message in the log
  628. var firstChatMessage = chatLog.querySelector('p[data-t="c"]');
  629. if (firstChatMessage) {
  630. // Get the UUID from the first chat message
  631. var uuidElement = firstChatMessage.querySelector('.nm.fcuser, .nm.fcmod');
  632. if (uuidElement) {
  633. return uuidElement.dataset.uuid;
  634. } else {
  635. // Handle the case where UUID element is not found
  636. console.error("UUID element not found in the first chat message:", firstChatMessage);
  637. return null;
  638. }
  639. } else {
  640. // Handle the case where no chat messages are found
  641. console.error("No chat messages found in the chat log.");
  642. return null;
  643. }
  644. } else {
  645. // Handle the case where the chatbox element is not found
  646. console.error("Chatbox element not found.");
  647. return null;
  648. }
  649. }
  650. // Create the ignore list div once and append the content dynamically
  651. var ignoreListDiv = document.createElement("div");
  652. ignoreListDiv.style.position = "fixed";
  653. ignoreListDiv.style.top = "135px"; // Move to the top
  654. ignoreListDiv.style.left = "10px";
  655. ignoreListDiv.style.backgroundColor = "white"; // Adjust styling as needed
  656. ignoreListDiv.style.padding = "10px";
  657. ignoreListDiv.style.border = "1px solid black"; // Add border for visibility
  658. ignoreListDiv.style.fontSize = "12px"; // Set font size to 12px
  659. // Create a heading for the ignore list
  660. var ignoreListHeading = document.createElement("h3");
  661. ignoreListHeading.innerText = "Ignore List";
  662. ignoreListDiv.appendChild(ignoreListHeading);
  663. // Create a list to display ignored users
  664. var ignoreList = document.createElement("ul");
  665. ignoreList.style.listStyleType = "none"; // Remove default list styling
  666. ignoreListDiv.appendChild(ignoreList);
  667. // Append the ignore list div to the body
  668. document.body.appendChild(ignoreListDiv);
  669. // Function to create a list item with the ignore list entry and remove button
  670. function createIgnoreListItem(uuid, username) {
  671. var listItem = document.createElement("li");
  672. listItem.innerText = `${username} (${uuid})`;
  673. // Create a remove button for each entry
  674. var removeButton = document.createElement("button");
  675. removeButton.innerText = "Remove";
  676. removeButton.addEventListener("click", function () {
  677. // Remove the entry when the button is clicked
  678. removeIgnoreEntry(uuid);
  679. });
  680. // Append the remove button to the list item
  681. listItem.appendChild(removeButton);
  682. // Append the list item to the ignore list
  683. ignoreList.appendChild(listItem);
  684. }
  685. // Function to refresh the ignore list display
  686. function refreshIgnoreList() {
  687. // Clear the existing content
  688. ignoreList.innerHTML = "";
  689.  
  690. // Populate the ignore list with entries and remove buttons
  691. blocked_uuids.forEach(function (uuid) {
  692. createIgnoreListItem(uuid);
  693. });
  694. }
  695. // Populate the ignore list with entries and remove buttons
  696. blocked_uuids.forEach(function (uuid) {
  697. createIgnoreListItem(uuid);
  698. });
  699. // Function to handle removing an entry from the ignore list
  700. function removeIgnoreEntry(uuid) {
  701. var index = blocked_uuids.indexOf(uuid);
  702. if (index !== -1) {
  703. // Remove the entry from the ignore list
  704. blocked_uuids.splice(index, 1);
  705. // Refresh the ignore list display after removal
  706. refreshIgnoreList();
  707. }
  708. }
  709. // Function to save blocked_uuids to a text file
  710. function saveToTextFile() {
  711. var textToSave = blocked_uuids.join('\n');
  712. var blob = new Blob([textToSave], { type: 'text/plain' });
  713. var link = document.createElement('a');
  714. link.download = 'ignore_list.txt';
  715. link.href = window.URL.createObjectURL(blob);
  716. link.onclick = function () {
  717. document.body.removeChild(link);
  718. };
  719. link.style.display = 'none';
  720. document.body.appendChild(link);
  721. link.click();
  722. }
  723. // Function to load blocked_uuids from a text file
  724. function loadFromTextFile() {
  725. var input = document.createElement('input');
  726. input.type = 'file';
  727. input.accept = '.txt';
  728. input.onchange = function (event) {
  729. var file = event.target.files[0];
  730. if (file) {
  731. var reader = new FileReader();
  732. reader.onload = function (e) {
  733. // Parse the content of the file and update blocked_uuids
  734. blocked_uuids = e.target.result.split('\n').map(function (uuid) {
  735. return uuid.trim();
  736. });
  737. // Update the ignore list display
  738. refreshIgnoreList();
  739. };
  740. reader.readAsText(file);
  741. }
  742. };
  743. input.click();
  744. }
  745. // Function to create a button to save and load ignore list
  746. function createSaveLoadButtons() {
  747. var saveButton = document.createElement("button");
  748. saveButton.innerText = "Save to Text File";
  749. saveButton.addEventListener("click", function () {
  750. saveToTextFile();
  751. });
  752. var loadButton = document.createElement("button");
  753. loadButton.innerText = "Load from Text File";
  754. loadButton.addEventListener("click", function () {
  755. loadFromTextFile();
  756. });
  757. var buttonContainer = document.createElement("div");
  758. buttonContainer.style.marginTop = "10px";
  759. buttonContainer.appendChild(saveButton);
  760. buttonContainer.appendChild(loadButton);
  761.  
  762. // Append the button container to the ignore list div
  763. ignoreListDiv.appendChild(buttonContainer);
  764. }
  765. // Function to create buttons, including the collapse button
  766. function createButtons() {
  767. // Create a container for the buttons
  768. var buttonContainer = document.createElement("div");
  769. buttonContainer.style.position = "fixed";
  770. buttonContainer.style.top = "10px";
  771. buttonContainer.style.left = "10px";
  772. document.body.appendChild(buttonContainer);
  773. // Function to create a button
  774. function createButton(text, clickHandler) {
  775. var button = document.createElement("button");
  776. button.innerText = text;
  777. button.addEventListener("click", clickHandler);
  778. buttonContainer.appendChild(button);
  779. }
  780. // Create the collapse button
  781. createButton("Collapse", function () {
  782. var chatbox = document.querySelector('.chatbox');
  783. chatbox.style.display = (chatbox.style.display === 'none' || chatbox.style.display === '') ? 'block' : 'none';
  784. });
  785. // Create the clear cache button
  786. createButton("Clear Cache", function () {
  787. localStorage.removeItem('blocked_uuids');
  788. showNotification("Cache cleared. Please refresh the page.");
  789. });
  790. // Create the button to hide system messages
  791. createButton("Hide System", function () {
  792. // Get all system messages
  793. var systemMessages = document.querySelectorAll('.chatbox .system');
  794. // Toggle visibility of system messages
  795. systemMessages.forEach(function (systemMessage) {
  796. systemMessage.style.display = (systemMessage.style.display === 'none' || systemMessage.style.display === '') ? 'block' : 'none';
  797. });
  798. });
  799. }
  800. // Function to create and style the gridbox_tools clone input window
  801. function createCustomInputWindow() {
  802. // Create the custom input window
  803. var customInputWindow1 = document.createElement("div");
  804. customInputWindow.className = "gridbox_tools";
  805. customInputWindow.innerHTML = `
  806. <div class="tb">
  807. <!-- Add other elements here similar to the default menu -->
  808. <input type="text" autocomplete="off" class="chatmsg fs_1" style="color: rgb(221, 221, 221);" maxlength="500">
  809. <button class="sendbtn material-icons">Send</button>
  810. </div>
  811. `;
  812. // Append the custom input window to the body
  813. document.body.appendChild(customInputWindow);
  814. // Style the text input
  815. var customChatmsg = customInputWindow.querySelector(".chatmsg");
  816. customChatmsg.style.flex = "1";
  817. customChatmsg.style.padding = "5px";
  818. // Style the send button
  819. var customSendbtn = customInputWindow.querySelector(".sendbtn");
  820. customSendbtn.innerText = "msg"; // Customize the button text as needed
  821. // Add event listener for the send button
  822. customSendbtn.addEventListener("click", function () {
  823. handleCustomButtonClick(customChatmsg.value.trim());
  824. });
  825. }
  826. // Function to create and style additional custom input window
  827. function createAdditionalCustomInputWindow() {
  828. // Create the custom input window
  829. var customInputWindow2 = document.createElement("div");
  830. customInputWindow2.className = "command-input-window";
  831. customInputWindow2.innerHTML = `
  832. <input type="text" autocomplete="off" class="custom-chatmsg" placeholder="Type your command...">
  833. <button class="custom-sendbtn material-icons">Send</button>
  834. <button class="custom-sendbtn2">Send 2</button>
  835. `;
  836. // Style the custom input window
  837. customInputWindow2.style.position = "fixed";
  838. customInputWindow2.style.bottom = "10px";
  839. customInputWindow2.style.left = "10px";
  840. customInputWindow2.style.display = "flex";
  841. customInputWindow2.style.alignItems = "center";
  842. // Append the custom input window to the body
  843. document.body.appendChild(customInputWindow2);
  844. // Style the text input
  845. var customChatmsg = customInputWindow2.querySelector(".custom-chatmsg");
  846. customChatmsg.style.flex = "1";
  847. customChatmsg.style.padding = "5px";
  848. // Style the send buttons
  849. var customSendbtn = customInputWindow2.querySelector(".custom-sendbtn");
  850. customSendbtn.innerText = "cmd"; // Customize the button text as needed
  851. var customSendbtn2 = customInputWindow2.querySelector(".custom-sendbtn2");
  852. customSendbtn2.innerText = "msg"; // Customize the button text as needed
  853. var sendButtons = [customSendbtn, customSendbtn2];
  854. // Create a third button for saying hello
  855. var customSendbtn3 = document.createElement("button");
  856. customSendbtn3.innerText = "hi"; // Customize the button text as needed
  857. // Append the button to the custom input window
  858. customInputWindow2.appendChild(customSendbtn3);
  859. // Add an event listener for the "Send" button
  860. customSendbtn.addEventListener("click", function () {
  861. handleCustomButtonClick(customChatmsg.value.trim());
  862. });
  863. // Add a click event listener to the "Hello" button
  864. customSendbtn3.addEventListener("click", function () {
  865. // Your logic for handling the "Hello" button goes here
  866. var command = customChatmsg.value.trim();
  867. // Clear the input field after processing the command
  868. customChatmsg.value = "";
  869. // Simulate a click on the button
  870. customSendbtn3.click();
  871. });
  872. // Create the button element
  873. var customSendBtn = document.createElement("button");
  874. customSendBtn.className = "sendbtn"; // Add the desired class name
  875. customSendBtn.innerHTML = '<svg width="24" height="24" viewBox="0 0 24 24"><path d="M3 3h18v2H3V3zm0 4h12v2H3V7zm0 4h18v2H3v-2zm0 4h12v2H3v-2z"></path></svg>';
  876. // Replace the innerHTML with your SVG code or use an external SVG file
  877. // Append the button to the desired container (e.g., document.body)
  878. document.body.appendChild(customSendBtn);
  879. // Append the third button to the custom input window
  880. customInputWindow2.appendChild(customSendbtn3);
  881. // Style all send buttons
  882. sendButtons.forEach(function (btn) {
  883. btn.style.cursor = "pointer";
  884. btn.style.padding = "5px";
  885. // Add event listener for each button
  886. btn.addEventListener("click", function () {
  887. handleButtonClick(btn);
  888. console.log("handleButtonClick clicked!");
  889. });
  890. });
  891. // Append the new button to the custom input window
  892. customInputWindow2.appendChild(customSendbtn2);
  893. // Add an event listener for the new "Message" button
  894. customSendbtn2.addEventListener("click", function () {
  895. // Your logic for handling the command goes here
  896. var command = customChatmsg.value.trim();
  897. // Clear the input field after processing the command
  898. customChatmsg.value = "";
  899. });
  900. // Append the new button to the custom input window
  901. customInputWindow2.appendChild(customSendbtn2);
  902. // Function to handle default "Send" button click
  903. function handleDefaultSendButtonClick(btn, customChatmsg) {
  904. var command = customChatmsg.value.trim();
  905. // Your logic for handling the command with the default "Send" button goes here
  906. // Use btn to identify which button triggered the click event
  907. // Clear the input field after processing the command
  908. customChatmsg.value = "";
  909. }
  910. // Add an event listener for the original "Send" button
  911. var defaultSendBtn = customInputWindow.querySelector(".sendbtn");
  912. defaultSendBtn.addEventListener("click", function () {
  913. handleButtonClick(defaultSendBtn);
  914. });
  915. // Function to handle button clicks
  916. function handleButtonClick(btn, customChatmsg) {
  917. var command = customChatmsg.value.trim();
  918. // Your logic for handling the command goes here
  919. // Use btn to identify which button triggered the click event
  920. // Clear the input field after processing the command
  921. customChatmsg.value = "";
  922. }
  923. function handleCustomButtonClick(command) {
  924. // Your logic for handling the command goes here
  925. // This might involve calling the necessary functions from furtherchat.js
  926. // Ensure the logic aligns with the existing chat system
  927. // Clear the input field after processing the command
  928. customChatmsg.value = "";
  929. }
  930. // Function to create and style the combined input window
  931. function createCombinedInputWindow() {
  932. // Create the custom input window
  933. var customInputWindow3 = document.createElement("div");
  934. customInputWindow.className = "combined-input-window";
  935. // Append the custom input window to the body
  936. document.body.appendChild(customInputWindow);
  937. // <!-- Add other elements here similar to the default menu -->
  938. customInputWindow.innerHTML = `
  939. <div class="tb">
  940. <input type="text" autocomplete="off" class="chatmsg fs_1" style="color: rgb(221, 221, 221);" maxlength="500">
  941. <button class="sendbtn material-icons">Send</button>
  942. <button class="custom-sendbtn2">Send 2</button>
  943. </div>
  944. `;
  945. // Move the following code inside the createCombinedInputWindow function
  946. var additionalButtonsHTML = `
  947. <select class="sizesel">
  948. <option value="0">smaller</option>
  949. <option value="1">normal</option>
  950. <option value="2">bigger</option>
  951. <option value="3">more bigger</option>
  952. </select>
  953. <button style="display: inline-block;">YouTube Player</button>
  954. <div class="fccb">
  955. <input type="checkbox">
  956. <label><span class="material-icons"></span>Kageshi Mode</label>
  957. </div>
  958. <input type="text" autocomplete="off" class="chatmsg fs_1" maxlength="700" style="color: rgb(221, 221, 221);">
  959. <button class="sendbtn material-icons"></button>
  960. `;
  961. customInputWindow.querySelector('.tb').innerHTML += additionalButtonsHTML;
  962. // Event listener for your "Command" button
  963. var customSendbtn2 = customInputWindow.querySelector(".custom-sendbtn2");
  964. customSendbtn2.addEventListener("click", function () {
  965. // Call the backend function or method for "Send 2"
  966. // Adjust the logic as needed
  967. send2ButtonClick();
  968. });
  969. // Event listener for your additional buttons
  970. var additionalButtons = customInputWindow.querySelectorAll(".your-additional-buttons-class");
  971. additionalButtons.forEach(function (button) {
  972. button.addEventListener("click", function () {
  973. // Call the backend function or method associated with the clicked button
  974. // Adjust the logic as needed
  975. yourAdditionalButtonClick(button);
  976. });
  977. });
  978. // Additional styling or event listeners for the combined input window if needed
  979. }
  980. // Create the combined input window
  981. createCombinedInputWindow();
  982. // Function to handle the "Send 2" button click
  983. function send2ButtonClick() {
  984. // Your logic for handling "Send 2" goes here
  985. console.log("Send 2 button clicked!");
  986. }
  987. // Function to handle additional button clicks
  988. function yourAdditionalButtonClick(button) {
  989. // Determine which button was clicked based on its properties or class, and call the corresponding backend method
  990. if (button.classList.contains("your-specific-button-class")) {
  991. // Call the backend method for the specific button
  992. console.log("Your specific button clicked!");
  993. } else {
  994. // Handle other buttons if needed
  995. }
  996. }
  997. // Append the custom input window to the body
  998. document.body.appendChild(customInputWindow);
  999. // Style the text input
  1000. var customChatmsg = customInputWindow.querySelector(".chatmsg");
  1001. customChatmsg.style.flex = "1";
  1002. customChatmsg.style.padding = "5px";
  1003. // Style the send button
  1004. var customSendbtn = customInputWindow.querySelector(".sendbtn");
  1005. customSendbtn.innerText = "msg"; // Customize the button text as needed
  1006. // Add event listener for the send button
  1007. customSendbtn.addEventListener("click", function () {
  1008. handleCustomButtonClick(customChatmsg.value.trim());
  1009. });
  1010. // Assuming you have a reference to your combined input window
  1011. var combinedInputWindow = document.querySelector(".combined-input-window");
  1012. // Event listener for your "Command" button
  1013. var customSendbtn2 = combinedInputWindow.querySelector(".custom-sendbtn2");
  1014. customSendbtn2.addEventListener("click", function () {
  1015. // Call the backend function or method for "Send 2"
  1016. // Adjust the logic as needed
  1017. send2ButtonClick();
  1018. });
  1019. // Event listener for your additional buttons
  1020. var additionalButtons = combinedInputWindow.querySelectorAll(".your-additional-buttons-class");
  1021. additionalButtons.forEach(function (button) {
  1022. button.addEventListener("click", function () {
  1023. // Call the backend function or method associated with the clicked button
  1024. // Adjust the logic as needed
  1025. yourAdditionalButtonClick(button);
  1026. });
  1027. });
  1028. }
  1029. // Declare customInputWindow4 at the beginning of your code
  1030. var customInputWindow4 = document.createElement("div");
  1031. customInputWindow4.className = "your-custom-class"; // Fix the typo here
  1032. // Clone gridbox
  1033. function cloneGridbox() {
  1034. var gridboxTools = document.querySelector('.gridbox_tools');
  1035. var clonedGridboxTools = gridboxTools.cloneNode(true);
  1036. // Append the new button to the custom input window
  1037. customInputWindow4.appendChild(clonedGridboxTools);
  1038. // Append the new button to the custom input window
  1039. var customSendbtn2 = customInputWindow4.querySelector(".custom-sendbtn2");
  1040. customSendbtn2.addEventListener("click", function () {
  1041. // Your logic for handling the "Send 2" command goes here
  1042. var command = customChatmsg.value.trim();
  1043. // Clear the input field after processing the command
  1044. customChatmsg.value = "";
  1045. });
  1046. // Additional styling or event listeners for the combined input window if needed
  1047. // Move this block inside the createCombinedInputWindow function
  1048. // Add additional buttons and elements from your HTML code
  1049. var additionalButtonsHTML = `
  1050. <select class="sizesel">
  1051. <option value="0">smaller</option>
  1052. <option value="1">normal</option>
  1053. <option value="2">bigger</option>
  1054. <option value="3">more bigger</option>
  1055. </select>
  1056. <button style="display: inline-block;">YouTube Player</button>
  1057. <div class="fccb">
  1058. <input type="checkbox">
  1059. <label><span class="material-icons"></span>Kageshi Mode</label>
  1060. </div>
  1061. <input type="text" autocomplete="off" class="chatmsg fs_1" maxlength="700" style="color: rgb(221, 221, 221);">
  1062. <button class="sendbtn material-icons"></button>
  1063. `;
  1064. clonedGridboxTools.querySelector('.tb').innerHTML += additionalButtonsHTML;
  1065. // Append the custom input window to the body
  1066. document.body.appendChild(customInputWindow4);
  1067. }
  1068. //fc_cam.prototype.setkmode = function(t) {
  1069. // this.kageshi_mode = t,
  1070. // null === this.video || null === this.user || this.you || this.paused || this.kageshi_mode && (this.pausecam(this.user),
  1071. // this.ws.sendpbuf(1200798, this.pb.roots.default.fc.p_1200798.encode({
  1072. // cn: this.camno
  1073. // }, null).finish()))
  1074. //}
  1075. function fc_coolbox(t, e, n, i, s, o, c) {
  1076. this.ws = t;
  1077. this.pb = e;
  1078. this.cb = s;
  1079. this.msglimit = o;
  1080. this.pmctrl = n;
  1081. this.layout = i;
  1082. this.yt_cb = c;
  1083. this.font_colour = "#FF0000";
  1084. this.font_size = 1;
  1085. this.elem = document.createElement("div");
  1086. this.elem.className = "tb";
  1087. // Create the color picker
  1088. this.text_cp = document.createElement("input");
  1089. this.text_cp.className = "jscolor";
  1090. this.text_cp.setAttribute("data-jscolor", "{position:'top',hash:false,value:'" + this.font_colour + "',borderRadius:'1px',borderColor:'" + this.ws.theme.lncol + "',controlBorderColor:'" + this.ws.theme.lncol + "',backgroundColor:'" + this.ws.theme.bgcol + "'}");
  1091. this.text_cp.onchange = this.cp_change.bind(this);
  1092. this.elem.appendChild(this.text_cp);
  1093. // Create the font size selector
  1094. this.sel_fs = document.createElement("select");
  1095. this.sel_fs.className = "sizesel";
  1096. this.sel_fs.onchange = this.fs_change.bind(this);
  1097. for (let i = 0; i < 4; i++) {
  1098. let option = document.createElement("option");
  1099. option.innerHTML = (i === 0) ? "smaller" : (i === 1) ? "normal" : (i === 2) ? "bigger" : "more bigger";
  1100. option.value = i;
  1101. this.sel_fs.appendChild(option);
  1102. }
  1103. this.sel_fs.selectedIndex = this.font_size;
  1104. this.elem.appendChild(this.sel_fs);
  1105. // Create the YouTube Player button
  1106. this.btn_ytpl = document.createElement("button");
  1107. this.btn_ytpl.innerHTML = "YouTube Player";
  1108. this.btn_ytpl.onclick = this.yt_click.bind(this);
  1109. this.btn_ytpl.style.display = "none";
  1110. this.elem.appendChild(this.btn_ytpl);
  1111. // Create the Kageshi Mode checkbox
  1112. //this.cb_kmode = new fc_checkbox(false, "Kageshi Mode");
  1113. //this.cb_kmode.addonclick(this.kmode_click.bind(this));
  1114. //this.elem.appendChild(this.cb_kmode.elem);
  1115. // Create the input for messages
  1116. this.text_msg = document.createElement("input");
  1117. this.text_msg.setAttribute("type", "text");
  1118. this.text_msg.setAttribute("autocomplete", "off");
  1119. this.text_msg.className = "chatmsg fs_" + this.font_size;
  1120. this.text_msg.style.color = this.font_colour;
  1121. this.text_msg.value = "";
  1122. this.text_msg.onkeyup = this.msg_keyup.bind(this);
  1123. this.text_msg.autocomplete = "off";
  1124. this.elem.appendChild(this.text_msg);
  1125. // Create the Send button
  1126. this.btn_send = document.createElement("button");
  1127. this.btn_send.className = "sendbtn material-icons";
  1128. this.btn_send.onclick = this.send_click.bind(this);
  1129. this.elem.appendChild(this.btn_send);
  1130. // Append additional buttons for Hello, Message, and Command
  1131. this.btn_hello = document.createElement("button");
  1132. this.btn_hello.innerHTML = "Hello";
  1133. this.btn_hello.onclick = this.hello_click.bind(this);
  1134. this.elem.appendChild(this.btn_hello);
  1135. this.btn_msg = document.createElement("button");
  1136. this.btn_msg.innerHTML = "Message";
  1137. this.btn_msg.onclick = this.msg_click.bind(this);
  1138. this.elem.appendChild(this.btn_msg);
  1139. this.btn_cmd = document.createElement("button");
  1140. this.btn_cmd.innerHTML = "Command";
  1141. this.btn_cmd.onclick = this.cmd_click.bind(this);
  1142. this.elem.appendChild(this.btn_cmd);
  1143. }