Skip to content

Commit

Permalink
Revert "Modification to fix issue #1516"
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube authored Feb 27, 2023
1 parent db87002 commit dc56797
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
34 changes: 19 additions & 15 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
11 changes: 8 additions & 3 deletions content-scripts/extension-context/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 () {
Expand Down
3 changes: 0 additions & 3 deletions content-scripts/website-context/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
});

/*--------------------------------------------------------------
Expand Down
10 changes: 6 additions & 4 deletions content-scripts/website-context/youtube-features/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit dc56797

Please sign in to comment.