diff --git a/src/api/plugins.js b/src/api/plugins.js index 8c6d3c7..333ecf8 100644 --- a/src/api/plugins.js +++ b/src/api/plugins.js @@ -201,7 +201,7 @@ intercept( "session/RECEIVED_COUNTRY_CODE", async () => { // We don't attempt to load plugins if CSP exists because loading every plugin will fail and automatically disable the plugin. - if (document.querySelector(`[http-equiv="Content-Security-Policy"]`)) return; + if (document.querySelector(`[http-equiv="Content-Security-Policy"]`) || window.require) return; for (const plugin of pluginStore) { if (plugin.update) { diff --git a/src/index.js b/src/index.js index e577def..7a1a360 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,28 @@ -import { after, instead } from "spitroast"; import "./ui/settings.js"; import "./handleExfiltrations.js"; import windowObject from "./windowObject.js"; +// TODO: Remove this in a future update. +if (window.require) { + (async () => { + const fs = require("fs"); + const path = require("path"); + + const indexFetch = await fetch( + "https://raw.githubusercontent.com/uwu/neptune/master/injector/index.js", + ); + const preloadFetch = await fetch( + "https://raw.githubusercontent.com/uwu/neptune/master/injector/preload.js", + ); + if (!(indexFetch.ok || preloadFetch.ok)) return; + + fs.writeFileSync(path.join(process.resourcesPath, "app", "index.js"), await indexFetch.text()); + fs.writeFileSync(path.join(process.resourcesPath, "app", "preload.js"), await preloadFetch.text()); + + alert("neptune has been updated. Please restart TIDAL."); + })() +} + // Restore the console for (let key in console) { const orig = console[key]; @@ -30,22 +50,6 @@ Object.defineProperty = function (...args) { Object.freeze = (arg) => arg; -// Polyfill node setInterval and setTimeout -const delayHandler = (_, resp) => { - return { - id: resp, - unref() {}, - }; -}; - -const clearDelayHandler = ([id], orig) => orig(id?.id ?? id); - -after("setInterval", window, delayHandler); -after("setTimeout", window, delayHandler); - -instead("clearInterval", window, clearDelayHandler); -instead("clearTimeout", window, clearDelayHandler); - // If the app fails to load for any reason we simply reload the page. setTimeout(() => { if (!windowObject.store) window.location.reload();