YouTube RSS Feed

Adds an RSS feed button to YouTube channels next to the subscribe button

目前為 2016-12-09 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name          YouTube RSS Feed
// @namespace     http://greasyfork.org/users/2240-doodles
// @author        Doodles
// @version       16
// @description   Adds an RSS feed button to YouTube channels next to the subscribe button
// @icon          http://i.imgur.com/Ty5HNbT.png
// @icon64        http://i.imgur.com/1FfVvNr.png
// @include       *://*youtube.*/*
// @grant         none
// @run-at        document-end
// @require       http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
// @updateVersion 16
// ==/UserScript==

(function() {
	window.jQ=jQuery.noConflict(true);
	RssFeedButton();
	document.body.addEventListener("DOMSubtreeModified", SelectiveFire);
	function SelectiveFire(){
		setTimeout(function() {
			if(jQ('#rssSubButton').length == 0){
				RssFeedButton();
			}
		}, 2500);
	}
	function RssFeedButton(){
		var rssFeed = navigator.userAgent.indexOf("Firefox") > 0 ? "http" : "feed";
		if(document.URL.indexOf("/playlist?list=") != -1){
			var playlistId = document.URL.split("list=")[1].split("&")[0];
			if(!playlistId.startsWith("PL")){
				playlistId = "PL" + playlistId;
			}
			rssFeed += "://www.youtube.com/feeds/videos.xml?playlist_id=" + playlistId;
		}else{
			rssFeed += "://www.youtube.com/feeds/videos.xml?channel_id=" + jQ("meta[itemprop='channelId']").attr("content");
		}
		if(jQ("link[title='RSS']").length === 0){
			jQ('head').append('<link rel="alternate" type="application/rss+xml" title="RSS" href="' + rssFeed + '" />');
		}
		var rssSubButton = jQ('<a/>').attr('id', 'rssSubButton').attr('target', '_blank').attr('href', rssFeed)
			.addClass('yt-uix-button yt-uix-button-size-default yt-uix-button-subscribe-branded yt-uix-button-has-icon no-icon-markup')
			.css("background", "linear-gradient(#fd9b12, #fe6702)");
		jQ(rssSubButton).html('<span class="yt-uix-button-content"><span class="subscribe-label">RSS Subscribe </span></span>');
		jQ(rssSubButton).mouseover(function(){ jQ(this).css("background", "linear-gradient(#fe6702, #fd9b12)"); });
		jQ(rssSubButton).mouseout(function(){ jQ(this).css("background", "linear-gradient(#fd9b12, #fe6702)"); });
		if(document.URL.indexOf("/playlist?list=") != -1){
			jQ('div.playlist-actions').append(rssSubButton);
		}else if(document.getElementById('c4-primary-header-contents') !== null){
			jQ('span.channel-header-subscription-button-container').prepend(document.createTextNode(" "));
			jQ('span.channel-header-subscription-button-container').prepend(rssSubButton);
		}else if(document.URL.indexOf("/watch") != -1 && document.URL.indexOf("v=") != -1){
			jQ('#watch7-subscription-container > span:first-child').prepend(document.createTextNode(" "));
			jQ('#watch7-subscription-container > span:first-child').prepend(rssSubButton);
		}
	}
})();