Advertisement
MeKLiN2

hidden menu button #2

Jan 7th, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 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/*
  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(".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. <!-- Replace this with your actual SVG path for the voting button -->
  34. <path d="M10 0C4.485 0 0 4.485 0 10s4.485 10 10 10 10-4.485 10-10S15.515 0 10 0zm0 18.75C5.5 18.75 1.25 14.5 1.25 10S5.5 1.25 10 1.25 18.75 5.5 18.75 10 14.5 18.75 10 18.75z"/>
  35. </svg>
  36. </button>
  37. `;
  38. overlayDiv.insertAdjacentHTML('beforeend', votingButtonHTML);
  39.  
  40. // Insert additional buttons into the video-context div
  41. const videoContextDiv = mainElement.querySelector(".video-context-content");
  42. if (videoContextDiv) {
  43. const additionalButtonHTML = `
  44. <button class="new-button">
  45. <svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
  46. <!-- Replace this with your actual SVG path for the new button -->
  47. <path d="M10 0C4.485 0 0 4.485 0 10s4.485 10 10 10 10-4.485 10-10S15.515 0 10 0zm0 18.75C5.5 18.75 1.25 14.5 1.25 10S5.5 1.25 10 1.25 18.75 5.5 18.75 10 14.5 18.75 10 18.75z"/>
  48. </svg>
  49. </button>
  50. `;
  51. videoContextDiv.insertAdjacentHTML('beforeend', additionalButtonHTML);
  52. }
  53.  
  54. // Add dynamic CSS styles for the buttons
  55. const style = document.createElement('style');
  56. style.textContent = `
  57. .overlay button.voting-button,
  58. .video-context-content button.new-button {
  59. display: none;
  60. position: absolute;
  61. top: 50% !important; /* Move the button halfway down the overlay */
  62. left: 10px; /* Adjust the left position as needed */
  63. transform: translateY(-50%); /* Center the button vertically */
  64. /* Your styling for the buttons */
  65. }
  66. .overlay:hover button.voting-button,
  67. .video-context-content:hover button.new-button {
  68. display: block;
  69. }
  70. /* Add other styles for the buttons as needed */
  71. `;
  72.  
  73. // Append the style element to the document head
  74. document.head.appendChild(style);
  75. } else {
  76. console.error('Overlay or waiting content element not found');
  77. }
  78. }
  79. }, 100);
  80. }
  81.  
  82. // Wait for the page to load before adding the buttons
  83. window.addEventListener('load', addButtonsToWaitingContent);
  84. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement