修复MAC下xm音乐滑块验证问题

pull/453/head
lyswhut 2021-01-30 14:29:20 +08:00
parent 9e37800426
commit 316f62c3c8
2 changed files with 32 additions and 17 deletions

View File

@ -1,3 +1,4 @@
### 修复
- 修复非透明模式下右侧滚动条无法拖动的问题
- 修复MAC下xm音乐滑块验证问题

View File

@ -27,12 +27,12 @@ mainHandle(ipcMainWindowNames.handle_xm_verify_open, (event, url) => new Promise
const windowSizeInfo = getWindowSizeInfo(global.appSetting)
win = new BrowserWindow({
parent: global.modules.mainWindow,
width: 460,
height: 370,
width: 1000,
height: 800,
resizable: false,
// transparent: true,
x: mainWindowSizeInfo.x + (windowSizeInfo.width - 460) / 2,
y: mainWindowSizeInfo.y + (windowSizeInfo.height - 320 + 52) / 2,
x: mainWindowSizeInfo.x + (windowSizeInfo.width - 1000) / 2,
y: mainWindowSizeInfo.y + (windowSizeInfo.height - 800 + 52) / 2,
minimizable: false,
maximizable: false,
// movable: false,
@ -43,20 +43,34 @@ mainHandle(ipcMainWindowNames.handle_xm_verify_open, (event, url) => new Promise
disableHtmlFullscreenWindowResize: true,
},
})
win.webContents.on('did-finish-load', () => {
if (/punish\?/.test(win.webContents.getURL())) return
let ses = win.webContents.session
ses.cookies.get({ name: 'x5sec' })
.then(async([x5sec]) => {
// win.webContents.on('did-finish-load', () => {
// if (/punish\?/.test(win.webContents.getURL())) return
// let ses = win.webContents.session
// ses.cookies.get({ name: 'x5sec' })
// .then(async([x5sec]) => {
// isActioned = true
// await closeWin()
// if (!x5sec) return reject(new Error('get x5sec failed'))
// resolve(x5sec.value)
// }).catch(async err => {
// isActioned = true
// await closeWin()
// reject(err)
// })
// })
win.webContents.session.webRequest.onCompleted({ urls: ['*://www.xiami.com/*'] }, details => {
if (/\/_____tmd_____\/slide\?/.test(details.url)) {
for (const item of details.responseHeaders['set-cookie']) {
if (!/^x5sec=/.test(item)) continue
const x5sec = /x5sec=(\w+);.+$/.exec(item)
isActioned = true
await closeWin()
if (!x5sec) return reject(new Error('get x5sec failed'))
resolve(x5sec.value)
}).catch(async err => {
isActioned = true
await closeWin()
reject(err)
})
closeWin().finally(() => {
if (!x5sec) return reject(new Error('get x5sec failed'))
resolve(x5sec[1])
})
}
}
})
win.webContents.loadURL(url, {