Drawaria Blue Links enabler!

changes the text color of that message to blue, makes the text clickable!

  1. // ==UserScript==
  2. // @name Drawaria Blue Links enabler!
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-06-05
  5. // @description changes the text color of that message to blue, makes the text clickable!
  6. // @author YouTube Drawaria
  7. // @match https://drawaria.online/*
  8. // @license MIT
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=drawaria.online
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Function to check if a string contains a URL
  17. function isUrl(string) {
  18. const urlRegex = /(http|https):\/\/[^\s]+/g;
  19. return urlRegex.test(string);
  20. }
  21. // Function to handle new chat messages
  22. function handleNewMessage(message) {
  23. const chatbox = document.getElementById('chatbox_messages');
  24. let messageText = message.innerText;
  25.  
  26. // Eliminar el nombre del jugador del mensaje
  27. const playerNameElement = message.querySelector('.playerchatmessage-selfname');
  28. if (playerNameElement) {
  29. messageText = messageText.replace(playerNameElement.innerText, '').trim();
  30. }
  31.  
  32. // Check if the message contains a URL
  33. if (isUrl(messageText)) {
  34. // Set the value of the chatbox to the URL
  35. chatbox.value = messageText;
  36. // Set the color to blue
  37. chatbox.style.color = 'blue';
  38. // Make the text clickable
  39. chatbox.style.cursor = 'pointer';
  40. // Add an event listener for the click event
  41. chatbox.addEventListener('click', function() {
  42. window.open(messageText, '_blank');
  43. });
  44. }
  45. }
  46.  
  47. // Add an event listener for new chat messages
  48. const chatMessages = document.getElementById('chatbox_messages');
  49. chatMessages.addEventListener('DOMNodeInserted', (event) => {
  50. if (event.target.classList.contains('chatmessage')) {
  51. handleNewMessage(event.target);
  52. }
  53. });
  54. })();