YouTube Helper

Quality of life changes to YouTube

  1. // ==UserScript==
  2. // @name YouTube Helper
  3. // @namespace ccn0
  4. // @version 7
  5. // @description Quality of life changes to YouTube
  6. // @author CCN0
  7. // @license MIT
  8. // @match *://*.youtube.com/*
  9. // @icon https://www.google.com/s2/favicons?domain=youtube.com&sz=64
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. function youTubeHelper() {
  15. /* make player have sharp corners */
  16. if (document.querySelector('ytd-player')) {
  17. document.querySelector('ytd-player').style.borderRadius = "0";
  18. };
  19. /* make notifications badge white */
  20. if (document.querySelector('.yt-spec-icon-badge-shape__badge')) {
  21. document.querySelector('.yt-spec-icon-badge-shape__badge').style.color = "#fff";
  22. };
  23. /* hides notification amount in tab title */
  24. document.title = document.title.replace(/^\([0-9]*\)\s/, "");
  25.  
  26. function removeElements(selector) {
  27. const elements = document.querySelectorAll(selector);
  28. elements.forEach(element => {
  29. element.remove();
  30. });
  31. };
  32.  
  33. removeElements('button[aria-label="Search with your voice"]');
  34. removeElements('button[aria-label="Thanks"]');
  35. removeElements('button[aria-label="Join this channel"]');
  36. removeElements('ytd-video-description-infocards-section-renderer');
  37. removeElements('a.yt-simple-endpoint.style-scope.yt-formatted-string.bold');
  38. removeElements('a.yt-simple-endpoint.bold.style-scope.yt-formatted-string');
  39. removeElements('.ytd-watch-info-text>a');
  40. removeElements('button:has([aria-label="Channel watermark"])');
  41. removeElements('ytd-rich-section-renderer');
  42. removeElements('ytd-reel-shelf-renderer');
  43.  
  44. /* makes links not go through youtube */
  45. document.querySelectorAll('a[href*="://www.youtube.com/redirect?"]').forEach(link => {
  46. if (link.getAttribute('href')) {
  47. const urlParams = new URLSearchParams(link.getAttribute('href'));
  48. const qParam = decodeURIComponent(urlParams.get('q'));
  49.  
  50. if (qParam) {
  51. link.setAttribute('href', qParam);
  52. }
  53. }
  54. });
  55.  
  56. const shareUrlInput = document.getElementById('share-url');
  57. if (shareUrlInput) {
  58. let currentUrl = shareUrlInput.value;
  59. currentUrl = currentUrl.replace(/(\?|\&)si=[^&]*/g, '');
  60. shareUrlInput.value = currentUrl;
  61. };
  62.  
  63. if (window.location.href.includes('shorts/')) {
  64. let noshortsurl = window.location.href.replace('shorts/', 'watch?v=');
  65. window.location.href = noshortsurl;
  66. };
  67. };
  68. setInterval(youTubeHelper, 500);
  69. })();