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

サイトをリンクタグ<a href=" "></a>で取得するブックマークレット

下記のブックマークレットを保存して押すと<a href=""></a>にURLとtitleを組み込んだものをクリップボードにコピーすることができる。

 

URLとTitle

例 <a href="https://www.youtube.com/watch?v=n1CNy0eIzuY" target="_blank" rel="noopener noreferrer">野坂昭如大島渚流「緊張と緩和」 - YouTube</a>

javascript:(function(){var url=document.location.href;var title=document.title;var newLink='<a href="'+url+'" target="_blank" rel="noopener noreferrer">'+title+'</a>';navigator.clipboard.writeText(newLink).then(function(){alert('Complete:'+newLink);}).catch(function(err){console.error('Error:',err);});})();

 

URLのみ

例 <a href="https://www.youtube.com/watch?v=n1CNy0eIzuY" target="_blank" rel="noopener noreferrer"></a>

javascript:(function(){var url=document.location.href;var newLink='<a href="'+url+'" target="_blank" rel="noopener noreferrer"></a>';navigator.clipboard.writeText(newLink).then(function(){alert('Complete: '+newLink);}).catch(function(err){console.error('Error: ',err);});})();

 

sha-k.hatenablog.com

タイムスタンプを取得するブックマークレット

下記のブックマークレットをブックマークバーに追加して押すと現在時刻がクリップボードにコピーされる。

chromeなどの初期タブには機能しない。

 

数字のみ

yyyymmdd 例 20240101

javascript:(function(){var now=new Date();var year=now.getFullYear();var month=('0'+(now.getMonth()+1)).slice(-2);var day=('0'+now.getDate()).slice(-2);var dateTime=year+month+day;var textField=document.createElement('textarea');textField.innerText=dateTime;document.body.appendChild(textField);textField.select();document.execCommand('copy');textField.remove();alert("Complete: "+dateTime);})();

.コロンパターン

yyyy.mm.dd  例 2024.01.01

javascript:(function(){var now=new Date();var year=now.getFullYear();var month=('0'+(now.getMonth()+1)).slice(-2);var day=('0'+now.getDate()).slice(-2);var dateTime=year+'.'+month+'.'+day;var textField=document.createElement('textarea');textField.innerText=dateTime;document.body.appendChild(textField);textField.select();document.execCommand('copy');textField.remove();alert("Complete: "+dateTime);})();

 

yyyy.mm.dd hh:mm 例 2024.01.01 00:00

javascript:(function(){var now=new Date();var year=now.getFullYear();var month=('0'+(now.getMonth()+1)).slice(-2);var day=('0'+now.getDate()).slice(-2);var hours=('0'+now.getHours()).slice(-2);var minutes=('0'+now.getMinutes()).slice(-2);var dateTime=year+'.'+month+'.'+day+' '+hours+':'+minutes;var textField=document.createElement('textarea');textField.innerText=dateTime;document.body.appendChild(textField);textField.select();document.execCommand('copy');textField.remove();alert("Complete: "+dateTime);})();

 

yyyy.mm.dd_hh:mm(アンダーバー有り) 例 2024.01.01_00:00

javascript:(function(){var now=new Date();var year=now.getFullYear();var month=('0'+(now.getMonth()+1)).slice(-2);var day=('0'+now.getDate()).slice(-2);var hours=('0'+now.getHours()).slice(-2);var minutes=('0'+now.getMinutes()).slice(-2);var dateTime=year+'.'+month+'.'+day+'_'+hours+':'+minutes;var textField=document.createElement('textarea');textField.innerText=dateTime;document.body.appendChild(textField);textField.select();document.execCommand('copy');textField.remove();alert("Complete: "+dateTime);})();

 

/スラッシュパターン

yyyy/mm/dd 例 2024/01/01

javascript:(function(){var now=new Date();var year=now.getFullYear();var month=('0'+(now.getMonth()+1)).slice(-2);var day=('0'+now.getDate()).slice(-2);var dateTime=year+'/'+month+'/'+day;var textField=document.createElement('textarea');textField.innerText=dateTime;document.body.appendChild(textField);textField.select();document.execCommand('copy');textField.remove();alert("Complete: "+dateTime);})();

 

yyyy/mm/dd hh:mm 例 2024/01/01 00:00

javascript:(function(){var now=new Date();var year=now.getFullYear();var month=('0'+(now.getMonth()+1)).slice(-2);var day=('0'+now.getDate()).slice(-2);var hours=('0'+now.getHours()).slice(-2);var minutes=('0'+now.getMinutes()).slice(-2);var dateTime=year+'/'+month+'/'+day+' '+hours+':'+minutes;var textField=document.createElement('textarea');textField.innerText=dateTime;document.body.appendChild(textField);textField.select();document.execCommand('copy');textField.remove();alert("Complete: "+dateTime);})();

 

yyyy/mm/dd_hh:mm(アンダーバー有り)例 2024/04/07_00:00

javascript:(function(){var now=new Date();var year=now.getFullYear();var month=('0'+(now.getMonth()+1)).slice(-2);var day=('0'+now.getDate()).slice(-2);var hours=('0'+now.getHours()).slice(-2);var minutes=('0'+now.getMinutes()).slice(-2);var dateTime=year+'/'+month+'/'+day+'_'+hours+':'+minutes;var textField=document.createElement('textarea');textField.innerText=dateTime;document.body.appendChild(textField);textField.select();document.execCommand('copy');textField.remove();alert("Complete: "+dateTime);})();

 

sha-k.hatenablog.com

TVerクイック検索 chrome拡張機能 ブックマークレット

2024.04.13更新

TVerをポップアップから手軽に検索できるchrome拡張機能を作っています。

chromewebstore.google.com

 

機能

・時計

TVer各種リンク

TVer検索バー

NHKプラスリンク

・ABEMAリンク

・ABEMA検索バー

TVerブックマークレット

 ボタンをブックマークバーにドラッグしてepisodes(番組)とliveのページで使うと 番組名、エピソード名、局名、放送日、期間、URLを取得する。

 

ブックマークレット

TVer_Copy 押すとクリップボードにコピーされる。

javascript:(function(){const elements=document.querySelectorAll('.titles_seriesTitle__filL4, .titles_title__KJ7tf, .description_metaDetail__M5hy5, .description_metaDetail__1swXX span, .description_broadcastDateLabel__PjGsI span');let textToCopy='';elements.forEach((element,index)=>{const text=element.textContent.trim();if(index===0||index===1||index===2||index===6||index===8){textToCopy+=text+'\n';}else if(index===3){textToCopy+=text+' ';}else if(index===4){textToCopy+=text+'\n';}else if(index===5||index===7){textToCopy+=text;}});const finalText=textToCopy.trim()+'\n'+location.href;const tempInput=document.createElement('textarea');tempInput.value=finalText;document.body.appendChild(tempInput);tempInput.select();document.execCommand('copy');document.body.removeChild(tempInput);alert('Complete:\n'+finalText);})();

TVer_Twi Twitterの投稿画面が開く。

javascript:(function(){const e=document.querySelectorAll('.titles_seriesTitle__filL4, .titles_title__KJ7tf, .description_metaDetail__M5hy5, .description_metaDetail__1swXX span, .description_broadcastDateLabel__PjGsI span');let t='';e.forEach((e,n)=>{const o=e.textContent.trim();n==0||n==1||n==2||n==6||n==8?t+=o+%27\n%27:n==3?t+=o+%27 %27:n==4?t+=o+%27\n%27:t+=o}),window.open(%27https://twitter.com/intent/tweet?text=%27+encodeURIComponent(t.trim()+%27\n%27+location.href),%27_blank%27)})();

 

sha-k.hatenablog.com

ストリートビューの今見ている場所を新しいタブで開くブックマークレット(2種)

ストリートビューの仕様はどのボタンを押してマップに戻っても、一体どの場所を見ていたか分からないものになってます。下記のブックマークレットを使うとストリートビューを見ているタブを残したまま新しいタブでマップを表示することができます。

ブックマークレットはブラウザに関係なく使用できます。

 

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

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

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

 

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

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

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

2ストリートビューのページで作成したブックマークをクリックする。

 

ブックマークレット

この場所 (JR東日本川口駅 埼玉県川口市栄町3丁目1)で使った場合

・place表示 ピンが立ち左に地点の詳細が表示された状態

javascript:(function(){var currentUrl = window.location.href; var baseUrl = currentUrl.split('/@')[0] + '/place/'; var newUrl = baseUrl + currentUrl.split('/@')[1].split(',')[0] + ',' + currentUrl.split('/@')[1].split(',')[1]; window.open(newUrl, '_blank');})();

 

・zoom表示 ピンも情報も無く付近を拡大して表示する

javascript:(function(){var url=window.location.href;var index=url.indexOf('@');var endIndex=url.indexOf('h',index);if(index!==-1&&endIndex!==-1){var newUrl=url.substring(0,endIndex+1);window.open(newUrl,'_blank');}})();

 

 

 

sha-k.hatenablog.com

 

 

作ったもの

Chrome拡張機能

ver1公開日 名前 

2024.03.20 X-Twitter_Youtube検索ヘルパー(Chrome ウェブストア)

      TwitterYoutubeをポップアップから検索する

2024.03.28 TVerクイック検索(Chromeウェブストア)

      TVerをポップアップから検索する

 

ブックマークレット

公開日        記事

2024.04.06  ストリートビューの今見ている場所を新しいタブで開く

2024.04.07  タイムスタンプを取得するブックマークレット

2024.04.08  サイトをリンクタグ<a href=" "></a>で取得する

2024.04.19   YouTubeの情報をコピーする

2024.04.23  NHKプラスにキーワードを入力する


sha-k.hatenablog.com