Greasy Fork is available in English.

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.

Устаревшая версия на 25.02.2018. Перейти к последней версии.

// ==UserScript==
// @name         Change YouTube Leftbar Subscription Links To Channel/User Video Page
// @namespace    ChangeYouTubeLeftbarSubscriptionLinksToChannelUserVideoPage
// @version      1.0.3
// @license      AGPL v3
// @description  Change YouTube leftbar's subscription links to channel/user video page. For new YouTube layout only.
// @author       jcunews
// @match        *://www.youtube.com/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

function patchGuide(guide) {
  if (guide && !guide.cysl_done) {
    guide.cysl_done = 1;
    guide.items.forEach(function(v) {
      if (v.guideSubscriptionsSectionRenderer) {
        v.guideSubscriptionsSectionRenderer.items.forEach(function(w) {
          if (w.guideCollapsibleEntryRenderer) {
            w.guideCollapsibleEntryRenderer.expandableItems.forEach(function(x) {
              if (x.guideEntryRenderer.badges) {
                x.guideEntryRenderer.navigationEndpoint.commandMetadata.webCommandMetadata.url += "/videos";
                x.guideEntryRenderer.navigationEndpoint.webNavigationEndpointData.url += "/videos";
              }
            });
          } else {
            w.guideEntryRenderer.navigationEndpoint.commandMetadata.webCommandMetadata.url += "/videos";
            w.guideEntryRenderer.navigationEndpoint.webNavigationEndpointData.url += "/videos";
          }
        });
      }
    });
    return true;
  }
  return false;
}

var ht1 = 0, ht2 = 0;

(function chkStatic(ev) {
  clearTimeout(ht1);
  if (!patchGuide(window.ytInitialGuideData)) {
    ht1 = setTimeout(chkStatic, 0);
  }
})();

(function chkSpf() {
  clearTimeout(ht2);
  if (window.spf && spf.request && !spf.request_cysl) {
    spf.request_cysl = spf.request;
    spf.request = function(a, b) {
      if (b && b.onDone) {
        var onDone_ = b.onDone;
        b.onDone = function(response) {
          if (response && (/\/guide_ajax\?/).test(response.url) && response.response && response.response.response) {
            patchGuide(response.response.response);
          }
          return onDone_.apply(this, arguments);
        };
        return this.request_cysl.apply(this, arguments);
      }
    };
    return;
  }
  ht2 = setTimeout(chkSpf, 0);
})();

addEventListener("load", function() {
  clearTimeout(ht1);
  clearTimeout(ht2);
});