Skip to content

Instantly share code, notes, and snippets.

@anjiro
Last active October 30, 2019 23:10
Show Gist options
  • Save anjiro/fbd5b2c505ff5f8b929c28284a21e1ff to your computer and use it in GitHub Desktop.
Save anjiro/fbd5b2c505ff5f8b929c28284a21e1ff to your computer and use it in GitHub Desktop.
Trello show days left Greasemonkey script
// ==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