Created
November 17, 2017 17:12
-
-
Save cmgdev/2f8917748df87aea1657d5dff2e119eb to your computer and use it in GitHub Desktop.
Updated "Metafilter MultiFavorited Multiwidth" script for https
This file contains 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 Metafilter MultiFavorited Multiwidth - November Experiment | |
// @author Deathalicious, cmgdev | |
// @namespace http://www.metafilter.com/user/25038 | |
// @description Code adjusted to deal with the "November Experiment" (see http://metatalk.metafilter.com/18396/November-is-National-Lets-Try-Obscuring-Favorite-Counts-Month) | |
// @include https://www.metafilter.com/* | |
// @include https://*.metafilter.com/* | |
// ==/UserScript== | |
(function () { | |
// 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[contains(@title,'marked this as favorite')]"; | |
var options = document.evaluate( searchPattern, document, null, | |
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); | |
if (options.snapshotLength === 0 ) { | |
options = document.evaluate( searchPatternFavesOff, document, null, | |
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null ); | |
} | |
var i = 0; | |
for (var klass = null; (klass = options.snapshotItem(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; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment