Update edupage.user.js

This commit is contained in:
Bruno Rybársky 2024-01-28 23:31:49 +01:00
parent 86eae77703
commit 956dffb3f8

@ -1,257 +1,316 @@
// ==UserScript== // ==UserScript==
// @name Edupage H4x // @name Edupage H4x
// @namespace https://brn.systems // @namespace https://brn.systems
// @version 0.2.29 // @version 0.2.29
// @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
// @website https://brn.systems // @website https://brn.systems
// @downloadURL https://userscripts.brn.systems/edupage.user.js // @downloadURL https://userscripts.brn.systems/edupage.user.js
// @updateURL https://userscripts.brn.systems/edupage.user.js // @updateURL https://userscripts.brn.systems/edupage.user.js
// @match https://*.edupage.org/* // @match https://*.edupage.org/*
// @icon64 https://www.google.com/s2/favicons?sz=64&domain=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 // @icon https://www.google.com/s2/favicons?sz=32&domain=edupage.org
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js // @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js
// @grant GM_getValue // @grant GM_getValue
// @grant GM_setValue // @grant GM_setValue
// @grant GM.getValue // @grant GM.getValue
// @grant GM.setValue // @grant GM.setValue
// @grant GM_registerMenuCommand // @grant GM_registerMenuCommand
// @grant GM.registerMenuCommand // @grant GM.registerMenuCommand
// ==/UserScript== // ==/UserScript==
( function() { ( function() {
'use strict'; 'use strict';
let gmc = new GM_config( //from https://addons.mozilla.org/en-US/firefox/addon/edupage-addons/
{ let darkmodecss = '.userTopDiv,.userRozvrh,.user-novyPrvok,.userHomeOther,.hwHeroDiv,.skgdFixedHeader,#skin_Div_10,#skin_Div_11,.messageViewerHeader,div.messageViewerReplies.messageViewerReplies1.messageViewerReplyText>form>div>div>textarea,.ui-dialog-titlebar,.etest-meditor-test-item.selected{background-color:#040404 !important;box-shadow:none}div.messageViewerReplies.messageViewerReplies1.messageViewerReplyText>form>div>div>textarea{outline:none;caret-color:#fff;color:#fff}body,html,.userContentInner,.bgDiv,#jw4298a4ab_md,.edubarSidebar,.usercalendarTitle>h1,.zsvFilterElem,.zsvHeaderTitle,.zsvHeaderTabs,.diplomy-st-contet-outer,.print-nobreak,#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(1)>div>div,#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(1)>div>div>div,#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(1)>div,#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(1),#fitheight>div:nth-child(1)>span,#fitheight>div:nth-child(1),#fitheight,#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(2)>div:nth-child(1)>div:nth-child(1),#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(2)>div:nth-child(3)>div:nth-child(1),#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(2)>div:nth-child(5)>div:nth-child(1),#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(2)>div:nth-child(7)>div:nth-child(1),#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(2)>div:nth-child(9)>div:nth-child(1),#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(2)>div:nth-child(11)>div:nth-child(1),#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(2)>div>div:nth-child(2)>div:nth-child(13)>div:nth-child(1),div.mvtMainScroller.replies>div.messageViewerReplies.messageViewerReplies0>ul>li>div.messageReakciaInner,.edubarHeader,.edubarProfilebox .display,.profilemenu{background-color:#1d1d1d !important;color:#fff !important}.edubarSmartLink span,.edubarMenuitem a span,.ribbon-button span,.hwWeekItem,.zsvHeaderTitle>h1,td>span>span,td>a,td>div>a,.expandMonthBtn,#home_Heading_2,.messageViewerConfirmationItem{color:#fff !important}.edubarSmartLink:hover,.edubarMenuitem.active a,.edubarMenuitem a:hover,.edubarMenulist a:hover,.hwmenuElem .selected,.hwWeekItem,#fitheight>div:nth-child(2)>div:nth-child(3)>div:nth-child(1),#fitheight>div:nth-child(2)>div:nth-child(3),.messageViewerReplyText,.messageViewerConfirmationsHeader,.tmv-userCardsList{background-color:#101010 !important}.hwLoadMoreDiv{opacity:1 !important}.userButton,.edubarMenulist,.calendar>div,.hwmenuElem,.ribbon-section,.toolbarForm,.hwDate,.hwItem,.hwLoadMoreDiv,.hwListElem,.hwsideElem,.ui-datepicker-header,.hwMainListMain,.tmv-userCard,.sgeRestrictedWidth,.sgpTargetsPanel,.etest-meditor-test-list-month,.etest-meditor-tests-obdobie-combo,.etest-meditor-test-list-tabs,.etest-meditor-content,.etest-meditor-search-results-toolbar{background-color:#181818 !important;color:#fff !important}.messageReplies,.mvtMainScroller{background-color:#181818 !important}.hwItem{margin:0 !important}.callout{display:none}.edubarSidebar .edubarMenulist{background-color:#1d1d1d !important}.userButtonLast{background-color:#1a1a1a !important;color:#fff}ul.edubarMenulist.level0>li:hover>a,ul.edubarMenulist.level0>li.v2:hover>a{background-color:#101010 !important}.messageViewerUser,.messageViewerText,.messageViewerClosePart,.tml-replies-actions,.messageRepliesTitle,.ui-dialog-content,.ui-dialog,.sgeNavPanel,.signin-playaction-hero,.etest-meditor-searchdiv-inner3,.hwDetails{background-color:#101010 !important;color:#fff !important}th,.fixedCell,td{background-color:#101010 !important;color:#fff !important;border:none !important}.header th,.sgpQuestionElem{background-color:#0b0b0b !important}.sgpTargetItem.confirmed{background-color:#5bba6f !important}#fitheight>div:nth-child(2)>div>div>div:nth-child(2)>div:nth-child(1)>div>div:nth-child(1)>div::after{content:"dark mode v0.1 beta"}.tt-cell,.tt-cell+div+div+div span{filter:brightness(80%)}/*# sourceMappingURL=darkmode.css.map */';
id: 'edupage_h4x_cnf',
title: GM_info.script.name + ' Settings',
fields: { let gmc = new GM_config(
modify_startbutton: { {
label: 'Hides the intro button', id: 'edupage_h4x_cnf',
type: 'checkbox', title: GM_info.script.name + ' Settings',
default: false, fields: {
title: 'Hides the intro button' modify_startbutton: {
}, label: 'Hides the intro button',
modify_adult_student: { type: 'checkbox',
label: 'Fake adult student', default: false,
type: 'checkbox', title: 'Hides the intro button'
default: false, },
title: 'Fakes you as an adult student(you might be able to sign your own grades)' modify_adult_student: {
}, label: 'Fake adult student',
modify_agent: { type: 'checkbox',
label: 'Fake mobile app', default: false,
type: 'checkbox', title: 'Fakes you as an adult student(you might be able to sign your own grades)'
default: false, },
title: 'Fakes you as an adult student(you might be able to sign your own grades)' modify_admin_stuff: {
}, label: 'Fake admin',
modify_admin_stuff: { type: 'checkbox',
label: 'Fake admin', default: false,
type: 'checkbox', title: 'Fakes isUcitelOrAdmin, isAdmin, getLoggedUserType, hasUserRight, isWebpageAdmin. Some functionality still does not work(Server protection)'
default: false, },
title: 'Fakes isUcitelOrAdmin, isAdmin, getLoggedUserType, hasUserRight, isWebpageAdmin. Some functionality still does not work(Server protection)' modify_restricted: {
}, label: 'Fake not restricted',
modify_restricted: { type: 'checkbox',
label: 'Fake not restricted', default: false,
type: 'checkbox', title: 'Fakes EduPage as not restricted(I do not know what this does)'
default: false, },
title: 'Fakes EduPage as not restricted(I do not know what this does)' modify_logged_in: {
}, label: 'Fake logged in',
modify_logged_in: { type: 'checkbox',
label: 'Fake logged in', default: false,
type: 'checkbox', title: 'Fakes EduPage portal logged in(I do not know what this does)'
default: false, },
title: 'Fakes EduPage portal logged in(I do not know what this does)' modify_strings: {
}, label: 'Patch strings',
modify_strings: { type: 'checkbox',
label: 'Patch strings', default: false,
type: 'checkbox', title: 'Patch strings to more cool ones'
default: false, },
title: 'Patch strings to more cool ones' modify_encoding: {
}, label: 'Disable encoded links',
modify_encoding: { type: 'checkbox',
label: 'Disable encoded links', default: false,
type: 'checkbox', title: 'Disables ?eqa=gibberish'
default: false, },
title: 'Disables ?eqa=gibberish' autologin: {
}, label: 'Autologin',
}, type: 'checkbox',
'events': { default: false,
'init': oninit title: 'Logs you in automatically'
} },
}); darkmode: {
label: 'Dark mode',
function oninit(){ type: 'checkbox',
default: false,
GM_registerMenuCommand('Settings', () => { title: 'Makes Edupage dark'
gmc.open() },
}) },
'events': {
let removeintrobtn = gmc.get("modify_startbutton"); 'init': oninit
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"); function oninit(){
let disable_encoding = gmc.get("modify_encoding");
let change_strings = gmc.get("modify_strings"); GM_registerMenuCommand('Settings', () => {
let modify_agent = gmc.get("modify_agent"); gmc.open()
})
let strings = {
3276: "budeme Ťa otravovať za", let removeintrobtn = gmc.get("modify_startbutton");
3275: "Teraz ťa nebudeme chvíľu otravovať, ale", let fake_adult_student = gmc.get("modify_adult_student");
3272: "Už kašli na školu, nemá to zmysel a", let fake_admin = gmc.get("modify_admin_stuff");
3274: "Zabudni na úlohy,", let fake_not_restricted = gmc.get("modify_restricted");
}; let fake_logged_in = gmc.get("modify_logged_in");
let disable_encoding = gmc.get("modify_encoding");
function deleteNotX (jNode) { let change_strings = gmc.get("modify_strings");
jNode.remove (); let darkmode = gmc.get("darkmode");
} let autologin = gmc.get("autologin");
// Define your modified function let strings = {
function modifiedGetLoggedUserType() { 3276: "budeme Ťa otravovať za",
// Your custom code here 3275: "Teraz ťa nebudeme chvíľu otravovať, ale",
return 'Admin'; // Override the return value as needed 3272: "Už kašli na školu, nemá to zmysel a",
} 3274: "Zabudni na úlohy,",
};
function justtrue(){
return true; function deleteNotX (jNode) {
} jNode.remove ();
}
function justfalse(){
return false; // Define your modified function
} function modifiedGetLoggedUserType() {
// Your custom code here
function modifiedbarEncLink(url) { return 'Admin'; // Override the return value as needed
return url; }
}
function justtrue(){
if(removeintrobtn){ return true;
//removes intro button }
waitForKeyElements ("a.learnMoreBtn", deleteNotX);
} function justfalse(){
return false;
// Find and replace the original function }
if (typeof EdubarUtils !== 'undefined') {
function modifiedbarEncLink(url) {
if(fake_admin){ return url;
if(typeof EdubarUtils.getLoggedUserType === 'function'){ }
EdubarUtils.getLoggedUserType = modifiedGetLoggedUserType;
console.log('EdubarUtils.getLoggedUserType overridden successfully.'); if(removeintrobtn){
} //removes intro button
waitForKeyElements ("a.learnMoreBtn", deleteNotX);
if (typeof EdubarUtils.isWebpageAdmin === 'function') { }
EdubarUtils.isWebpageAdmin = justtrue;
console.log('EdubarUtils.isWebpageAdmin overridden successfully.'); // Find and replace the original function
} else { if (typeof EdubarUtils !== 'undefined') {
console.error('EdubarUtils.isWebpageAdmin not found or not a function.');
} if(fake_admin){
if(typeof EdubarUtils.getLoggedUserType === 'function'){
if (typeof EdubarUtils.hasUserRight === 'function') { EdubarUtils.getLoggedUserType = modifiedGetLoggedUserType;
EdubarUtils.hasUserRight = justtrue; console.log('EdubarUtils.getLoggedUserType overridden successfully.');
console.log('EdubarUtils.hasUserRight overridden successfully.'); }
} else {
console.error('EdubarUtils.hasUserRight not found or not a function.'); if (typeof EdubarUtils.isWebpageAdmin === 'function') {
} EdubarUtils.isWebpageAdmin = justtrue;
console.log('EdubarUtils.isWebpageAdmin overridden successfully.');
if (typeof EdubarUtils.isAdmin === 'function') { } else {
EdubarUtils.isAdmin = justtrue; console.error('EdubarUtils.isWebpageAdmin not found or not a function.');
console.log('EdubarUtils.isAdmin overridden successfully.'); }
} else {
console.error('EdubarUtils.isAdmin not found or not a function.'); if (typeof EdubarUtils.hasUserRight === 'function') {
} EdubarUtils.hasUserRight = justtrue;
console.log('EdubarUtils.hasUserRight overridden successfully.');
if (typeof EdubarUtils.isUcitelOrAdmin === 'function') { } else {
EdubarUtils.isUcitelOrAdmin = justtrue; console.error('EdubarUtils.hasUserRight not found or not a function.');
console.log('EdubarUtils.isUcitelOrAdmin overridden successfully.'); }
} else {
console.error('EdubarUtils.isUcitelOrAdmin not found or not a function.'); if (typeof EdubarUtils.isAdmin === 'function') {
} EdubarUtils.isAdmin = justtrue;
} console.log('EdubarUtils.isAdmin overridden successfully.');
} else {
if(fake_adult_student){ console.error('EdubarUtils.isAdmin not found or not a function.');
if (typeof EdubarUtils.isAdultStudent === 'function') { }
EdubarUtils.isAdultStudent = justtrue;
console.log('EdubarUtils.isAdultStudent overridden successfully.'); if (typeof EdubarUtils.isUcitelOrAdmin === 'function') {
} else { EdubarUtils.isUcitelOrAdmin = justtrue;
console.error('EdubarUtils.isAdultStudent not found or not a function.'); console.log('EdubarUtils.isUcitelOrAdmin overridden successfully.');
} } else {
console.error('EdubarUtils.isUcitelOrAdmin not found or not a function.');
if (typeof EdubarUtils.isParentOrAdultStudent === 'function') { }
EdubarUtils.isParentOrAdultStudent = justtrue; }
console.log('EdubarUtils.isParentOrAdultStudent overridden successfully.');
} else { if(fake_adult_student){
console.error('EdubarUtils.isParentOrAdultStudent not found or not a function.'); if (typeof EdubarUtils.isAdultStudent === 'function') {
} EdubarUtils.isAdultStudent = justtrue;
} console.log('EdubarUtils.isAdultStudent overridden successfully.');
} else {
if(fake_not_restricted){ console.error('EdubarUtils.isAdultStudent not found or not a function.');
if (typeof EdubarUtils.isRestrictedEdupage === 'function') { }
EdubarUtils.isRestrictedEdupage = justfalse;
console.log('EdubarUtils.isRestrictedEdupage overridden successfully.'); if (typeof EdubarUtils.isParentOrAdultStudent === 'function') {
} else { EdubarUtils.isParentOrAdultStudent = justtrue;
console.error('EdubarUtils.isRestrictedEdupage not found or not a function.'); console.log('EdubarUtils.isParentOrAdultStudent overridden successfully.');
} } else {
} console.error('EdubarUtils.isParentOrAdultStudent not found or not a function.');
}
if(fake_logged_in){ }
if (typeof EdubarUtils.isLoggedToPortal === 'function') {
EdubarUtils.isLoggedToPortal = justtrue; if(fake_not_restricted){
console.log('EdubarUtils.isLoggedToPortal overridden successfully.'); if (typeof EdubarUtils.isRestrictedEdupage === 'function') {
} else { EdubarUtils.isRestrictedEdupage = justfalse;
console.error('EdubarUtils.isLoggedToPortal not found or not a function.'); console.log('EdubarUtils.isRestrictedEdupage overridden successfully.');
} } else {
} console.error('EdubarUtils.isRestrictedEdupage not found or not a function.');
}
}
} else {
console.error('EdubarUtils not found or not a function.'); if(fake_logged_in){
} if (typeof EdubarUtils.isLoggedToPortal === 'function') {
EdubarUtils.isLoggedToPortal = justtrue;
if(disable_encoding){ console.log('EdubarUtils.isLoggedToPortal overridden successfully.');
if (typeof unsafeWindow.barEncLink === 'function') { } else {
unsafeWindow.barEncLink = modifiedbarEncLink; console.error('EdubarUtils.isLoggedToPortal not found or not a function.');
//unsafeWindow.AscMobileAppVersion = "69420"; }
unsafeWindow.$j.post = function(url, data, success, dataType, eqav) { }
if (!eqav) {
eqav = 1;
} } else {
if(data && Object.keys(data).length === 0) { console.error('EdubarUtils not found or not a function.');
data = { }
eqap: "",
eqacs: "da39a3ee5e6b4b0d3255bfef95601890afd80709", if(disable_encoding){
eqaz: 0, if (typeof unsafeWindow.barEncLink === 'function') {
} unsafeWindow.barEncLink = modifiedbarEncLink;
} //unsafeWindow.AscMobileAppVersion = "69420";
url += (url.indexOf('?') >= 0 ? '&' : '?')+'eqav='+eqav+'&maxEqav='+unsafeWindow.maxEqav; unsafeWindow.$j.post = function(url, data, success, dataType, eqav) {
return $j.origPost(url, data, success, dataType); if (!eqav) {
}; eqav = 1;
//MobileAppBridge.isActive = function() { }
// return false; if(data && Object.keys(data).length === 0) {
//} data = {
eqap: "",
console.log("barEncLink overriden successfully."); eqacs: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
} eqaz: 0,
else { }
console.error('barEncLink not found or not a function.'); }
} url += (url.indexOf('?') >= 0 ? '&' : '?')+'eqav='+eqav+'&maxEqav='+unsafeWindow.maxEqav;
} return $j.origPost(url, data, success, dataType);
};
if(change_strings){ //MobileAppBridge.isActive = function() {
if (typeof unsafeWindow.Langs === 'object') { // return false;
for (var key in strings) { //}
var value = strings[key];
unsafeWindow.Langs[key] = value; console.log("barEncLink overriden successfully.");
} }
console.log("Strings overriden successfully."); else {
} console.error('barEncLink not found or not a function.');
else { }
console.error('Langs 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.');
}
}
// If Dark Mode is enabled, apply the styles
if (darkmode) {
const style = document.createElement('style');
style.textContent = darkmodecss;
document.head.appendChild(style);
}
if (autologin) {
(async function() {
// Function to get value using postMessage
async function getValue(k) {
return new Promise((resolve) => {
window.addEventListener("message", (e) => {
console.log(e);
if (e.data.message === "getValueResponse") {
resolve(e.data.value);
}
});
window.postMessage({ message: "getValue", key: k }, "*");
});
}
// Wait for the DOM to be ready
await new Promise(resolve => {
if (document.readyState === 'complete') {
resolve();
} else {
window.addEventListener('load', resolve);
}
});
// Select elements
const userField = document.querySelector("#home_Login_1e1");
const passField = document.querySelector("#home_Login_1e2");
// Check if userField exists and host matches
if (userField && location.host === (await getValue("autologin_host")) + ".edupage.org") {
// Populate fields with autologin credentials
userField.value = await getValue("autologin_username");
passField.value = await getValue("autologin_password");
// Click the submit button
}
})();
}
}
})(); })();