YouTubeの情報をコピーするブッマークレット

以下のブッマークレットをYouTubeのページで使うと全部で日付 チャンネル名 タイトル URLをクリップボードにコピーすることができる。ブックマークレットはブラウザに関係なく使用できます。

 

ブックマークレットの使い方

ブックマークバーを表示していない場合はバーを表示する。

設定→ブックマーク→ブックマークバーを表示。

 

ブックマークレットを作成する。

1-A コードをトリプルクリックで選択状態にしコピーする。バーを右クリック、「ページを追加」からURLにコードを張り付け名前を付け保存する。

1-B コードをトリプルクリックで選択状態にしドラッグでブックマークバーに配置し、名前を変える。

2Youtubeの動画ページで作成したブックマークをクリックする。

 

機能

・&カットはURLの指定秒数やリストの情報を含んだ&以降を削って取得する。

・投稿日は「もっと見る」を自動で開いて取得できる。

注意

ライブ配信中は取得できない。

・情報が取得できない場合は更新する。

 

 

タイトル URL 

例: Walter White in Mario Kart Wii https://www.youtube.com/watch?v=1XSysnj2Bk0

javascript:(function(){var dateElement=document.querySelector('yt-formatted-string#info > span:nth-child(3)'),title=document.querySelector('title'),url=window.location.href;if(dateElement && title){var date=dateElement.textContent.trim().match(/\d{4}\/\d{1,2}\/\d{1,2}/),dateString=date?date[0]:"",pageTitle=title.textContent.trim().replace(/\s*-\s*YouTube$/i,''),finalText=dateString+" "+pageTitle+" "+url;navigator.clipboard.writeText(finalText),alert("Complete: "+finalText)}else alert("Error")})();

&カット

javascript:(function(){var dateElement=document.querySelector('yt-formatted-string#info > span:nth-child(3)'),title=document.querySelector('title'),url=window.location.href.split('&')[0];if(dateElement&&title){var date=dateElement.textContent.trim().match(/\d{4}\/\d{1,2}\/\d{1,2}/),dateString=date?date[0]:"",pageTitle=title.textContent.trim().replace(/\s*-\s*YouTube$/i,''),finalText=dateString+" "+pageTitle+" "+url;navigator.clipboard.writeText(finalText),alert("Complete: "+finalText)}else alert("Error")})();

 

投稿日 タイトル URL

例: 2022/08/30 Walter White in Mario Kart Wii https://www.youtube.com/watch?v=1XSysnj2Bk0

javascript:(function(){var expandButton=document.querySelector('tp-yt-paper-button#expand');if(expandButton){expandButton.click();setTimeout(function(){var dateElement=document.querySelector('yt-formatted-string#info > span:nth-child(3)'),title=document.querySelector('title'),url=window.location.href;if(dateElement && title){var date=dateElement.textContent.trim().match(/\d{4}\/\d{1,2}\/\d{1,2}/),dateString=date?date[0]:"",pageTitle=title.textContent.trim().replace(/\s*-\s*YouTube$/i,''),finalText=dateString+" "+pageTitle+" "+url;navigator.clipboard.writeText(finalText),alert("Complete: "+finalText)}else alert("Error")}, 0);}})();

&カット

javascript:(function(){var expandButton=document.querySelector('tp-yt-paper-button#expand');if(expandButton){expandButton.click();setTimeout(function(){var dateElement=document.querySelector('yt-formatted-string#info > span:nth-child(3)'),title=document.querySelector('title'),url=window.location.href.split('&')[0];if(dateElement&&title){var date=dateElement.textContent.trim().match(/\d{4}\/\d{1,2}\/\d{1,2}/),dateString=date?date[0]:"",pageTitle=title.textContent.trim().replace(/\s*-\s*YouTube$/i,''),finalText=dateString+" "+pageTitle+" "+url;navigator.clipboard.writeText(finalText),alert("Complete: "+finalText)}else alert("Error")},0);}})();

 

チャンネル名 - タイトル URL

例: Chiptuner - Walter White in Mario Kart Wii https://www.youtube.com/watch?v=1XSysnj2Bk0

javascript:(function(){var title=document.querySelector('title'),url=window.location.href,channelElement=document.querySelector('yt-formatted-string#text');if(title&&channelElement){var t=title.textContent.trim().replace(/\s*-\s*YouTube$/i,''),channel=channelElement.textContent.trim(),finalText=channel+" - "+t+" "+url;navigator.clipboard.writeText(finalText),alert("Complete: "+finalText)}else alert("Error")})();

&カット

javascript:(function(){var title=document.querySelector('title'),url=window.location.href.split('&')[0],channelElement=document.querySelector('yt-formatted-string#text');if(title&&channelElement){var t=title.textContent.trim().replace(/\s*-\s*YouTube$/i,''),channel=channelElement.textContent.trim(),finalText=channel+" - "+t+" "+url;navigator.clipboard.writeText(finalText),alert("Complete: "+finalText)}else alert("Error")})();

投稿日 チャンネル名 - タイトル URL

例: 2022/08/30 Chiptuner - Walter White in Mario Kart Wii https://www.youtube.com/watch?v=1XSysnj2Bk0

javascript:(function(){var expandButton=document.querySelector('tp-yt-paper-button#expand');if(expandButton){expandButton.click();setTimeout(function(){var title=document.querySelector('title'),url=window.location.href,channelElement=document.querySelector('yt-formatted-string#text'),dateElement=document.querySelector('yt-formatted-string#info > span:nth-child(3)');if(title&&channelElement){var t=title.textContent.trim().replace(/\s*-\s*YouTube$/i,''),channel=channelElement.textContent.trim(),date=dateElement?dateElement.textContent.trim().match(/\d{4}\/\d{1,2}\/\d{1,2}/):"",dateString=date?date[0]:"",finalText=(dateString ? dateString + " " : "") + channel + " - " + t + " " + url;navigator.clipboard.writeText(finalText),alert("Complete: "+finalText)}else alert("Error")},0)}})();

&カット

javascript:(function(){var expandButton=document.querySelector('tp-yt-paper-button#expand');if(expandButton){expandButton.click();setTimeout(function(){var title=document.querySelector('title'),url=window.location.href.split('&')[0],channelElement=document.querySelector('yt-formatted-string#text'),dateElement=document.querySelector('yt-formatted-string#info > span:nth-child(3)');if(title&&channelElement){var t=title.textContent.trim().replace(/\s*-\s*YouTube$/i,''),channel=channelElement.textContent.trim(),date=dateElement?dateElement.textContent.trim().match(/\d{4}\/\d{1,2}\/\d{1,2}/):"",dateString=date?date[0]:"",finalText=(dateString ? dateString + " " : "") + channel + " - " + t + " " + url;navigator.clipboard.writeText(finalText),alert("Complete: "+finalText)}else alert("Error")},0)}})();

sha-k.hatenablog.com