Meklin Shutdownchat Script

Modified Shutdownchat, unmatched scripts, brace to be thunderstruck

目前為 2024-01-03 提交的版本,檢視 最新版本

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