diff --git a/background.js b/background.js index e3669d451..140e143a9 100644 --- a/background.js +++ b/background.js @@ -196,21 +196,25 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { if (action === "play") { chrome.tabs.query({}, function (tabs) { if (tabs.length > prevTabsLength) { - prevTabsLength++; - } else if (tabs.length < prevTabsLength){ - prevTabsLength--; - }else{ - for (var i = 0, l = tabs.length; i < l; i++) { - prevTabsLength = tabs.length; - var tab = tabs[i]; - - if (sender.tab.id !== tab.id) { - chrome.tabs.sendMessage(tab.id, { - action: "another-video-started-playing", - }); - } - } - } + prevTabsLength = tabs.length; + for (var i = 0, l = tabs.length; i < l; i++) { + var tab = tabs[i]; + chrome.tabs.sendMessage(tab.id, { + action: "new-tab-opened", + }); + } + } else { + prevTabsLength = tabs.length; + } + for (var i = 0, l = tabs.length; i < l; i++) { + var tab = tabs[i]; + + if (sender.tab.id !== tab.id) { + chrome.tabs.sendMessage(tab.id, { + action: "another-video-started-playing", + }); + } + } }); } else if (action === 'options-page-connected') { sendResponse({ diff --git a/content-scripts/extension-context/init.js b/content-scripts/extension-context/init.js index 87d2e8bd8..051a0e4c1 100644 --- a/content-scripts/extension-context/init.js +++ b/content-scripts/extension-context/init.js @@ -80,7 +80,7 @@ document.addEventListener('DOMContentLoaded', function () { bodyReady(); }); - +let prevRequestAction = ""; chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { if (request.action === 'focus') { extension.messages.send({ @@ -112,11 +112,16 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { extension.messages.send({ deleteCookies: true }); - } else if (request.action === "another-video-started-playing") { + } else if ( + request.action === "another-video-started-playing" && + prevRequestAction === "new-tab-opened" + ) { + console.log("Continue playing"); + } else if (request.action === "another-video-started-playing") { extension.features.onlyOnePlayerInstancePlaying(); } - + prevRequestAction = request.action; }); document.addEventListener('it-message-from-youtube', function () { diff --git a/content-scripts/website-context/core.js b/content-scripts/website-context/core.js index 06b0ab75d..32032de58 100644 --- a/content-scripts/website-context/core.js +++ b/content-scripts/website-context/core.js @@ -183,9 +183,6 @@ document.addEventListener('it-message-from-extension', function () { } } } - if(ImprovedTube.storage.only_one_player_instance_playing === true){ - ImprovedTube.storage = {...ImprovedTube.storage, player_autoplay: false, playlist_autoplay: false} - } }); /*-------------------------------------------------------------- diff --git a/content-scripts/website-context/youtube-features/appearance.js b/content-scripts/website-context/youtube-features/appearance.js index 7c19a05d7..c1967bd29 100644 --- a/content-scripts/website-context/youtube-features/appearance.js +++ b/content-scripts/website-context/youtube-features/appearance.js @@ -286,13 +286,15 @@ ImprovedTube.channelVideosCount = function () { ImprovedTube.description = function (el) { if (this.storage.description === "expanded") { - document.querySelector("#more").click(); - }else if (this.storage.description === "normal") { - document.querySelector("#less").click(); + el.click(); } }; -/*------------------ailButton = function (el) { +/*------------------------------------------------------------------------------ +4.2.3.4 HIDE DETAIL BUTTON +------------------------------------------------------------------------------*/ + +ImprovedTube.hideDetailButton = function (el) { setTimeout(function () { for (var i = 2; i < el.length; i++) { tmp = el[i].querySelector("g.yt-icon path").attributes.d.textContent.split(" ")[0];