Skip to content

Instantly share code, notes, and snippets.

@fortserious
Last active January 18, 2016 21:59
Show Gist options
  • Save fortserious/0a4d7f3f36806ff12562 to your computer and use it in GitHub Desktop.
Save fortserious/0a4d7f3f36806ff12562 to your computer and use it in GitHub Desktop.
Changes twitter's heart icons back to yellow stars.
// ==UserScript==
// @name twitter hearts to favs
// @namespace rossdoran.com
// @version 6.0
// @description don't tread on me
// @author ross doran
// @match https://twitter.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @updateURL https://gist.githubusercontent.com/raw/0a4d7f3f36806ff12562/
// @run-at document-start
// ==/UserScript==
$('head').append('<style type="text/css">.HeartAnimationContainer, .Icon--heartBadge {display:none;}</style>');
// change 'Like' tooltip to 'Favorite'
waitForKeyElements(".ProfileNav-label", function() {
$(".ProfileNav-label").each(function() {
$(this).html($(this).html().replace("Like","Favorite"))
})
});
waitForKeyElements(".js-stat-count", function() {
$(".js-stat-count a").each(function() { $(this).html($(this).html().replace("Like","Favorite")) })
});
waitForKeyElements("div.js-tooltip", function() {
$("div.js-tooltip").each(function() {
var origTitle = $(this).attr("title");
if (origTitle == "Like")
{
$(this).attr("data-original-title","Favorite")
$(this).attr("title","Favorite")
}
else if (origTitle == "Undo like")
{
$(this).attr("data-original-title","Undo favorite")
$(this).attr("title","Undo favorite")
}
})
});
// remove 'liked' heartbadge from interactions
waitForKeyElements(".Icon--heartBadge", function() {
$(".Icon--heartBadge").addClass("Icon--favorited").removeClass("Icon--heartBadge");
});
// change 'liked' to 'favorited'
waitForKeyElements(".stream-item-activity-line", function() {
$(".stream-item-activity-line").each(function() {
$(this).html($(this).html().replace("liked","favorited"))
});
});
waitForKeyElements(".view-all-supplements", function() {
$(".view-all-supplements span").each(function() {
$(this).html($(this).html().replace("like","favorite"))
});
});
// change hearts to stars
waitForKeyElements(".HeartAnimationContainer", function() {
$(".HeartAnimationContainer").each(function()
{
var favSpan = document.createElement("span");
favSpan.setAttribute("class","Icon Icon--favorite");
// add .Icon--favorite class
addGlobalStyle(".Icon--favorite:before { content: \"\\f147\" !important; }");
// add .Icon--favorited class
addGlobalStyle(".Icon--favorited:before { content: \"\\f001\" !important; color:#ffac33 !important }");
// change hover color
addGlobalStyle(".ProfileTweet-action--favorite .ProfileTweet-actionButton:hover, .ProfileTweet-action--favorite .ProfileTweet-actionButton:focus, .ProfileTweet-action--favorite .ProfileTweet-actionCount:hover, .ProfileTweet-action--favorite .ProfileTweet-actionCount:focus, .favorited .ProfileTweet-action--favorite .Icon--favorite, .favorited .ProfileTweet-action--favorite .ProfileTweet-actionButtonUndo, .favorited .tweet-actions .Icon--favorite { color: #ffac33 !important } ");
$(this).parent().append(favSpan);
$(this).remove();
})
});
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
@fortserious
Copy link
Author

This just does the icons for now, I will edit it to change all mention of Likes to Favs when I get a chance.

@fortserious
Copy link
Author

V2: Changes heart badge from interactions back to fav badge.

@fortserious
Copy link
Author

V3: Changes "liked" to "favorited" in interactions.

@fortserious
Copy link
Author

V4: Changes "Like" and "Undo like" tooltips to "Favorite" and "Undo favorite".

@fortserious
Copy link
Author

V5: (IMPORTANT!) Removes dependence on Icon--favorite/Icon--favorited classes by hardcoding those classes into the CSS with direct references to the rosettaicon star images.

@fortserious
Copy link
Author

V5.5: Changes "like" to "favorite" in "View all favorites" link when a user has favorited multiple tweets

@fortserious
Copy link
Author

V6.0: (SO COOL!) Script now runs at document start and injects a bit of CSS to the head, preventing hearts from displaying at all, ever!

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