Skip to content

Instantly share code, notes, and snippets.

@lodi-g
Last active November 14, 2016 23:08
Show Gist options
  • Save lodi-g/40e624c251be2c4252ac4e183bd8d9e2 to your computer and use it in GitHub Desktop.
Save lodi-g/40e624c251be2c4252ac4e183bd8d9e2 to your computer and use it in GitHub Desktop.
Hides full activities on the {EPITECH} intra. Only works with weekly view. Tested with Firefox (GreaseMonket) & Chrome (TamperMonkey) successfully.
// ==UserScript==
// @name Hide full activities
// @namespace lodi_g
// @description Hides full activities on the {EPITECH} intra. Only works with weekly view. Tested with Firefox (GreaseMonket) & Chrome (TamperMonkey) successfully.
// @include *intra.epitech.eu/planning/*
// @require https://code.jquery.com/jquery-3.0.0.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @version 0.2a
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
// ==ChangeLog==
//
// v0.2a
// - Implemented GM_getValue & GM_setValue to remember user's choice.
//
// v0.1a
// - Initial release
// ==/ChangeLog==
waitForKeyElements(".buttons a", actionFunction);
function actionFunction(jNode) {
$("fieldset.filters.student").append(`<div class="item event"><input name="event" id="hide-full-act" type="checkbox"><label for="hide-full-act">Hide full activities</label></div>`);
if (GM_getValue("hidden", 0) == 1) {
$("#hide-full-act").attr("checked", "checked");
hideFullActivities();
}
$("#hide-full-act").on("click", function(e) {
main(e);
});
}
function main(e) {
if (e.target.checked) {
GM_setValue("hidden", !GM_getValue("hidden"));
hideFullActivities();
}
else {
GM_setValue("hidden", !GM_getValue("hidden"));
showFullActivities();
}
}
function hideFullActivities() {
$(".appoint").each(function(i) {
if ($(this).find(".used_seats").length > 0) {
let usedSeats = $(this).find(".used_seats").attr("title").split(" ")[0];
let totalSeats = $(this).find(".room_seats").attr("title").split(" ")[0];
if (usedSeats === totalSeats) {
$(this).hide();
$(this).toggleClass("removed-full");
}
}
});
}
function showFullActivities() {
$(".appoint").each(function() {
if (!$(this).is(":visible")) {
$(this).show();
$(this).toggleClass("removed-full");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment