Skip to content

Instantly share code, notes, and snippets.

@hyuki

hyuki/README.md Secret

Last active April 24, 2022 12:53
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyuki/8a9e64f776357baf07e858a1f2a2180b to your computer and use it in GitHub Desktop.
Save hyuki/8a9e64f776357baf07e858a1f2a2180b to your computer and use it in GitHub Desktop.
YouTubeToRSS.js - YouTubeのチャンネルページからRSSフィードを得るブックマークレット

YouTubeToRSS.js - YouTubeのチャンネルページからRSSフィードを得るブックマークレット

使い方

  • YouTubeToRSS.jsをブックマークレットにしておく。
  • 登録チャンネル→管理で、自分の登録しているチャンネル一覧を表示する。
  • そこからRSSを得たいチャンネルにジャンプする。
  • そこのページでYouTubeToRSS.jsブックマークレットを実行。
  • クリップボードにRSSフィードが得られる。

チャンネルページ

得られるRSSフィード

RADWIMPS - YouTube
https://www.youtube.com/feeds/videos.xml?channel_id=UCIVqvhyo8ttjYOmMJuhq_YQ
function initToast() {
const bodies = document.getElementsByTagName("body");
const body = bodies[0];
const div = document.createElement("div");
div.id = "YouTubeToRSS";
div.innerText = "YouTubeToRSS";
div.style.position = "fixed";
div.style.zIndex = "5000";
div.style.top = "0px";
div.style.left = "0px";
div.style.padding = "10px";
div.style.margin = "10px";
div.style.borderRadius = "5px";
div.style.display = "none";
div.style.color = "black";
div.style.backgroundColor = "#ffffcc";
div.style.whiteSpace = "pre-wrap";
div.style.wordWrap = "break-word";
div.style.fontFamily = "monospace";
div.style.fontSize = "x-large";
div.style.border = "gray solid 1px";
div.style.lineHeight = "1.5";
body.append(div);
}
function showToast(s) {
const div = document.getElementById("YouTubeToRSS");
div.innerText = s;
div.style.display = "block";
setTimeout(function() {
div.style.display = "none";
}, 5000);
}
initToast();
function saveToClipboard(s) {
navigator.clipboard.writeText(s).then(function() {
showToast(`RSS Copied!\n${s}`);
}, function() {
showToast(`ERROR: ${s} is NOT saved`);
});
}
function start() {
const url = location.href;
const title = document.title;
if (url.match(/^https:\/\/www.youtube.com\/channel\/(.*)/)) {
let id = RegExp.$1;
let rss = `https://www.youtube.com/feeds/videos.xml?channel_id=${id}`;
const text = `${title}\n${rss}\n`;
saveToClipboard(text);
} else {
showToast(`ERROR: ${url} is NOT YouTube Channel URL.`);
}
}
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment