This commit is contained in:
Bruno Rybársky 2023-10-26 17:07:11 +02:00
parent 60b448e876
commit 8361254d00

@ -1,7 +1,7 @@
// ==UserScript==
// @name Edupage H4x
// @namespace https://brn.systems
// @version 0.2.26
// @version 0.2.27
// @copyright Can be found at https://git.brn.systems/BRNSystems/Userscripts
// @description Gives you a bit more options on EduPage, some are broken
// @author BRNSystems
@ -219,151 +219,20 @@
if (typeof unsafeWindow.barEncLink === 'function') {
unsafeWindow.barEncLink = modifiedbarEncLink;
//unsafeWindow.AscMobileAppVersion = "69420";
unsafeWindow.$j.origPost = $j.post;
$j.post = function (url, data, success, dataType, eqav) {
unsafeWindow.$j.post = function(url, data, success, dataType, eqav) {
if (!eqav) {
eqav = 1;
}
var url0 = url;
var data0 = data;
var success0 = success;
var dataType0 = dataType;
url += (url.indexOf('?') >= 0 ? '&' : '?') + 'eqav=' + eqav + '&maxEqav=' + maxEqav;
var ret;
var wrongData = false;
var doneFunc0 = [];
var failFunc0 = [];
var alwaysFunc0 = [];
if (eqav == maxEqav) {
return $j.origPost(url, data, success, dataType);
} else {
var useZip = isEmptyObject(data);
var cs = '';
var cs0 = '';
if (useZip) {
try {
var encoder = new TextEncoder()
var gz = new Zlib.RawDeflate(encoder.encode(cs));
var compressed = gz.compress();
var cs1 = '';
for (var i = 0; i < compressed.length; i += 10000) {
cs1 += String.fromCharCode.apply(null, compressed.subarray(i, i + 10000));
}
cs0 = 'dz:' + btoa(cs1);
} catch (e) {
cs0 = Base64.encode(cs, true);
}
} else {
cs0 = Base64.encode(cs, true);
}
var obj = {
eqap: cs0,
eqacs: sha1(cs0),
eqaz: '0', // Always set eqaz to '0' for no encryption
}
ret = $j.ajax({
type: "POST",
url: url,
data: obj,
success: function (data, textStatus, jqXHR) {
if (!wrongData && success) {
success(data, textStatus, jqXHR);
}
},
dataType: dataType,
dataFilter: function (data, type) {
if (data.substr(0, 5) == 'eqwd:') {
data = data.substr(5);
wrongData = true;
}
return data;
},
complete: function (jqXHR, status) {
if (wrongData) {
eqav++;
var ret2 = $j.post(url0, data0, success0, dataType0, eqav);
ret2.always(function (p1, p2, p3) {
executeFuncs(alwaysFunc0, p1, p2, p3);
});
ret2.fail(function (p1, p2, p3) {
executeFuncs(failFunc0, p1, p2, p3);
});
ret2.done(function (p1, p2, p3) {
executeFuncs(doneFunc0, p1, p2, p3);
});
}
}
});
}
ret.always0 = ret.always;
ret.fail0 = ret.fail;
ret.done0 = ret.done;
ret.done = function (doneFunc) {
doneFunc0.push(doneFunc);
return ret.done0(function (p1, p2, p3) {
if (!wrongData) {
if (doneFunc) doneFunc(p1, p2, p3);
}
});
}
ret.fail = function (failFunc) {
failFunc0.push(failFunc);
return ret.fail0(function (p1, p2, p3) {
if (!wrongData) {
if (failFunc) failFunc(p1, p2, p3);
}
});
}
ret.always = function (alwaysFunc) {
alwaysFunc0.push(alwaysFunc);
return ret.always0(function (p1, p2, p3) {
if (!wrongData) {
if (alwaysFunc) alwaysFunc(p1, p2, p3);
}
});
};
function executeFuncs(funcs, p1, p2, p3) {
for (var i = 0; i < funcs.length; i++) {
if (funcs[i]) {
funcs[i](p1, p2, p3);
}
if(data && data.length == 0) {
data = {
eqap: "",
eqacs: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
eqaz: 0,
}
}
return ret;
url += (url.indexOf('?') >= 0 ? '&' : '?')+'eqav='+eqav+'&maxEqav='+unsafeWindow.maxEqav;
return $j.origPost(url, data, success, dataType);
};
// Function to check if an object is empty
function isEmptyObject(obj) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
return false;
}
}
return true;
}
//MobileAppBridge.isActive = function() {
// return false;
//}