Last active
December 12, 2021 15:51
-
-
Save daveyarwood/ab85d38e365cdc10e26d11c67ba23d64 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
var expectedOrgName = 'AdzerkBC'; | |
var expectedBoardName = 'The Sprint Board'; | |
function getOrgName() { | |
return $('.board-header-btn-org-name .board-header-btn-text').text(); | |
} | |
function getBoardName() { | |
return $('.board-header-btn-name .board-header-btn-text').text(); | |
} | |
function runExtension() { | |
if (getOrgName() != expectedOrgName || | |
getBoardName() != expectedBoardName) | |
return; | |
var allColumns = $('.list-wrapper'); | |
var columnsICareAbout = [ | |
"Crushable: Mgmt UI/API", | |
"Crushing", | |
"Needs Code Review", | |
"Needs QA Deploy", | |
"Needs Prod Deploy (Passed QA)", | |
"CRUSHED!" | |
]; | |
function showOnlyColumnsICareAbout() { | |
console.info("Hiding columns I don't care about."); | |
$.map(allColumns, function(column) { | |
var columnName = $(column).find('.list-header-name-assist').text(); | |
if (!columnsICareAbout.includes(columnName)) { | |
$(column).hide(); | |
} | |
}); | |
} | |
function showAllColumns() { | |
console.info("Showing all columns.") | |
allColumns.show(); | |
} | |
var showAll = true; | |
function toggleColumns() { | |
showAll = !showAll; | |
if (showAll) { | |
showAllColumns(); | |
} else { | |
showOnlyColumnsICareAbout(); | |
} | |
} | |
toggleColumns(); | |
document.onkeypress = function(e) { | |
if ((e.key == '`' || e.keyCode == 96) && !$('.window').is(':visible')) { | |
toggleColumns(); | |
} | |
} | |
} | |
var onTheRightBoard = false; | |
function checkOrgAndBoardName() { | |
var orgName = getOrgName(); | |
var boardName = getBoardName(); | |
if (orgName == expectedOrgName && boardName == expectedBoardName) { | |
if (!onTheRightBoard) { | |
onTheRightBoard = true; | |
runExtension(); | |
} | |
} else { | |
onTheRightBoard = false; | |
// console.log('orgName: ' + orgName + ', boardName: ' + boardName); | |
} | |
setTimeout(checkOrgAndBoardName, 1000); | |
} | |
checkOrgAndBoardName(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use this script to optimize your Trello experience:
orgName
andboardName
to reflect the name of your Trello organization and board you want to optimize.columnsICareAbout
to reflect the columns that you personally care about.`
to toggle between showing all columns and just the ones you care about. (Just the ones you care about is the default behavior.)