+Youtube
by
noromanba
2012-12-14 [2012/12/14 09:22:27]
Subscribe Youtube feed (Atom, RSS)
@@ -1,70 +1,52 @@
/*
- * @title +Subscribe Youtube RSS
- * @description Subscribe Youtube Uploads RSS.
+ * @title +Youtube
+ * @description Subscribe Youtube uploads feed (RSS, Atom)
* @include http://www.youtube.com/*
* @include https://www.youtube.com/*
- * @license MIT License http://noromanba.mit-license.org/2012+
* @require
- * @see http://let.hatelabo.jp/noromanba/let/gYC-yZeZ6_P0WQ (Permalink)
+ * @license MIT License http://nrm.mit-license.org/2012
+ * @author noromanba (https://flavors.me/noromanba)
*
- * [RSS]
- * Large Thumbnail(embed) ver.
- * http://gdata.youtube.com/feeds/base/users/youtube/uploads
- * Default Register from Browser
- * http://gdata.youtube.com/feeds/base/users/youtube/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile
- * Tiny Query ver.
- * http://gdata.youtube.com/feeds/base/users/youtube/uploads?alt=rss&v=2&orderby=published
+ * RSS
+ * - large thumbnail ver.
+ * https://gdata.youtube.com/feeds/base/users/youtube/uploads
+ * - default feed, register from browser
+ * https://gdata.youtube.com/feeds/base/users/youtube/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile
+ * - tiny query ver.
+ * https://gdata.youtube.com/feeds/base/users/youtube/uploads?alt=rss&v=2&orderby=published
*
- * Alternate Gateway
- * http://www.youtube.com/rss/user/youtube/videos.rss
- * Exepand Alt-GW. Default Order by Updated
- * http://gdata.youtube.com/feeds/base/users/youtube/uploads?orderby=updated&alt=rss&client=ytapi-youtube-rss-redirect&v=2
- *
- * [NOTE]
- * This bookmarklet that may conflict with the Browser Extension or UserScript.
- * If you have problems while using the Developer Tool(It's stuck or death) or not,
- * please try to disable the extensions and scripts.
- * ex.) Google Chrome: use '--disable-extensions' option.
+ * - alternate gateway (user: youtube)
+ * https://www.youtube.com/rss/user/youtube/videos.rss
+ * - exepanded alt-gw. default order by updated
+ * https://gdata.youtube.com/feeds/base/users/youtube/uploads?orderby=updated&alt=rss&client=ytapi-youtube-rss-redirect&v=2
+ *
+ * NOTE
+ * This bookmarklet that may conflict with the Browser Extension or UserScript.
+ * If you have problems while using the Developer Tool(e.g. stuck or death) or other,
+ * please try to disable the extensions and scripts.
+ * e.g. add option on run
+ * chrome --disable-extensions
+ * firefox -safe-mode
*/
-(function() {
- return goSubscribe(getUserNameByLocation() || getUserNameBySelector());
-})();
-
-function getUserNameByLocation() {
- return parseUserName(location.href) || '';
-}
-
-function parseUserName(anchor) {
- // @TODO HTMLAnchorElement .href
- if (anchor && anchor.match(/https?:\/\/www\.youtube\.com\/user\/(\w+).*/)) {
- return RegExp.$1;
- }
- return '';
-}
-function getUserNameBySelector() {
- var d = document;
- var $ = function(q) { return d.querySelector(q); };
+// no handling artist tag or any other feeds
+(function () {
+ if (!(/^https?:\/\/www\.youtube\.com/.test(location.href))) return;
+
+ var user = (/^https?:\/\/www\.youtube\.com\/user\/(\w+)/.exec(location.href) || [])[1] ||
+ (document.querySelector('[rel=author]') || {}).textContent;
+ if (!user) return;
+
+ var reader = 'https://www.google.com/reader/view/feed/';
+ var feed = (function () {
+ // TBD make https:
+ var origin = 'http://gdata.youtube.com/feeds/base/users/' + user + '/uploads';
+ return {
+ small: origin + '?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile',
+ tiny : origin + '?alt=rss&v=2&orderby=published',
+ large: origin
+ };
+ })();
- // @TODO Refactor to Factory Method?
- var aVideo = '#watch-uploader-info > a';
- var chView = '#playnav-curvideo-channel-name > a';
- var newChView = 'upper-section, ytg-box > a';
-
- var anchor = $(aVideo) || $(chView) || $(newChView);
- if (!anchor) {
- alert('Oops.. Can\'t find UserName!');
- return '';
- }
- return parseUserName(anchor.href);
-}
-
-function goSubscribe(userName) {
- if (userName) {
- var baseFeed = 'http://gdata.youtube.com/feeds/base/users/' + userName + '/uploads';
- var apiQuery = '?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile';
-
- var readerPreview = 'http://google.com/reader/view/feed/';
- location.href = readerPreview + encodeURIComponent(baseFeed + apiQuery);
- }
-}
+ location.href = reader + encodeURIComponent(feed.small);
+})();
/*
* @title +Youtube
* @description Subscribe Youtube uploads feed (RSS, Atom)
* @include http://www.youtube.com/*
* @include https://www.youtube.com/*
* @require
* @license MIT License http://nrm.mit-license.org/2012
* @author noromanba (https://flavors.me/noromanba)
*
* RSS
* - large thumbnail ver.
* https://gdata.youtube.com/feeds/base/users/youtube/uploads
* - default feed, register from browser
* https://gdata.youtube.com/feeds/base/users/youtube/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile
* - tiny query ver.
* https://gdata.youtube.com/feeds/base/users/youtube/uploads?alt=rss&v=2&orderby=published
*
* - alternate gateway (user: youtube)
* https://www.youtube.com/rss/user/youtube/videos.rss
* - exepanded alt-gw. default order by updated
* https://gdata.youtube.com/feeds/base/users/youtube/uploads?orderby=updated&alt=rss&client=ytapi-youtube-rss-redirect&v=2
*
* NOTE
* This bookmarklet that may conflict with the Browser Extension or UserScript.
* If you have problems while using the Developer Tool(e.g. stuck or death) or other,
* please try to disable the extensions and scripts.
* e.g. add option on run
* chrome --disable-extensions
* firefox -safe-mode
*/
// no handling artist tag or any other feeds
(function () {
if (!(/^https?:\/\/www\.youtube\.com/.test(location.href))) return;
var user = (/^https?:\/\/www\.youtube\.com\/user\/(\w+)/.exec(location.href) || [])[1] ||
(document.querySelector('[rel=author]') || {}).textContent;
if (!user) return;
var reader = 'https://www.google.com/reader/view/feed/';
var feed = (function () {
// TBD make https:
var origin = 'http://gdata.youtube.com/feeds/base/users/' + user + '/uploads';
return {
small: origin + '?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile',
tiny : origin + '?alt=rss&v=2&orderby=published',
large: origin
};
})();
location.href = reader + encodeURIComponent(feed.small);
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。