mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fixed 'repeatChanged' modes being different depending on selected youtube music language
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ node_modules
|
|||||||
/assets/generated
|
/assets/generated
|
||||||
electron-builder.yml
|
electron-builder.yml
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
|
.idea
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
const { ipcRenderer } = require("electron");
|
const {ipcRenderer} = require("electron");
|
||||||
const is = require('electron-is');
|
const is = require('electron-is');
|
||||||
const { getImage } = require("./song-info");
|
const {getImage} = require("./song-info");
|
||||||
|
|
||||||
const config = require("../config");
|
const config = require("../config");
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ module.exports = () => {
|
|||||||
data.videoDetails.isPaused = false;
|
data.videoDetails.isPaused = false;
|
||||||
ipcRenderer.send("video-src-changed", JSON.stringify(data));
|
ipcRenderer.send("video-src-changed", JSON.stringify(data));
|
||||||
}
|
}
|
||||||
}, { once: true, passive: true });
|
}, {once: true, passive: true});
|
||||||
};
|
};
|
||||||
|
|
||||||
function setupTimeChangeListener() {
|
function setupTimeChangeListener() {
|
||||||
@ -63,17 +63,54 @@ function setupTimeChangeListener() {
|
|||||||
ipcRenderer.send('timeChanged', mutations[0].target.value);
|
ipcRenderer.send('timeChanged', mutations[0].target.value);
|
||||||
global.songInfo.elapsedSeconds = mutations[0].target.value;
|
global.songInfo.elapsedSeconds = mutations[0].target.value;
|
||||||
});
|
});
|
||||||
progressObserver.observe($('#progress-bar'), { attributeFilter: ["value"] })
|
progressObserver.observe($('#progress-bar'), {attributeFilter: ["value"]})
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupRepeatChangeListener() {
|
function setupRepeatChangeListener() {
|
||||||
const repeatObserver = new MutationObserver(mutations => {
|
const repeatObserver = new MutationObserver(mutations => {
|
||||||
ipcRenderer.send('repeatChanged', mutations[0].target.title);
|
document.cookie.split(';').forEach((cookie) => {
|
||||||
|
let cookieName = cookie.substring(0, cookie.indexOf("=")).replaceAll(" ", "");
|
||||||
|
if (cookieName === 'PREF') {
|
||||||
|
let value = cookie.replace(cookieName + "=", "").replaceAll(" ", "");
|
||||||
|
value.split('&').forEach((pair) => {
|
||||||
|
if (pair !== '') {
|
||||||
|
let splitpair = pair.split('=');
|
||||||
|
if (splitpair[0] === "repeat") {
|
||||||
|
if (splitpair[1] === "NONE")
|
||||||
|
ipcRenderer.send('repeatChanged', "Repeat off");
|
||||||
|
else if (splitpair[1] === "ONE") //MPRIS Playlist and Track Codes are switched to look the same as yt-music icons
|
||||||
|
ipcRenderer.send('repeatChanged', "Repeat one");
|
||||||
|
else if (splitpair[1] === "ALL")
|
||||||
|
ipcRenderer.send('repeatChanged', "Repeat all");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
repeatObserver.observe($('#right-controls .repeat'), { attributeFilter: ["title"] });
|
repeatObserver.observe($('#right-controls .repeat'), {attributeFilter: ["title"]});
|
||||||
|
|
||||||
// Emit the initial value as well; as it's persistent between launches.
|
// Emit the initial value as well; as it's persistent between launches.
|
||||||
ipcRenderer.send('repeatChanged', $('#right-controls .repeat').title);
|
// ipcRenderer.send('repeatChanged', $('#right-controls .repeat').title);
|
||||||
|
document.cookie.split(';').forEach((cookie) => {
|
||||||
|
let cookieName = cookie.substring(0, cookie.indexOf("=")).replaceAll(" ", "");
|
||||||
|
if (cookieName === 'PREF') {
|
||||||
|
let value = cookie.replace(cookieName + "=", "").replaceAll(" ", "");
|
||||||
|
value.split('&').forEach((pair) => {
|
||||||
|
if (pair !== '') {
|
||||||
|
let splitpair = pair.split('=');
|
||||||
|
if (splitpair[0] === "repeat") {
|
||||||
|
if (splitpair[1] === "NONE")
|
||||||
|
ipcRenderer.send('repeatChanged', "Repeat off");
|
||||||
|
else if (splitpair[1] === "ONE") //MPRIS Playlist and Track Codes are switched to look the same as yt-music icons
|
||||||
|
ipcRenderer.send('repeatChanged', "Repeat one");
|
||||||
|
else if (splitpair[1] === "ALL")
|
||||||
|
ipcRenderer.send('repeatChanged', "Repeat all");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupVolumeChangeListener(api) {
|
function setupVolumeChangeListener(api) {
|
||||||
|
|||||||
Reference in New Issue
Block a user