Created
July 25, 2023 07:11
-
-
Save LouisHaftmann/a112a409efb1504150f0b2fcc510c631 to your computer and use it in GitHub Desktop.
GoodDay Board Sorting
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 GoodDay Board Sorting | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://*.goodday.work/* | |
// @icon https://falcondev.de/wp-content/uploads/2021/08/cropped-Facivon-512-min-32x32.png | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
console.log('testtest') | |
let app | |
const observer = new MutationObserver(mutations => { | |
for (const mutation of mutations) { | |
for (const node of [...mutation.addedNodes, mutation.target]) { | |
if (node.classList.contains('gd-app')) { | |
app = node | |
setTimeout(sort, 500) | |
setTimeout(sort, 2000) | |
observer.observe(node, { childList: true, subtree: true, attributes: true }) | |
return | |
} | |
if (node.classList.contains('gd-board-card') || node.closest('.gd-board-card')) { | |
observer.disconnect() | |
sort() | |
observer.observe(app, { childList: true, subtree: true, attributes: true }) | |
return | |
} | |
} | |
} | |
}) | |
observer.observe(document.body, { childList: true, subtree: true, attributes: true }) | |
function getElementPriority(el) { | |
if(el.classList.contains('add-card-inactive')) return -1 | |
const prioEl = el.querySelector('.ui5-priority') | |
if(!prioEl) return 3 | |
const prioClass = [...prioEl.classList].find(c => /pr\-[0-9]/.test(c)) | |
return +(prioClass.replace('pr-', '')) | |
} | |
function sort() { | |
const cols = [...document.querySelectorAll('#ui-page > div > div.main.with-controls.inline-filter > div > div.board-view-new-scroll-container.no-vertical-scroll > div > div > div > div > div.v-children-container > div.column-content')]; | |
for(const col of cols) { | |
const els = [...col.querySelectorAll('div.gd-board-card')] | |
.sort((a,b) => getElementPriority(b) - getElementPriority(a)); | |
for(const c of els) { | |
col.appendChild(c) | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment