Change YouTube Leftbar Subscription Links To Channel/User Video Page

Change YouTube leftbar's subscription links to channel/user video page. For new YouTube layout only.

目前为 2018-02-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Change YouTube Leftbar Subscription Links To Channel/User Video Page
  3. // @namespace ChangeYouTubeLeftbarSubscriptionLinksToChannelUserVideoPage
  4. // @version 1.0.3
  5. // @license AGPL v3
  6. // @description Change YouTube leftbar's subscription links to channel/user video page. For new YouTube layout only.
  7. // @author jcunews
  8. // @match *://www.youtube.com/*
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. function patchGuide(guide) {
  14. if (guide && !guide.cysl_done) {
  15. guide.cysl_done = 1;
  16. guide.items.forEach(function(v) {
  17. if (v.guideSubscriptionsSectionRenderer) {
  18. v.guideSubscriptionsSectionRenderer.items.forEach(function(w) {
  19. if (w.guideCollapsibleEntryRenderer) {
  20. w.guideCollapsibleEntryRenderer.expandableItems.forEach(function(x) {
  21. if (x.guideEntryRenderer.badges) {
  22. x.guideEntryRenderer.navigationEndpoint.commandMetadata.webCommandMetadata.url += "/videos";
  23. x.guideEntryRenderer.navigationEndpoint.webNavigationEndpointData.url += "/videos";
  24. }
  25. });
  26. } else {
  27. w.guideEntryRenderer.navigationEndpoint.commandMetadata.webCommandMetadata.url += "/videos";
  28. w.guideEntryRenderer.navigationEndpoint.webNavigationEndpointData.url += "/videos";
  29. }
  30. });
  31. }
  32. });
  33. return true;
  34. }
  35. return false;
  36. }
  37.  
  38. var ht1 = 0, ht2 = 0;
  39.  
  40. (function chkStatic(ev) {
  41. clearTimeout(ht1);
  42. if (!patchGuide(window.ytInitialGuideData)) {
  43. ht1 = setTimeout(chkStatic, 0);
  44. }
  45. })();
  46.  
  47. (function chkSpf() {
  48. clearTimeout(ht2);
  49. if (window.spf && spf.request && !spf.request_cysl) {
  50. spf.request_cysl = spf.request;
  51. spf.request = function(a, b) {
  52. if (b && b.onDone) {
  53. var onDone_ = b.onDone;
  54. b.onDone = function(response) {
  55. if (response && (/\/guide_ajax\?/).test(response.url) && response.response && response.response.response) {
  56. patchGuide(response.response.response);
  57. }
  58. return onDone_.apply(this, arguments);
  59. };
  60. return this.request_cysl.apply(this, arguments);
  61. }
  62. };
  63. return;
  64. }
  65. ht2 = setTimeout(chkSpf, 0);
  66. })();
  67.  
  68. addEventListener("load", function() {
  69. clearTimeout(ht1);
  70. clearTimeout(ht2);
  71. });