YouTube Helper

mods to make youtube better to use

目前为 2025-01-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Helper
  3. // @namespace ccn0
  4. // @version 6
  5. // @description mods to make youtube better to use
  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. document.querySelector('ytd-player').style.borderRadius = "0";
  17. /* make notifications badge white */
  18. document.querySelector('.yt-spec-icon-badge-shape__badge').style.color = "#fff"
  19. /* hides notification amount in tab title */
  20. document.title = document.title.replace(/^\([0-9]*\)\s/, "");
  21.  
  22. function removeElements(selector) {
  23. const elements = document.querySelectorAll(selector);
  24. elements.forEach(element => {
  25. element.remove();
  26. });
  27. };
  28.  
  29. removeElements('button[aria-label="Search with your voice"]');
  30. removeElements('button[aria-label="Thanks"]');
  31. removeElements('button[aria-label="Join this channel"]');
  32. removeElements('ytd-video-description-infocards-section-renderer');
  33. removeElements('a.yt-simple-endpoint.style-scope.yt-formatted-string.bold');
  34. removeElements('a.yt-simple-endpoint.bold.style-scope.yt-formatted-string');
  35.  
  36. /* middle mouse clicking the avatars opens the link in new tab */
  37. /*
  38. document.querySelectorAll('#avatar-container').forEach((e)=>{
  39. e.addEventListener('mousedown',(ev)=>{
  40. ev.preventDefault();
  41. if(ev.button===1){
  42. window.open(e.children[0].href)
  43. }
  44. })
  45. });
  46. */
  47.  
  48. /* kills annoying shelves */
  49. document.querySelector('.ShortsLockupViewModelHostThumbnail').parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.remove();
  50. document.querySelector('.yt-mini-game-card-view-model__thumbnail-image').parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.remove();
  51.  
  52. /* makes links not go through youtube */
  53. document.querySelectorAll('a[href*="://www.youtube.com/redirect?"]').forEach(link => {
  54. if (link.getAttribute('href')) {
  55. const urlParams = new URLSearchParams(link.getAttribute('href'));
  56. const qParam = decodeURIComponent(urlParams.get('q'));
  57.  
  58. if (qParam) {
  59. link.setAttribute('href', qParam);
  60. }
  61. }
  62. });
  63.  
  64. const shareUrlInput = document.getElementById('share-url');
  65. if (shareUrlInput) {
  66. let currentUrl = shareUrlInput.value;
  67. currentUrl = currentUrl.replace(/(\?|\&)si=[^&]*/g, '');
  68. shareUrlInput.value = currentUrl;
  69. }
  70.  
  71. if (window.location.href.includes('shorts/')) {
  72. let noshortsurl = window.location.href.replace('shorts/', 'watch?v=');
  73. window.location.href = noshortsurl;
  74. };
  75. };
  76. setInterval(youTubeHelper, 500);
  77. })();