Skip to content

Instantly share code, notes, and snippets.

@NigelThorne
Created March 1, 2012 22:42
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save NigelThorne/1953757 to your computer and use it in GitHub Desktop.
Save NigelThorne/1953757 to your computer and use it in GitHub Desktop.
WorkFlowy userscript to add css classes to nodes based on their tags
/* I use Stylish (a chome addin) to set these styles
* URLs on the domain workflowy
*/
.next-row {
border: 2px solid #46A546 !important;
border-top-left-radius:0.5em;
background-color: #CCFFCC !important;
}
.next {
background-color: #46A546 !important;
}
.blocked-row {
border: 2px solid #4646A5 !important;
border-bottom-left-radius:1em;
background-color: #CCCCFF !important;
}
.blocked {
background-color: #4646A5 !important;
}
.urgent-row {
border: 3px solid #A54646 !important;
border-top-left-radius:1em;
color: #A54646;
background-color: #FFCCCC !important;
}
.urgent {
background-color: #A54646 !important;
}
// ==UserScript==
// @name WorkflowyStylableTags
// @description Gives each tag it's own css style, so you can style them with Stylish. I use Blank Canvas to manage my userscripts in Chrome.
// @author Nigel Thorne
// @include http*://*workflowy.com/*
// @version 1.0
// ==/UserScript==
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
var customClasses = function(index, old){
var classes = old.split(" ");
var custom = [];
for( i = 0; i < classes.length; i++){
if(classes[i].endsWith("-row")){ custom.push(classes[i]);};
if(classes[i].endsWith("-span")){ custom.push(classes[i]);};
};
return custom.join(" ");
}
setInterval(function(){
$('.name').removeClass(customClasses);
$('.content').removeClass(customClasses );
$('span > .contentTagText').map( function(){
var x = $(this).text();
$(this).parent('.contentTag').addClass(x).parent().addClass(x+"-span").parent().addClass(x+"-row");}
);
},100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment