Advertisement
MeKLiN2

Untitled

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