Advertisement
MeKLiN2

abandoned code for shutdownchat

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