Improved songinfo provider, by using the data from the '/player' request

This commit is contained in:
Sem Visscher
2021-03-18 17:48:56 +01:00
parent c5bda4f3be
commit d852029d25
4 changed files with 52 additions and 77 deletions

View File

@ -0,0 +1,21 @@
const { ipcRenderer } = require("electron");
const injectListener = () => {
var oldXHR = window.XMLHttpRequest;
function newXHR() {
var realXHR = new oldXHR();
realXHR.addEventListener("readystatechange", function() {
if(realXHR.readyState==4 && realXHR.status==200){
if (realXHR.responseURL.includes('/player'))
// if the request is the contains the song info send the response to ipcMain
ipcRenderer.send(
"song-info-request",
realXHR.responseText
);
}
}, false);
return realXHR;
}
window.XMLHttpRequest = newXHR;
}
module.exports = injectListener