Youtube Logo - Link to subscriptions feed

Change YouTube logo link to user's subscription feed instead of homepage (only when logged in)

当前为 2017-11-18 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            Youtube Logo - Link to subscriptions feed
// @namespace       Youtube Logo - Link to subscriptions feed
// @description     Change YouTube logo link to user's subscription feed instead of homepage (only when logged in)
// @version         1.1.3
// @include         /http|https://.*youtube\..*/
// @supportURL      https://greasyfork.org/en/scripts/13582/feedback
// @author          aciid
// ==/UserScript==

function runScript() {
  // console.info("Running Youtube Logo - Link to subscriptions feed");
  try {
    if (document.getElementById("yt-masthead-user") != null) {																												// Check user is logged in (old design)
      var LogoElement = document.getElementById("logo-container");                    																		// Get logo element
      LogoElement.href = "/feed/subscriptions";                                       															// Update logo element URL
      LogoElement.getElementsByTagName('area')[0].href = "/feed/subscriptions";       															// Update special event logo URL		
    } else if (document.getElementById("end").getElementsByTagName("ytd-notification-topbar-button-renderer") != null) {	// Check user is logged in (new design)
      var LogoElement = document.getElementById("logo").getElementsByTagName('a')[0];                    									// Get logo element
      LogoElement.addEventListener("click", function(){window.location.href = "/feed/subscriptions";});										// Refresh to correct URL on click
      LogoElement.href = "/feed/subscriptions";																																						// Update logo element URL	        
    }
  } catch (e) {
    // Try catch used to suppress errors if logo element or special event logo area map are unavailable
  }
}

window.onload = setTimeout(function(){runScript();}, 1);																																	// Execute script after page load
document.addEventListener('readystatechange', runScript);																																	// Use event listeners when page is not fully reloaded during navigation
document.addEventListener('spfdone', runScript);																																					// Use event listeners when page is not fully reloaded during navigation