Youtube Playlist Link Fix

Changes the playlist links on YouTube's playlist overview pages so that clicking them shows the page for the playlist in question instead of playing its first video (in other words, restores the old behaviour).

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Youtube Playlist Link Fix
// @namespace   https://greasyfork.org/users/151127-zeksm
// @description Changes the playlist links on YouTube's playlist overview pages so that clicking them shows the page for the playlist in question instead of playing its first video (in other words, restores the old behaviour).
// @include     https://youtube.com/*
// @include     https://www.youtube.com/*
// @version     1
// @grant       none
// ==/UserScript==

(function() {
    'use strict';

    replaceLinks();

    var body = document.getElementsByTagName("body")[0];
    body.addEventListener("yt-navigate-finish", function(e) {
        replaceLinks();
    });

    function replaceLinks() {
        if (location.href.indexOf("playlists") !== -1) {
            var links = document.querySelectorAll("a.ytd-grid-playlist-renderer");
            for (var i=0,imax=links.length; i<imax; i++) {
                var url = links[i].href;
                var playlistID = url.split("list=")[1];
                links[i].href = "https://www.youtube.com/playlist?list=" + playlistID;
                links[i].outerHTML = links[i].outerHTML;
            }
        }
    }
})();