Created
January 24, 2022 18:05
-
-
Save GrzegorzManiak/01e31e739102b5bc0fce4c59548dbe13 to your computer and use it in GitHub Desktop.
Make moodle good again!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Gets rid of useless moddle shit | |
// @namespace http://moodle.com/ | |
// @version 0.1 | |
// @description rethemes the moodle site for TUD tallaght | |
// @author You | |
// @match https://elearning-ta.tudublin.ie/* | |
// @icon https://www.google.com/s2/favicons?domain=tudublin.ie | |
// @grant none | |
// ==/UserScript== | |
//Sleep func | |
async function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
document.head.insertAdjacentHTML("afterend", `<link rel="stylesheet" type="text/css" href='https://cdn.discordapp.com/attachments/913549297595858956/935232034803175454/moo.css'>`); | |
(function() { | |
'use strict'; | |
//Module ID's to remove | |
let remove = [ | |
308, | |
325, | |
315, | |
314, | |
2240, | |
312, | |
2616, | |
6112, | |
382, | |
3345, | |
3498, | |
162, | |
5799, | |
1180, | |
5506 | |
] | |
//------[ Dropdown menu ]------// | |
let dropdown = document.getElementById('dropdownmain-navigation0').children; | |
dropdown = [...dropdown]; | |
dropdown.forEach(element => { | |
let a_element = [...element.children][0]; | |
remove.forEach(id => { | |
if(a_element.href.includes(id.toString())) | |
element.remove(); | |
}); | |
}); | |
//-----------------------------// | |
//other | |
let latest_badges = document.querySelector('div[data-block="badges"]'); | |
if(latest_badges) | |
latest_badges.remove(); | |
let announcments = document.querySelector('div.mod-indent'); | |
if(announcments) | |
announcments.remove(); | |
//--------[ card menu ]--------// | |
let checkForCards = async(cards)=>{ | |
while(true){ | |
//get all the cards | |
cards = document.getElementsByClassName('card dashboard-card'); | |
//sleep for a while | |
await sleep(50); | |
//check if the cards have loaded in yet | |
if(cards?.length > 0) break; | |
} | |
// convert the DOMarray to a normal array | |
cards = [...cards]; | |
// check if any of the card's id's match the ones that we want to block | |
cards.forEach((elem) => { | |
try { | |
elem.querySelector('button').remove(); | |
if(remove.includes(parseInt(elem?.dataset?.courseId))) | |
elem.remove(); | |
} | |
catch{} | |
}); | |
}; | |
(async() =>{ | |
while(true){ | |
checkForCards(); | |
await sleep(1000); | |
} | |
})(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment