-
-
Save mals14/7b4f39ff2e22ceb89ad61332d5877410 to your computer and use it in GitHub Desktop.
Trello show days left Greasemonkey script
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 Trello days left | |
// @namespace edu.rit.ashbrook.daniel | |
// @include https://trello.com/* | |
// @version 1.1 | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js | |
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
// @grant GM_addStyle | |
// @description Add the number of days left until an item is due to each applicable card. | |
// ==/UserScript== | |
var showDaysLeft = function() | |
{ | |
$("div.is-due-future.badge span.badge-icon.icon-clock") | |
.siblings("span.badge-text") | |
.each( | |
function() | |
{ | |
var curText = $(this).text(); | |
if($(this).siblings('.daysLeft').length == 0) //Don't add extra days left | |
{ | |
var dueDate; | |
if(curText.indexOf(",") != -1) //There's a year, so don't add it | |
dueDate = Date.parse(curText); | |
else | |
dueDate = Date.parse(curText + ", " + (new Date()).getFullYear()); | |
var daysLeft = Math.floor((dueDate - Date.now())/(3600*24*1000)) + 1; | |
$(this).after("<span class='daysLeft' style='color:red; font-weight:bold'> [" + daysLeft + "]</span>"); | |
} | |
} | |
) | |
} | |
//Run every 1.5s to overcome Trello's Ajax auto-refresh | |
$(document).ready(function(){setInterval(showDaysLeft, 1500)}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment