Youtube Large Guide

Hide guide menu by default on YouTube

  1. // ==UserScript==
  2. // @name Youtube Large Guide
  3. // @description Hide guide menu by default on YouTube
  4. // @namespace https://greasyfork.org/users/237458
  5. // @version 1.0
  6. // @match https://www.youtube.com/*
  7. // @author figuccio
  8. // @grant GM_addStyle
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @run-at document-idle
  12. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
  13. // @icon https://www.youtube.com/s/desktop/3748dff5/img/favicon_48.png
  14. // @license MIT
  15. // ==/UserScript==
  16. (function() {
  17. 'use strict';
  18. var $ = window.jQuery;
  19. $(document).ready(function() {
  20. var url = undefined;
  21. var act = 2;
  22.  
  23. setInterval(function() {
  24. if (act == 0 && document.location.toString() != url) {
  25. act = 1;
  26. }
  27.  
  28. if (act == 1) {
  29. const Q = document.getElementsByTagName('yt-page-navigation-progress');
  30. if (!Q.length || !Q[0].hasAttribute('hidden')) {
  31. return;
  32. }
  33. act = 2;
  34. }
  35.  
  36. if (act == 2) {
  37. const guideButton = document.getElementById('guide-button');
  38. if (!guideButton) {
  39. return;
  40. }
  41.  
  42. let tmp = guideButton.getElementsByTagName('button');
  43. if (!tmp.length) {
  44. return;
  45. }
  46.  
  47. tmp = tmp[0];
  48. if (!tmp.hasAttribute('aria-pressed')) {
  49. return;
  50. }
  51.  
  52. if (tmp.getAttribute('aria-pressed') === 'true') {
  53. guideButton.click();
  54. } else {
  55. url = document.location.toString();
  56. act = 0;
  57. window.dispatchEvent(new Event('resize'));
  58. }
  59. }
  60. }, 1000);
  61. });
  62. })();