Diskussionen » Entwicklungsanfragen

Youtube - land on user's video page by default

§
Veröffentlicht: 03.04.2015

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

woxxomMod
§
Veröffentlicht: 06.04.2015
Bearbeitet: 11.04.2015

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';
§
Veröffentlicht: 11.04.2015

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?

woxxomMod
§
Veröffentlicht: 11.04.2015

Fixed a few typos, try it again.

Antwort schreiben

Anmelden um eine Antwort zu senden.

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