Skip to content

Commit

Permalink
fix move and share
Browse files Browse the repository at this point in the history
  • Loading branch information
kota-shiokara committed Jan 14, 2021
1 parent 68e8aba commit d24c9dc
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Y2M/y2m.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
chrome.browserAction.onClicked.addListener(
function(tab){
function (tab) {
var yturl = tab.url;
console.log(tab.url);
if(yturl.indexOf('www.youtube.com/watch') != -1){
if (yturl.indexOf('www.youtube.com/watch') != -1) {
// Youtubeでの処理
var result = yturl.substring(yturl.indexOf('watch'));
if(result.indexOf('&') != -1) result = result.substring(0, result.indexOf('&'));
if (result.indexOf('&') != -1) result = result.substring(0, result.indexOf('&'));

window.open("https://music.youtube.com/" + result);
}else if(yturl.indexOf('music.youtube.com/watch') != -1){
} else if (yturl.indexOf('music.youtube.com/watch') != -1) {
// Youtube Musicでの処理
if(confirm("共有しますか")){
if (confirm("共有しますか")) {
var tweetText = tab.title;
tweetText = tweetText.substring(0, tweetText.indexOf("- YouTube Music"));

var result = yturl.substring(yturl.indexOf('watch'));
if(result.indexOf('&') != -1) result = result.substring(0, result.indexOf('&'));
if (result.indexOf('&') != -1) result = result.substring(0, result.indexOf('&'));

var tweetUrl = "https://youtube.com/" + result;

window.open("https://twitter.com/intent/tweet?text=" + tweetText + "&url=" + tweetUrl + "&via=YouTube");
}else{
var result = yturl.substring(yturl.indexOf('watch'));
if(result.indexOf('&') != -1) result = result.substring(0, result.indexOf('&'));

window.open("https://youtube.com/" + result);
} else {
if (confirm("YouTubeに移動しますか")) {
var result = yturl.substring(yturl.indexOf('watch'));
if (result.indexOf('&') != -1) result = result.substring(0, result.indexOf('&'));

window.open("https://youtube.com/" + result);
}
}
}else{
} else {
alert("Move failed to youtube music");
}
}
Expand Down

0 comments on commit d24c9dc

Please sign in to comment.