apply workaround for login
This commit is contained in:
parent
ba7999af34
commit
658239ed5f
5 changed files with 170 additions and 14 deletions
|
@ -110,9 +110,9 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"build": {
|
"build": {
|
||||||
"electronVersion": "25.0.0-beta.2",
|
"electronVersion": "24.3.0",
|
||||||
"electronDownload": {
|
"electronDownload": {
|
||||||
"version": "25.0.0-beta.2+wvcus",
|
"version": "24.3.0+wvcus",
|
||||||
"mirror": "https://github.com/castlabs/electron-releases/releases/download/v"
|
"mirror": "https://github.com/castlabs/electron-releases/releases/download/v"
|
||||||
},
|
},
|
||||||
"appId": "cider",
|
"appId": "cider",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { app, BrowserWindow as bw, ipcMain, ShareMenu, shell, screen, dialog, nativeTheme } from "electron";
|
import { app, BrowserWindow as bw, ipcMain, ShareMenu, shell, screen, dialog, nativeTheme, ipcRenderer } from "electron";
|
||||||
import * as windowStateKeeper from "electron-window-state";
|
import * as windowStateKeeper from "electron-window-state";
|
||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import * as getPort from "get-port";
|
import * as getPort from "get-port";
|
||||||
|
@ -1407,6 +1407,144 @@ export class BrowserWindow {
|
||||||
shell.openExternal(String(utils.getStoreValue("cc_authURL")));
|
shell.openExternal(String(utils.getStoreValue("cc_authURL")));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
ipcMain.on("auth-window", (_event) => {
|
||||||
|
AuthWindow(BrowserWindow.win);
|
||||||
|
});
|
||||||
|
|
||||||
|
function AuthWindow(win: bw) {
|
||||||
|
// create a BrowserWindow
|
||||||
|
const authWindow = new bw({
|
||||||
|
width: 500,
|
||||||
|
height: 600,
|
||||||
|
show: false,
|
||||||
|
titleBarOverlay: {
|
||||||
|
color: "#1d1d1f",
|
||||||
|
symbolColor: "#ffffff",
|
||||||
|
},
|
||||||
|
titleBarStyle: "hidden",
|
||||||
|
darkTheme: true,
|
||||||
|
resizable: false,
|
||||||
|
webPreferences: {
|
||||||
|
contextIsolation: false,
|
||||||
|
nodeIntegration: true,
|
||||||
|
sandbox: true,
|
||||||
|
allowRunningInsecureContent: true,
|
||||||
|
webSecurity: false,
|
||||||
|
preload: join(utils.getPath("srcPath"), "./preload/cider-preload.js"),
|
||||||
|
nodeIntegrationInWorker: false,
|
||||||
|
experimentalFeatures: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// authWindow.webContents.openDevTools();
|
||||||
|
// remove all local storage data
|
||||||
|
authWindow.webContents.session.clearStorageData();
|
||||||
|
|
||||||
|
// set user agent
|
||||||
|
authWindow.webContents.setUserAgent(`Mozilla/5.0 (Macintosh; Intel Mac OS X 13_3_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15`);
|
||||||
|
|
||||||
|
// show the window
|
||||||
|
authWindow.loadURL("https://beta.music.apple.com/");
|
||||||
|
const cookieKeys = ["itspod", "pltvcid", "pldfltcid", "itua", "media-user-token", "acn1", "dslang"];
|
||||||
|
|
||||||
|
ipcMain.on("auth-window-ready", async (_event) => {
|
||||||
|
authWindow.show();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on("auth-completed", async (_event) => {
|
||||||
|
const cookies = await getCookies();
|
||||||
|
console.log("cookies", cookies);
|
||||||
|
win.webContents.send("recv-cookies", cookies);
|
||||||
|
authWindow.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
const overlayStyling = `
|
||||||
|
.hehehe {
|
||||||
|
position: fixed;
|
||||||
|
top:0;
|
||||||
|
left:0;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
background: #1d1d1f;
|
||||||
|
z-index: 99999;
|
||||||
|
}
|
||||||
|
.titlebar {
|
||||||
|
height: 30px;
|
||||||
|
position: fixed;
|
||||||
|
top:0;
|
||||||
|
left:0;
|
||||||
|
right:0;
|
||||||
|
-webkit-app-region: drag;
|
||||||
|
z-index: 99999;
|
||||||
|
}`;
|
||||||
|
|
||||||
|
// on content loaded
|
||||||
|
authWindow.webContents.on("did-finish-load", () => {
|
||||||
|
authWindow.webContents.executeJavaScript(`
|
||||||
|
let tOut = setInterval(async ()=>{
|
||||||
|
try {
|
||||||
|
if(typeof MusicKit === 'undefined') return;
|
||||||
|
MusicKit.getInstance().addEventListener(MusicKit.Events.authorizationStatusDidChange, ()=>{
|
||||||
|
if(MusicKit.getInstance().isAuthorized) {
|
||||||
|
ipcRenderer.send('auth-completed')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
clearInterval(tOut)
|
||||||
|
}catch(e) {}
|
||||||
|
}, 500)
|
||||||
|
let tOut2 = setInterval(()=>{
|
||||||
|
try {
|
||||||
|
const el = document.querySelector('.signin')
|
||||||
|
if(el) {
|
||||||
|
el.click()
|
||||||
|
ipcRenderer.send('auth-window-ready')
|
||||||
|
clearInterval(tOut2)
|
||||||
|
}
|
||||||
|
}catch(e) {}
|
||||||
|
}, 500)
|
||||||
|
let styling = \`${overlayStyling}\`;
|
||||||
|
(()=>{
|
||||||
|
const titleBarEl = document.createElement('div')
|
||||||
|
const overlayEl = document.createElement('div')
|
||||||
|
titleBarEl.classList.add('titlebar')
|
||||||
|
overlayEl.classList.add('hehehe')
|
||||||
|
const styleTag = document.createElement('style')
|
||||||
|
styleTag.innerHTML = styling
|
||||||
|
document.head.appendChild(styleTag)
|
||||||
|
document.body.appendChild(overlayEl)
|
||||||
|
document.body.appendChild(titleBarEl)
|
||||||
|
})()
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function getCookies(): Promise<{ [key: string]: string }> {
|
||||||
|
return new Promise((res, rej) => {
|
||||||
|
authWindow.webContents.session.cookies
|
||||||
|
.get({})
|
||||||
|
.then((cookies) => {
|
||||||
|
// for each cookie
|
||||||
|
const toRenderer: {
|
||||||
|
[key: string]: string;
|
||||||
|
} = {};
|
||||||
|
for (let i = 0; i < cookieKeys.length; i++) {
|
||||||
|
const key = cookieKeys[i];
|
||||||
|
// find the cookie
|
||||||
|
const cookie = cookies.find((cookie) => cookie.name === key);
|
||||||
|
// if cookie exists
|
||||||
|
if (cookie) {
|
||||||
|
toRenderer[`music.ampwebplay.${cookie.name}`] = cookie.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res(toRenderer);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
rej();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ipcMain.on("cc-logout", (_event) => {
|
ipcMain.on("cc-logout", (_event) => {
|
||||||
//Make sure to update the default store
|
//Make sure to update the default store
|
||||||
utils.setStoreValue("connectUser", {
|
utils.setStoreValue("connectUser", {
|
||||||
|
|
|
@ -352,6 +352,16 @@ const app = new Vue({
|
||||||
document.body.removeAttribute("loading");
|
document.body.removeAttribute("loading");
|
||||||
ipcRenderer.invoke("renderer-ready", true);
|
ipcRenderer.invoke("renderer-ready", true);
|
||||||
document.querySelector("#LOADER").remove();
|
document.querySelector("#LOADER").remove();
|
||||||
|
|
||||||
|
ipcRenderer.on("recv-cookies", function (_event, cookies) {
|
||||||
|
console.log('[appIPC] recv-cookies');
|
||||||
|
Object.keys(cookies).forEach((key) => {
|
||||||
|
localStorage.setItem(key, cookies[key]);
|
||||||
|
});
|
||||||
|
localStorage.setItem("seenOOBE", 1);
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
getAppStyle() {
|
getAppStyle() {
|
||||||
let finalStyle = {};
|
let finalStyle = {};
|
||||||
|
@ -400,7 +410,7 @@ const app = new Vue({
|
||||||
if (val) {
|
if (val) {
|
||||||
this.mk.isAuthorized ? (this.chrome.menuOpened = !this.chrome.menuOpened) : false;
|
this.mk.isAuthorized ? (this.chrome.menuOpened = !this.chrome.menuOpened) : false;
|
||||||
if (!this.mk.isAuthorized) {
|
if (!this.mk.isAuthorized) {
|
||||||
this.mk.authorize();
|
ipcRenderer.send("auth-window")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -830,17 +840,23 @@ const app = new Vue({
|
||||||
this.chrome.nativeControls = true;
|
this.chrome.nativeControls = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.setLz(this.cfg.general.language);
|
this.setLz(this.cfg.general.language);
|
||||||
this.setLzManual();
|
this.setLzManual();
|
||||||
clearTimeout(this.hangtimer);
|
clearTimeout(this.hangtimer);
|
||||||
this.mk = MusicKit.getInstance();
|
this.mk = MusicKit.getInstance();
|
||||||
let needsReload = typeof localStorage["music.ampwebplay.media-user-token"] == "undefined";
|
let needsReload = typeof localStorage["music.ampwebplay.media-user-token"] == "undefined";
|
||||||
this.mk.authorize().then(() => {
|
if(needsReload) {
|
||||||
self.mkIsReady = true;
|
ipcRenderer.send("auth-window");
|
||||||
if (needsReload) {
|
this.mkIsReady = true;
|
||||||
document.location.reload();
|
}
|
||||||
}
|
// this.mk.authorize().then(() => {
|
||||||
});
|
// self.mkIsReady = true;
|
||||||
|
// if (needsReload) {
|
||||||
|
// document.location.reload();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
if (this.isDev) {
|
if (this.isDev) {
|
||||||
this.mk.privateEnabled = true;
|
this.mk.privateEnabled = true;
|
||||||
|
@ -1075,6 +1091,7 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
this.mk.addEventListener(MusicKit.Events.playbackStateDidChange, (event) => {
|
this.mk.addEventListener(MusicKit.Events.playbackStateDidChange, (event) => {
|
||||||
ipcRenderer.send("wsapi-updatePlaybackState", wsapi.getAttributes());
|
ipcRenderer.send("wsapi-updatePlaybackState", wsapi.getAttributes());
|
||||||
document.body.setAttribute("playback-state", event.state == 2 ? "playing" : "paused");
|
document.body.setAttribute("playback-state", event.state == 2 ? "playing" : "paused");
|
||||||
|
|
|
@ -183,8 +183,9 @@
|
||||||
localStorage.setItem("seenOOBE", 1)
|
localStorage.setItem("seenOOBE", 1)
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
this.screen = "signin"
|
this.screen = "signin";
|
||||||
capiInit()
|
capiInit();
|
||||||
|
|
||||||
},
|
},
|
||||||
getLz() {
|
getLz() {
|
||||||
return this.$root.getLz.apply(this.$root, arguments);
|
return this.$root.getLz.apply(this.$root, arguments);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"electronVersion": "21.3.3",
|
"electronVersion": "24.3.0",
|
||||||
"electronDownload": {
|
"electronDownload": {
|
||||||
"version": "21.3.3+wvcus",
|
"version": "24.3.0+wvcus",
|
||||||
"mirror": "https://github.com/castlabs/electron-releases/releases/download/v"
|
"mirror": "https://github.com/castlabs/electron-releases/releases/download/v"
|
||||||
},
|
},
|
||||||
"appId": "cider",
|
"appId": "cider",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue