Userscripts/edupage.user.js
2023-10-26 17:05:15 +02:00

392 lines
15 KiB
JavaScript

// ==UserScript==
// @name Edupage H4x
// @namespace https://brn.systems
// @version 0.2.26
// @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
// @website https://brn.systems
// @downloadURL https://userscripts.brn.systems/edupage.user.js
// @updateURL https://userscripts.brn.systems/edupage.user.js
// @match https://*.edupage.org/*
// @icon64 https://www.google.com/s2/favicons?sz=64&domain=edupage.org
// @icon https://www.google.com/s2/favicons?sz=32&domain=edupage.org
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM.getValue
// @grant GM.setValue
// @grant GM_registerMenuCommand
// @grant GM.registerMenuCommand
// ==/UserScript==
( function() {
'use strict';
let gmc = new GM_config(
{
id: 'edupage_h4x_cnf',
title: GM_info.script.name + ' Settings',
fields: {
modify_startbutton: {
label: 'Hides the intro button',
type: 'checkbox',
default: false,
title: 'Hides the intro button'
},
modify_adult_student: {
label: 'Fake adult student',
type: 'checkbox',
default: false,
title: 'Fakes you as an adult student(you might be able to sign your own grades)'
},
modify_agent: {
label: 'Fake mobile app',
type: 'checkbox',
default: false,
title: 'Fakes you as an adult student(you might be able to sign your own grades)'
},
modify_admin_stuff: {
label: 'Fake admin',
type: 'checkbox',
default: false,
title: 'Fakes isUcitelOrAdmin, isAdmin, getLoggedUserType, hasUserRight, isWebpageAdmin. Some functionality still does not work(Server protection)'
},
modify_restricted: {
label: 'Fake not restricted',
type: 'checkbox',
default: false,
title: 'Fakes EduPage as not restricted(I do not know what this does)'
},
modify_logged_in: {
label: 'Fake logged in',
type: 'checkbox',
default: false,
title: 'Fakes EduPage portal logged in(I do not know what this does)'
},
modify_strings: {
label: 'Patch strings',
type: 'checkbox',
default: false,
title: 'Patch strings to more cool ones'
},
modify_encoding: {
label: 'Disable encoded links',
type: 'checkbox',
default: false,
title: 'Disables ?eqa=gibberish'
},
},
'events': {
'init': oninit
}
});
function custompost(url, data, success, dataType, eqav, oldpost){
oldpost(url, data, success, dataType, unsafeWindow.maxEqav);
}
function oninit(){
GM_registerMenuCommand('Settings', () => {
gmc.open()
})
let removeintrobtn = gmc.get("modify_startbutton");
let fake_adult_student = gmc.get("modify_adult_student");
let fake_admin = gmc.get("modify_admin_stuff");
let fake_not_restricted = gmc.get("modify_restricted");
let fake_logged_in = gmc.get("modify_logged_in");
let disable_encoding = gmc.get("modify_encoding");
let change_strings = gmc.get("modify_strings");
let modify_agent = gmc.get("modify_agent");
let strings = {
3276: "budeme Ťa otravovať za",
3275: "Teraz ťa nebudeme chvíľu otravovať, ale",
3272: "Už kašli na školu, nemá to zmysel a",
3274: "Zabudni na úlohy,",
};
function deleteNotX (jNode) {
jNode.remove ();
}
// Define your modified function
function modifiedGetLoggedUserType() {
// Your custom code here
return 'Admin'; // Override the return value as needed
}
function justtrue(){
return true;
}
function justfalse(){
return false;
}
function modifiedbarEncLink(url) {
return url;
}
if(removeintrobtn){
//removes intro button
waitForKeyElements ("a.learnMoreBtn", deleteNotX);
}
// Find and replace the original function
if (typeof EdubarUtils !== 'undefined') {
if(fake_admin){
if(typeof EdubarUtils.getLoggedUserType === 'function'){
EdubarUtils.getLoggedUserType = modifiedGetLoggedUserType;
console.log('EdubarUtils.getLoggedUserType overridden successfully.');
}
if (typeof EdubarUtils.isWebpageAdmin === 'function') {
EdubarUtils.isWebpageAdmin = justtrue;
console.log('EdubarUtils.isWebpageAdmin overridden successfully.');
} else {
console.error('EdubarUtils.isWebpageAdmin not found or not a function.');
}
if (typeof EdubarUtils.hasUserRight === 'function') {
EdubarUtils.hasUserRight = justtrue;
console.log('EdubarUtils.hasUserRight overridden successfully.');
} else {
console.error('EdubarUtils.hasUserRight not found or not a function.');
}
if (typeof EdubarUtils.isAdmin === 'function') {
EdubarUtils.isAdmin = justtrue;
console.log('EdubarUtils.isAdmin overridden successfully.');
} else {
console.error('EdubarUtils.isAdmin not found or not a function.');
}
if (typeof EdubarUtils.isUcitelOrAdmin === 'function') {
EdubarUtils.isUcitelOrAdmin = justtrue;
console.log('EdubarUtils.isUcitelOrAdmin overridden successfully.');
} else {
console.error('EdubarUtils.isUcitelOrAdmin not found or not a function.');
}
}
if(fake_adult_student){
if (typeof EdubarUtils.isAdultStudent === 'function') {
EdubarUtils.isAdultStudent = justtrue;
console.log('EdubarUtils.isAdultStudent overridden successfully.');
} else {
console.error('EdubarUtils.isAdultStudent not found or not a function.');
}
if (typeof EdubarUtils.isParentOrAdultStudent === 'function') {
EdubarUtils.isParentOrAdultStudent = justtrue;
console.log('EdubarUtils.isParentOrAdultStudent overridden successfully.');
} else {
console.error('EdubarUtils.isParentOrAdultStudent not found or not a function.');
}
}
if(fake_not_restricted){
if (typeof EdubarUtils.isRestrictedEdupage === 'function') {
EdubarUtils.isRestrictedEdupage = justfalse;
console.log('EdubarUtils.isRestrictedEdupage overridden successfully.');
} else {
console.error('EdubarUtils.isRestrictedEdupage not found or not a function.');
}
}
if(fake_logged_in){
if (typeof EdubarUtils.isLoggedToPortal === 'function') {
EdubarUtils.isLoggedToPortal = justtrue;
console.log('EdubarUtils.isLoggedToPortal overridden successfully.');
} else {
console.error('EdubarUtils.isLoggedToPortal not found or not a function.');
}
}
} else {
console.error('EdubarUtils not found or not a function.');
}
if(disable_encoding){
if (typeof unsafeWindow.barEncLink === 'function') {
unsafeWindow.barEncLink = modifiedbarEncLink;
//unsafeWindow.AscMobileAppVersion = "69420";
unsafeWindow.$j.origPost = $j.post;
$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);
}
}
}
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() {
// return false;
//}
console.log("barEncLink overriden successfully.");
}
else {
console.error('barEncLink not found or not a function.');
}
}
if(change_strings){
if (typeof unsafeWindow.Langs === 'object') {
for (var key in strings) {
var value = strings[key];
unsafeWindow.Langs[key] = value;
}
console.log("Strings overriden successfully.");
}
else {
console.error('Langs not found or not a function.');
}
}
}
})();