Last active
September 23, 2017 19:38
-
-
Save maximeaubaret/6f7e30bc7260377aafc465f30e4e1f29 to your computer and use it in GitHub Desktop.
Trello Enhancements
This file contains hidden or 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 Enhancements | |
| // @namespace http://moveyourbuddy.io/trello-enhancements | |
| // @version 0.2 | |
| // @description try to take over the world! | |
| // @author Maxime Aubaret <maxime@moveyourbuddy.io> | |
| // @match https://trello.com/b/* | |
| // @run-at document-end | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| function init() { | |
| // Hide details of lists first cards | |
| var firstCards = $(".list .list-card:nth-child(1)"); | |
| firstCards.children(".list-card-details").addClass("hide"); | |
| // Format Card titles | |
| $(".list-card-title").each((_, el) => { | |
| var complexityRegex = /(- [\d* ?\d*\/\d*]* ?J)$$/; | |
| var matchesA = el.innerText.match(/^((.*) ?:)?(.*)/); | |
| var matchesB = el.innerText.match(complexityRegex); | |
| var project = matchesA[2]; | |
| var complexity = matchesB != null ? matchesB[1].replace(/[ -]/, "") : null; | |
| var content = matchesA[3].replace(complexityRegex, ""); | |
| var html = ""; | |
| if (project) { | |
| html += "<b>" + project + "</b>"; | |
| } | |
| if (complexity) { | |
| html += "<i style=\"font-size: 12px;\"> " + complexity + "</i>"; | |
| } | |
| if (project || complexity) { | |
| html += "<br />"; | |
| } | |
| html += content; | |
| el.innerHTML = html; | |
| }); | |
| // Add filter by self button | |
| var header = $(".board-header-btns.mod-left")[0]; | |
| var button = document.createElement("a"); | |
| button.className = "board-header-btn"; | |
| button.innerHTML = "<span class=\"board-header-btn-icon icon-sm\">😀</span><span class=\"board-header-btn-text\">Only me</span>"; | |
| header.appendChild(button); | |
| button.addEventListener("click", () => { | |
| var userPicture = $("#header .member-avatar")[0].src; | |
| // Hide all cards | |
| $(".list-card").toggleClass("hide"); | |
| // Show cards from the user | |
| $(".list-card img").filter((_, el) => el.src === userPicture).parents(".list-card").toggleClass("hide"); | |
| // Always show first cards in lists | |
| firstCards.toggleClass("hide"); | |
| }); | |
| } | |
| setTimeout(init, 2000); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment