Skip to content

Instantly share code, notes, and snippets.

@lukemt
Last active March 29, 2018 21:04
Show Gist options
  • Save lukemt/bd90b41e9603e0737a30 to your computer and use it in GitHub Desktop.
Save lukemt/bd90b41e9603e0737a30 to your computer and use it in GitHub Desktop.
// ==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]);};
if(classes[i].endsWith("-proj")){ custom.push(classes[i]);};
};
return custom.join(" ");
}
var StylableTagsCounter = 1;
setInterval(function(){
StylableTagsCounter ++;
if( StylableTagsCounter >= 3){
$('.name').removeClass(customClasses);
$('.content').removeClass(customClasses);
$('.project').removeClass(customClasses);
$('.pageContainer').removeClass(customClasses);
StylableTagsCounter = 0;
}
$('span > .contentTagText').map( function(){
var x = $(this).text();
$(this).parent('.contentTag').addClass(x).parent().addClass(x+"-span").parent().addClass(x+"-row").parent().addClass(x+"-proj");}
);
},1000);
// ==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 and LukeMT
// @include http*://*workflowy.com/*
// @version 1.1
// ==/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("-proj")){ custom.push(classes[i]);};
};
return custom.join(" ");
}
var StylableTagsCounter = 1;
setInterval(function(){
StylableTagsCounter ++;
if( StylableTagsCounter >= 3){
$('.project').removeClass(customClasses);
$('.pageContainer').removeClass(customClasses);
StylableTagsCounter = 0;
}
$('span > .contentTagText').map( function(){
var x = $(this).text();
$(this).parent('.contentTag').parent().parent().parent().addClass(x+"-proj");}
);
},1000);
@Mqrius
Copy link

Mqrius commented Nov 23, 2016

Your selector for pageContainer selects on class, but pageContainer is an id.
Here's a fix: https://gist.github.com/Mqrius/2012e139b1fc4c3ccaf2a5fe0a67bfec/revisions
(Can't do pull requests on gists)
(Note that I haven't fixed the big old version. Fix is trivial though.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment