Skip to content

Instantly share code, notes, and snippets.

@jewel-andraia
Last active February 3, 2017 03:01
Show Gist options
  • Save jewel-andraia/af19e8db8dde937afb1a to your computer and use it in GitHub Desktop.
Save jewel-andraia/af19e8db8dde937afb1a to your computer and use it in GitHub Desktop.
Metafilter MultiFavorited Multiwidth for Greasemonkey
// ==UserScript==
// @name Metafilter MultiFavorited Multiwidth
// @author andytuba
// @namespace http://www.metafilter.com/user/25038
// @description https://gist.github.com/andytuba/af19e8db8dde937afb1a/edit
// @include http://www.metafilter.com/*
// @include http://*.metafilter.com/*
// ==/UserScript==
setTimeout(go, 200); // cheat instead of learning about Tampermonkey startup and config
function go() {
// Threshold; at this number or higher the comment will be highlights
var threshold = 2;
// Highlighting colors, change to match your preferences!
var MetaHighlight='#337dc3';
var askMeHighlight='#47cf4a';
var TalkHighlight='#888888';
var searchPattern = 'a[title*="marked this as favorite"]';
var options = document.querySelectorAll(searchPattern);
var i;
for (var klass = null, i = 0; (klass = options[i]); i++) {
var favCount=klass.title.replace(/^[^0-9]*([0-9]+)[^0-9]+$/,'$1');
if (favCount >= threshold) {
var commentNode=klass;
while (commentNode.nodeName != "DIV") {
commentNode = commentNode.parentNode;
}
commentNode.style.borderLeft=''+((favCount/2)+1)+'px solid';
commentNode.style.paddingLeft='5px';
commentNode.style.marginLeft=''+(70-((favCount/2)+1))+'px';
if (document.location.hostname.indexOf('www')==0)
commentNode.style.borderColor=MetaHighlight;
if (document.location.hostname.indexOf('ask')==0)
commentNode.style.borderColor=askMeHighlight
if (document.location.hostname.indexOf('metatalk')==0)
commentNode.style.borderColor=TalkHighlight;
};
}
}
@JordanReiter
Copy link

Thanks for doing this! Nice to see that people are still getting use out of this.

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