Advertisement
MeKLiN2

Untitled

Jan 6th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. // ==UserScript==
  2. // @name New Userscript
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-01-06
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://tinychat.com/room/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=tinychat.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to add buttons to the waiting content
  16. function addButtonsToWaitingContent() {
  17. // Wait for the shadow host element to become available
  18. const waitForShadowHost = setInterval(function() {
  19. const shadowHost = document.querySelector("#content").shadowRoot.querySelector("#room-content > tc-videolist").shadowRoot.querySelector("#videos > div:nth-child(2) > div > tc-video-item");
  20. if (shadowHost && shadowHost.shadowRoot) {
  21. clearInterval(waitForShadowHost);
  22.  
  23. // Access shadow DOM
  24. const mainElement = shadowHost.shadowRoot;
  25. const overlayDiv = mainElement.querySelector("div > div > div.overlay");
  26. const waitingContent = mainElement.querySelector("div > div > div.waiting > div");
  27.  
  28. if (overlayDiv && waitingContent) {
  29. // Insert voting button into overlay div as the last child (nth-child 6)
  30. const votingButtonHTML = `
  31. <button class="voting-button">
  32. <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
  33. <!-- Your SVG path and other elements go here -->
  34. </svg>
  35. </button>
  36. `;
  37. overlayDiv.insertAdjacentHTML('beforeend', votingButtonHTML);
  38.  
  39. // Insert blank span into waiting-content div
  40. const blankSpanHTML = '<span></span>';
  41. waitingContent.innerHTML = blankSpanHTML;
  42.  
  43. // Add dynamic CSS styles for the voting button
  44. const style = document.createElement('style');
  45. style.textContent = `
  46. .video > div > .overlay > .voting-button {
  47. /* Your styling for the voting button */
  48. }
  49. /* Add other styles for the buttons as needed */
  50. `;
  51.  
  52. // Append the style element to the document head
  53. document.head.appendChild(style);
  54. } else {
  55. console.error('Overlay or waiting content element not found');
  56. }
  57. }
  58. }, 100);
  59. }
  60.  
  61. // Wait for the page to load before adding the buttons
  62. window.addEventListener('load', addButtonsToWaitingContent);
  63. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement