This commit is contained in:
Bruno Rybársky 2023-10-26 17:01:02 +02:00
parent e92e61c784
commit 7c7e0ecfcd

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Edupage H4x // @name Edupage H4x
// @namespace https://brn.systems // @namespace https://brn.systems
// @version 0.2.24 // @version 0.2.25
// @copyright Can be found at https://git.brn.systems/BRNSystems/Userscripts // @copyright Can be found at https://git.brn.systems/BRNSystems/Userscripts
// @description Gives you a bit more options on EduPage, some are broken // @description Gives you a bit more options on EduPage, some are broken
// @author BRNSystems // @author BRNSystems
@ -219,20 +219,161 @@
if (typeof unsafeWindow.barEncLink === 'function') { if (typeof unsafeWindow.barEncLink === 'function') {
unsafeWindow.barEncLink = modifiedbarEncLink; unsafeWindow.barEncLink = modifiedbarEncLink;
//unsafeWindow.AscMobileAppVersion = "69420"; //unsafeWindow.AscMobileAppVersion = "69420";
unsafeWindow.$j.post = function(url, data, success, dataType, eqav) { unsafeWindow.$j.origPost = $j.post;
$j.post = function (url, data, success, dataType, eqav) {
if (!eqav) { if (!eqav) {
eqav = 1; eqav = 1;
} }
if(data && data.length == 0) {
data = { var url0 = url;
eqap: "dz:BcCBCAAAAAAgf+sD", var data0 = data;
eqacs: "16a63ef35cd7438a04662d53a0360ef2fb6c02e6", var success0 = success;
eqaz: 0, var dataType0 = dataType;
}
} url += (url.indexOf('?') >= 0 ? '&' : '?') + 'eqav=' + eqav + '&maxEqav=' + maxEqav;
url += (url.indexOf('?') >= 0 ? '&' : '?')+'eqav='+eqav+'&maxEqav='+unsafeWindow.maxEqav;
var ret;
var wrongData = false;
var doneFunc0 = [];
var failFunc0 = [];
var alwaysFunc0 = [];
if (eqav == maxEqav) {
return $j.origPost(url, data, success, dataType); return $j.origPost(url, data, success, dataType);
} else {
var useZip = eqav % 2 == 1;
var cs = '';
if (typeof data == "function") {
cs = '';
success = data;
} else if (typeof data == 'string') {
cs = data;
} else if (isEmptyObject(data)) {
cs = '';
} else {
cs = $j.param(data);
}
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);
}
}
}
return ret;
};
// 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() { //MobileAppBridge.isActive = function() {
// return false; // return false;
//} //}