Created
January 27, 2022 18:29
-
-
Save GrzegorzManiak/73da56baa5ca96df286670d9c54bd9b0 to your computer and use it in GitHub Desktop.
Moodle theme for TUD Tallaght
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://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @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, | |
branch = document?.querySelectorAll('li.type_course.depth_3.contains_branch'); | |
try{ | |
dropdown = [...dropdown]; | |
dropdown.forEach(element => { | |
let a_element = [...element.children][0]; | |
remove.forEach(id => { | |
if(a_element?.href?.includes(id.toString())) | |
element.remove(); | |
}); | |
}); | |
}catch(err){ console.log(err) } | |
try{ | |
branch = [...branch]; | |
branch.forEach(element => { | |
let a_element = [...element.children][0]; | |
remove.forEach(id => { | |
if(a_element?.attributes["data-node-key"]?.nodeValue == id.toString()) | |
element.remove(); | |
}); | |
}); | |
}catch(err){ console.log(err) } | |
//-----------------------------// | |
//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