Advertisement
MeKLiN2

Untitled

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