Skip to content

Instantly share code, notes, and snippets.

@umaar
Forked from simevidas/highlight_tweets.js
Created July 12, 2017 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umaar/032e8c56696db3b46cdb741f7527ec24 to your computer and use it in GitHub Desktop.
Save umaar/032e8c56696db3b46cdb741f7527ec24 to your computer and use it in GitHub Desktop.
A JS snippet for highlighting tweets with lots of RTs or hearts
(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