YouTube Button Reposition

Move YouTube buttons to different positions

  1. // ==UserScript==
  2. // @name YouTube Button Reposition
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Move YouTube buttons to different positions
  6. // @author You
  7. // @match *://www.youtube.com/watch*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to move buttons around
  15. function moveButtons() {
  16. // Wait until the page is fully loaded
  17. if (document.readyState === 'complete') {
  18. const watchActions = document.querySelector('#actions');
  19. const title = document.querySelector('.title yt-formatted-string');
  20. const channel = document.querySelector('#owner-name');
  21. const subscribe = document.querySelector('#subscribe-button');
  22. const join = document.querySelector('#join-button');
  23.  
  24. if (watchActions && title && channel && subscribe && join) {
  25. // Move buttons
  26. const buttons = watchActions.querySelectorAll('ytd-menu-renderer, ytd-button-renderer');
  27. const rightSection = document.querySelector('.style-scope.ytd-watch-metadata');
  28. const leftSection = document.querySelector('#info-contents');
  29.  
  30. buttons.forEach(button => {
  31. rightSection.appendChild(button);
  32. });
  33.  
  34. leftSection.insertBefore(subscribe, leftSection.firstChild);
  35. leftSection.insertBefore(join, leftSection.firstChild);
  36. }
  37. }
  38. }
  39.  
  40. // Run the function when the page is loaded
  41. window.addEventListener('load', moveButtons);
  42. })();