// ==UserScript==
// @name Trello custom css
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Custom css of trello website.
// @author oraant
// @match https://trello.com/b/*
// @match https://trello.com/c/*
// @grant none
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @require https://greasyfork.org/scripts/6250-waitforkeyelements/code/waitForKeyElements.js?version=23756
// @downloadURL none
// ==/UserScript==
waitForKeyElements (".js-board-header", main);
function main(){
// 首先,为页面添加全局的css样式,包括自定义的样式和第三方的样式(tailwind 和 uikit,均已去掉冲突的标签样式),
$("head").append(`
`);
// 其次,为页面添加 开启/关闭自定义样式 的按钮和功能
$(".board-header-btns.mod-right").prepend(`
`);
$("#custom_css_toggler").click(function(){
let content = $("#custom_css").attr("type") == "text/css" ? "nothing" : "text/css";
$("#custom_css").attr("type", content);
});
// 获取所有列表标题中,包含JSON格式的列表
var list_wrappers = $('.list-wrapper').filter(
function(){
var title = $(this).find('h2.js-list-name-assist').text();
try {var obj=JSON.parse(title); return typeof obj == 'object' && obj; console.log(obj);}
catch(e) {return false;}
}
);
// 从JSON格式中,读取此列表下各元素要添加的类名,并为其添加该类名
list_wrappers.each(function(){
var title = $(this).find('h2.js-list-name-assist').text();
var obj=JSON.parse(title);
console.log(obj);
$(this).addClass(obj["js-list"]);
$(".js-list-content", this).addClass(obj["js-list-content"]);
$(".js-list-header", this).addClass(obj["js-list-header"]);
$(".js-list-cards", this).addClass(obj["js-list-cards"]);
$(".js-card-composer-container", this).addClass(obj["js-card-composer-container"]);
});
console.log("hello2");
};