Last active
March 22, 2017 21:31
-
-
Save fcannizzaro/f4b77425ae7c804efcb69d0999755683 to your computer and use it in GitHub Desktop.
This file contains 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 Unipa Subscription | |
// @version 1.0 | |
// @description Sort Unipa Files by Upload Date | |
// @author Francesco Cannizzaro | |
// @match https://immaweb.unipa.it/immaweb/private/docenti/esami/include/contenutiInsegnamentoMaterialeDidattico.seam?* | |
// @require https://code.jquery.com/jquery-3.2.0.min.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var table = $("table[id*='materialeDidatticoList'] tbody"); | |
var array = $("tr", table); | |
var getDate = (ele) => { | |
var tmp = $('td',ele).first().text().trim().split(' '); | |
var time = tmp[1].split(':'); | |
var date = tmp[0].split('/'); | |
return new Date(date[2], date[1], date[0], time[0], time[1], time[2]); | |
}; | |
jQuery.each(array, (i, ele) => { | |
var key = $('td',ele).first().text().trim(); | |
if (!localStorage.getItem(key)) { | |
$("td", ele).css("background-color", "#DCEDC8"); | |
$("td:eq(1)", ele).css("font-weight", "bold"); | |
} | |
localStorage.setItem(key, true); | |
}); | |
array.sort((a, b) => getDate(a) < getDate(b) ? 1 : -1); | |
$(table).html(array); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment