Skip to content

Commit

Permalink
feat: add migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
twnlink committed Jun 25, 2024
1 parent bf0e0b8 commit 025e913
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/api/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
38 changes: 21 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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];
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 025e913

Please sign in to comment.