討論 » 建立請求

Youtube - land on user's video page by default

§
發表於:2015-04-03

Youtube - land on user's video page by default

Simple request (I hope)

Any time you land on a youtube user's home page, for example https://www.youtube.com/user/grindinggear/featured
Redirect automatically to the video's page: https://www.youtube.com/user/grindinggear/videos

woxxom管理員
§
發表於:2015-04-06
編輯:2015-04-11

That can be done in two ways:

  1. Rewrite the user page links on any site to point to videos page, use Ctrl-Alt-click to skip redirection:
  // ==UserScript==
  // @name Youtube: open user's videos instead of the personal page
  // ==/UserScript==

  window.addEventListener('click', function(e) {
        if (e.altKey)
            return;

        var a = e.target;

        //search the parent A element if needed, max 10 levels up the hierarchy
        for (i=10; a.localName != 'a'; i--, a = a.parentNode)
            if (i==0 || !a.parentNode)
                return;

        a.href = a.href.replace(/(youtube\.com.*?\/user\/[^\/]+)(?:\/featured)?\/?$/, '$1/videos');
  });
  1. Redirect to the videos page only when a user page is opened, which will be briefly visible:
  // ==UserScript==
  // @name    Youtube: open user's videos instead of the personal page
  // @include https://www.youtube.com/user/*
  // ==/UserScript==

  if (m = location.href.match(/(^.+?youtube\.com.*?\/user\/[^\/]+)(?:\/featured)?\/?$/))
        location.href = m[1] + '/videos';
§
發表於:2015-04-11

Sounds good, but doesn't seem to work. The first script does nothing at all, and the second one does redirect to the videos page, but it reloads the video page over and over in and endless loop. Did you try the scripts?

woxxom管理員
§
發表於:2015-04-11

Fixed a few typos, try it again.

發表回覆

登入以回覆

长期地址
遇到问题?请前往 GitHub 提 Issues。