NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name TimeKey- Calculate Hours
// @namespace http://tampermonkey.net/
// @version 1.1.10
// @description Calculate hours as a decimal in Alleima TimeKey
// @author salience
// @copyright 2023, salience (https://openuserjs.org/users/salience)
// @license MIT
// @match https://alleima.timekey.se/*
// @require https://code.jquery.com/jquery-3.5.1.slim.min.js
// @grant none
// ==/UserScript==
/* -------------------------------------------------------------------------- */
/* TimeKey */
/* -------------------------------------------------------------------------- */
(function() {
})();
jQuery.noConflict();
(function($) {
// Set better Timekey favicon
$('link[rel*="icon"]').each(function() {
$(this)[0].href = 'https://i.imgur.com/Hy5tgeN.png';
});
var elems = $('.col-nvt .text-primary');
window.setInterval(function() {
elems = getElems();
if (elems.length > 0) update();
}, 5000);
function getElems() {
return $('.col-nvt .text-primary');
}
function update() {
var elem;
var time, timeArr;
var hour;
var fraction;
var timeFraction;
var even;
elems.each(function () {
elem = $(this);
time = elem.text().split(':');
hour = Number(time[0]);
fraction = Math.round((time[1] * 10) / 6) / 100;
even = time[1] % 6 === 0 ? true : false;
timeFraction = hour + fraction;
timeFraction = timeFraction.toString() + (fraction == 0 ? '.0' : '');
if (elem.parent().children().length === 1) {
elem.parent().append('<div class="time-fraction"></div>');
}
elem.next().html(timeFraction);
});
}
})(jQuery);
/* -------------------------------------------------------------------------- */
/* CSS */
/* -------------------------------------------------------------------------- */
jQuery.noConflict();
(function($) {
$('body').after(`<style type="text/css">
.col-nvt.col-nvt.col-nvt {
width: 100px;
}
.col-nvt.col-nvt.col-nvt > .header-label-content {
display: flex;
margin-left: 0;
}
.col-nvt.col-nvt.col-nvt > .header-label-content > .text-primary {
min-width: 36px;
}
.col-nvt > .header-label-content > .time-fraction {
display: flex;
}
.col-nvt > .header-label-content > .time-fraction::before {
content: ' ➔ ';
margin-left: .4rem;
margin-right: .4rem;
}
</style>`);
})(jQuery);