Last active
January 18, 2016 21:59
-
-
Save fortserious/0a4d7f3f36806ff12562 to your computer and use it in GitHub Desktop.
Changes twitter's heart icons back to yellow stars.
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 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); | |
} |
V5.5: Changes "like" to "favorite" in "View all favorites" link when a user has favorited multiple tweets
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
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.