-
-
Save umaar/032e8c56696db3b46cdb741f7527ec24 to your computer and use it in GitHub Desktop.
A JS snippet for highlighting tweets with lots of RTs or hearts
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
(function(){ | |
'use strict'; | |
let cap = 100; // 100+ RTs or hearts produces max yellow bg color | |
$('.tweet', '.stream-items').each((i, tweet) => { | |
let all_nums = $(tweet) | |
.find('.ProfileTweet-actionList .ProfileTweet-actionCount:visible') | |
.map((j, elem) => Number(elem.textContent)).toArray(); | |
let num = Math.min(Math.max.apply(Math, all_nums.concat(0)), cap); | |
let str = Math.floor(255 * (1 - num/cap)).toString(16); | |
if (str.length === 1) str = '0' + str; | |
$(tweet).css({ 'background-color': '#FFFF' + str }); | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment