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.

当前为 2017-12-16 提交的版本,查看 最新版本

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