Advertisement
MeKLiN2

init tc manually 2

Jan 27th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Init Tc Manually 2
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-01-27
  5. // @description Intercepts WebSocket creation for Tinychat
  6. // @author You
  7. // @match https://tinychat.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. "use strict";
  13.  
  14. // Create a function to append logs to a console div
  15. function appendToConsole(message) {
  16. const consoleDiv = document.getElementById("console");
  17. if (consoleDiv) {
  18. consoleDiv.innerHTML += message + "<br>";
  19. }
  20. }
  21.  
  22. // Override WebSocket constructor to intercept WebSocket creation
  23. const originalWebSocket = window.WebSocket;
  24. window.WebSocket = function(url, protocol) {
  25. if (url === "wss://wss1516.tinychat.com:31897/") {
  26. appendToConsole(`Intercepted WebSocket connection: ${url}`);
  27. // You can manipulate the WebSocket connection here if needed
  28. }
  29. return new originalWebSocket(url, protocol);
  30. };
  31.  
  32. // Method to connect and initialize the console div
  33. function connectConsole() {
  34. const consoleDiv = document.createElement("div");
  35. consoleDiv.id = "console";
  36. consoleDiv.style.border = "1px solid #ccc";
  37. consoleDiv.style.overflow = "auto";
  38. consoleDiv.style.maxHeight = "200px";
  39. document.body.appendChild(consoleDiv);
  40. }
  41.  
  42. connectConsole();
  43. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement