diff --git a/.gitignore b/.gitignore index 0c735597..1850e4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ package-lock.json .DS_Store yarn-error.log .yarnclean +auth.json diff --git a/index.js b/index.js index 4c821223..feb9e087 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,6 @@ const {app} = require('electron'); // Creating the Application Window and Calling all the Functions function CreateWindow() { if (app.isQuiting) { app.quit(); return; } - /** CIDER **/ const ciderwin = require("./resources/functions/cider-base") app.win = ciderwin @@ -19,7 +18,6 @@ function CreateWindow() { app.on('ready', () => { if (app.isQuiting) { app.quit(); return; } - console.log('[Cider] Application is Ready. Creating Window.') CreateWindow() }); diff --git a/resources/cider-ui-tests/index.js b/resources/cider-ui-tests/index.js index 05baad45..b1fffeaf 100644 --- a/resources/cider-ui-tests/index.js +++ b/resources/cider-ui-tests/index.js @@ -830,26 +830,23 @@ const app = new Vue({ document.addEventListener('musickitloaded', function () { // MusicKit global is now defined - fetch("https://beta.music.apple.com/", {mode: "no-cors"}) - .then(response => response.text()) - .then(data => { - var el = document.createElement("html"); - el.innerHTML = data; - var u = el.querySelector(`[name="desktop-music-app/config/environment"]`) - var amwebCFG = JSON.parse(decodeURIComponent(u.getAttribute("content"))); - console.log(amwebCFG.MEDIA_API.token) - MusicKit.configure({ - developerToken: amwebCFG.MEDIA_API.token, - app: { - name: 'My Cool Web App', - build: '1978.4.1' - } - }); - setTimeout(() => { - app.init() - }, 1000) + function initMusicKit () { + let parsedJson = JSON.parse(this.responseText) + MusicKit.configure({ + developerToken: parsedJson.Key, + app: { + name: 'My Cool Web App', + build: '1978.4.1' + } }); - + setTimeout(() => { + app.init() + }, 1000) + } + const request = new XMLHttpRequest(); + request.addEventListener("load", initMusicKit); + request.open("GET", "https://devkey.cider.sh/"); + request.send(); }); function xmlToJson(xml) { diff --git a/resources/functions/cider-base.js b/resources/functions/cider-base.js index 05bb91bb..b8d5ddb8 100644 --- a/resources/functions/cider-base.js +++ b/resources/functions/cider-base.js @@ -4,6 +4,8 @@ const getPort = require("get-port"); const express = require("express"); const path = require("path"); const windowStateKeeper = require("electron-window-state"); +const request = require('request'); +const authFile = require("../auth.json"); const CiderBase = { @@ -105,7 +107,6 @@ const CiderBase = { } }) } - return win }, async InitWebServer() { diff --git a/resources/preload/cider-preload.js b/resources/preload/cider-preload.js index 0c1240f1..b8089fc4 100644 --- a/resources/preload/cider-preload.js +++ b/resources/preload/cider-preload.js @@ -1,7 +1,8 @@ const electron = require('electron') -console.log('preload is in baby') +console.log('Loaded Preload') process.once('loaded', () => { + console.log("Setting ipcRenderer") global.ipcRenderer = electron.ipcRenderer; }); \ No newline at end of file