Created
June 8, 2016 10:47
-
-
Save WillMoggridge/ce9a8ef3558a5a33f17d4f7d93f1e279 to your computer and use it in GitHub Desktop.
trello-user-cycle.user.js
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 - Next User | |
// @namespace [email protected] | |
// @include https://trello.com/b/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
window.addEventListener('load', function() { | |
var nextButton = $('<a class="board-header-btn board-header-btn-filter-indicator">Next User</a>'); | |
var userIndicator = $('<a class="board-header-btn"></a>'); | |
var prevButton = $('<a class="board-header-btn board-header-btn-filter-indicator">Prev User</a>'); | |
function resetFilter() { | |
var activeExists = false; | |
do { | |
var active = $('.js-mem-list .js-member-item.active a'); | |
active.click() | |
activeExists = (active.length - 1 > 0) | |
} while (activeExists); | |
} | |
function changeUser(i) { | |
$('.js-open-card-filter').click(); | |
$('.js-show-all-members').click(); | |
var next = $(".js-mem-list .js-member-item:nth('"+i+"') a"); | |
if (next.length) { | |
resetFilter(); | |
next = $(".js-mem-list .js-member-item:nth('"+i+"') a"); | |
userIndicator.text(next.text()); | |
next.click(); | |
} | |
return false; | |
} | |
function getCurrentUserIndex() { | |
var current = $('.js-mem-list .js-member-item.active:first'); | |
if (current.length) { | |
return current.index(); | |
} | |
return false; | |
} | |
function firstUser() { | |
changeUser(1); | |
} | |
function nextUser() { | |
$('.js-open-card-filter').click(); | |
$('.js-show-all-members').click(); | |
var currentIndex = getCurrentUserIndex(); | |
var index = 0; | |
if (currentIndex !== $('.js-mem-list .js-member-item:last').index()) { | |
index = currentIndex + 1; | |
} | |
changeUser(index); | |
} | |
function prevUser() { | |
$('.js-open-card-filter').click(); | |
$('.js-show-all-members').click(); | |
var currentIndex = getCurrentUserIndex(); | |
var index; | |
if (currentIndex !== false || currentIndex !== 0) { | |
index = currentIndex - 1; | |
} else { | |
index = $('.js-mem-list .js-member-item:last').index(); | |
} | |
changeUser(index); | |
} | |
nextButton.click(nextUser); | |
prevButton.click(prevUser); | |
$('.board-header-btn.perms-btn').after(userIndicator); | |
$('.board-header-btn.calendar-btn').before(prevButton, nextButton); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment