Skip to content

Instantly share code, notes, and snippets.

@ayunami2000
Last active August 17, 2022 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayunami2000/53953b5ebdeedf84e9581016840c6c2e to your computer and use it in GitHub Desktop.
Save ayunami2000/53953b5ebdeedf84e9581016840c6c2e to your computer and use it in GitHub Desktop.
Eaglercraft Client Music hijacker script (by ayunami2000) (in index.html, change "classes.js" to "eagler_music_hack.js", then change '"load"' to '"hack"')
window.music = (function () {
let audio = new Audio();
audio.volume = 0.25;
let songs = [ "CW6CMFPAsF4", "gz1xq2qJnHs", "RUEWIG8zoa0", "n02zTn2d3rY", "FoFqBB0r9OI", "Ugb7GUtiyZ0", "3UFyc7zN9KY", "V6N_rL4fh6I", "iBZS6ad3Tlk", "Mnb2RhXL-nM", "lidx_2d4YOA", "ETQJZHYlc3g", "kRpRoTaNni0", "ACy5tHoNUoA", "OKoA2ppQMkw", "-jcOtAuGZC4", "-cJFVNZC4h8", "yLFX_7SH2tY", "oP6wOte3wZU", "MT7ssDlcN_c", "dOu3APclRkU", "CElWZz_oCsA", "8wr8eqro_OI", "OlLUtndzw7A", "HBYS5mBHie4", "5HxGK3DTUBQ", "_9qUu8IeabE", "QaRbalghKl4", "PtjgNhXWr2U", "OqJi_n3AcV4", "WFFF-jMyFaQ", "FD56t_0B9ig", "x6EATApss4k", "vLv3r1jtnmc", "VLbMXG8lvjI", "-5h9Q5PMHkw", "M0opHPn2bSQ", "XbuqB3uB6DI", "ZCJo8CDyqlQ", "A1-fM0s1Yt0", "zfKvnd-f4fA", "zsLT3JqfTn0", "YZlclPLX1Hw", "AYdyRPIo4ZA", "loeGmoYr3s4", "0qhoqXTUQlY", "7KtwWWJqDrM", "uIk_jGypR24", "G9z_DmhSKjM", "IFWYSOsAuL8", "DhUieLpc16A", "b9W22zhQdkA", "lpm7-aEXD7I", "YIp1S0VfJVI", "BSC6d81pvwE", "aZlOBCXgIVg", "sG2yDNSSwaY", "RiVZCDq--m4", "-NXEcmszXzQ", "N2SW_MWBa6w", "2k5dqgNT37g", "T0cGZD15UaA", "6qTBIAkd8ns", "2_GUQC4nCl8", "9LlH78J_3bc", "9Ty-qFZZPZk", "6EDS01Ipaow", "R3rzdj_aP3U", "3Ax6jTZlu_g", "8GW6sLrK40k", "mfegGiVUk58", "mLmFpLivDRE", "GOQEOkPsdcM", "a4LZg9vIGT0", "720HcvEvEC8", "2GBsmmzm2j0", "YbdcrJZBtu8", "x0qKH1hJePs", "Ub7y69hg4do", "hFal0LKZwnM", "PzJtShkAkwA", "rYHNB_lPSNc", "Mr-wV17WFZU", "sVnRScxzPlA", "MATIBHTbLkw", "8DrtpB5Me6s", "EdFyQOngYJs", "3RyqONKuRzk", "jBPqr_IsWvY", "f6dnBVhH8AY", "dAalyaoVGfE", "DYRvdzUJMr0", "qFjaDnnPbA4", "RM9O1HO4FLE", "NrlhbIzjO04", "F6NNMAoBMS4", "UqVW7-q7fTA", "eDBAdAzCqr4", "EPT3dIWBbDA", "FuMtDXkuxVw", "PkmKM_OXNZM", "KbC46oJmLh4", "8HW9fyQdib4", "mRJSIYmHuNI", "GmLsIivtcIM", "rDBbaGCCIhk", "EyicJOlYOm4", "BDIG46sPKCs", "Ig5v4jhLLWI", "XZcG2esvW7I", "TTJBevUIp0s", "agIayif-oi0", "plm3DVsX7Jg", "yP7dvyK5OiY", "HA0Mk5BXX44", "HbtwR1REaFk", "-tUJJXWXdXk", "h-b8Xs7sNI0", "eyp-YuzhTN4", "xrawoRF4lN0", "6xVHpgJbuc8", "IdeMjEYeH_M", "mLFfI13jfeE", "fYSUV33ZPfw", "qnSHJlRJ2cM", "Ytt1_ErIV34", "_DBfb0-A6T0", "05TnpE0x4wI", "px-UnYP1smo", "dRAKbbYlTcI", "MYC5k-EvYyI", "GCkyGVsIcF0", "Qg83cniiYEY", "F7gwcgmoREg", "3I-WJ6UgmOA", "RakcYpzOI8A", "Tx0dUDrh_hE", "uRdnCC5kACY", "phrpiLpaiLs", "sLwHrqW-x4w", "wf93JAZR3gU", "7tBQFpFyZiI", "zz3F5j8qWNw", "Q7miO-Q-4bU", "j5FcOo48HpE", "CQLvggJFxuM", "_Ci0Kgdpgsw", "XYXUi4bn1pQ", "iBjZshhpipg", "-yXzE7undI4", "zEf46ulVSL0", "UBIsi3xWa64", "GWYkh1IX4PE", "n1hChZS9Hew", "YYjDFXJ6Wdo", "qOVxQ_yEYks", "9zibDnOOj3w", "rQMd3b1BF50", "xeM40-FkRLI", "wVOFnTrSOOA", "msUarvc4Sx8", "GB9kBLre96M", "p_wcC1l1cLk", "zKavYMyPveI", "YZ3no2EK58Y", "SLFMiEAjSoA", "K5F-RLzLH6Q", "A09BhpgfGKQ", "ziAK1OLeeEE", "7Vj-xVb0DWI", "33zGN7vENog", "zD8TxUBkjGA", "m0zPkt5BZ9I", "xktxgo7b8HQ", "jMSiM6iZpwk", "zeTIG5lwDyM", "CUHYQ-FN3P8", "GLGjqtgCKY8", "bLagC2wX3Ak", "fW128GHFJIE", "B5L0AMO2HA8", "oFFFzMkGNrk", "1RQQLwnaw80", "byUipqLQ_Hc", "_Rjh6zVEPH4", "R9z5CoO7Qxo", "neEq14x7mTU", "pkkIqT9LpDY", "BLRk8D7ovDY", "gMGEyl5TRa4" ];
let insturl = "https://invidious.zapashcanon.fr";
let loading = false;
let usealt = 0;
function shuffle (array) {
for (let i = 0; i < array.length; i++) {
let j = Math.floor(Math.random() * (array.length-i)) + i;
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
function fixfard (url) {
if (!url) return insturl;
return url.endsWith("/") ? url.slice(0, url.length - 1) : url;
}
const updinsturl = async () => {
try {
const json = await (await fetch("https://api.invidious.io/instances.json?sort_by=health")).json();
const out = shuffle(json).map(entry => {
const healthKnown = !!entry[1].monitor
return {
name: entry[0],
details: entry[1],
health: +(healthKnown ? entry[1].monitor.dailyRatios[0].ratio : 95),
healthKnown
}
}).filter(entry => {
return entry.details.type === "https" && entry.health > 0
}).sort((a, b) => {
return b.health - a.health
});
insturl = fixfard(out.find(e => e.details.cors).details.uri);
} catch (e) { aud.onerror(); }
};
const updint = setInterval(updinsturl, 3600000);
updinsturl();
audio.onended = function (e) {
loading = true;
start();
};
audio.oncanplay = function (e) {
if (loading) audio.play();
};
audio.onplay = function (e) {
loading = false;
if (usealt == 1) usealt = 0;
};
audio.onerror = function (e) {
if (usealt == 3) {
audio = null;
return;
}
if (usealt == 0 || usealt == 1) {
usealt++;
} else if (usealt == 2) {
loading = true;
usealt = 3;
}
stop();
if (usealt == 1) {
updinsturl();
} else {
clearInterval(updint);
}
if (usealt == 1 || usealt == 2) start();
};
const playing = function () {
return usealt == 3 || (!audio.paused) || loading;
};
const start = function() {
loading = true;
let url = "";
if (usealt == 0 || usealt == 1) {
songs = shuffle(songs);
url = insturl + "/latest_version?id=" + songs[0] + "&itag=251";
} else if (usealt == 2) {
url = "https://nightride.fm/stream/chillsynth.m4a";
} else if (usealt == 3) {
return;
}
audio.src = url;
audio.currentTime = 0;
};
const stop = function() {
if (usealt == 3) return;
audio.pause();
loading = false;
};
let started = false;
return {
start: start,
stop: stop,
playing: playing,
gta: function() {
if (!started) {
started = true;
window.music.start();
}
},
gtaIndex: -1
};
})();
window.WebSocket.prototype.oSend = window.WebSocket.prototype.send;
window.WebSocket.prototype.send = function(...a) {
if (this.__MUSIC__hasSentFirstMessage) return this.oSend(...a);
this.__MUSIC__hasSentFirstMessage = true;
if (a != null && a.length > 0 && a[0] != null && a[0] instanceof ArrayBuffer) {
const fard = new Uint8Array(a[0]);
if (fard[0] == 2 && fard[1] == 69) {
this.__MUSIC__matters = true;
window.music.stop();
}
}
return this.oSend(...a);
};
window.WebSocket.prototype.oClose = window.WebSocket.prototype.close;
window.WebSocket.prototype.close = function(...a) {
if (this.__MUSIC__matters && !window.music.playing()) window.music.start();
return this.oClose(...a);
};
navigator.mediaSession.setActionHandler("play", function() {});
navigator.mediaSession.setActionHandler("pause", function() {});
navigator.mediaSession.setActionHandler("seekbackward", function() {});
navigator.mediaSession.setActionHandler("seekforward", function() {});
navigator.mediaSession.setActionHandler("previoustrack", function() {});
navigator.mediaSession.setActionHandler("nexttrack", function() {});
fetch("classes.js").then(a => a.text()).then(d => {
d = d.replace(/function \$rt_stringPool\(strings\) ?{/, "function $rt_stringPool(strings){window.music.gtaIndex=strings.indexOf(\"/sounds/gta.mp3\");strings[window.music.gtaIndex]=\"\";");
d = d.replace(/function \$rt_s\(index\) ?{/, "function $rt_s(index){if(index==window.music.gtaIndex)window.music.gta();");
const xd = document.createElement("SCRIPT");
xd.src = window.URL.createObjectURL(new Blob([ d ], { type: "text/javascript" }));
xd.onload = function() {
window.dispatchEvent(new CustomEvent("hack", { }));
};
document.body.appendChild(xd);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment