Last active
November 11, 2019 07:38
-
-
Save dalevross/b848057b33fbea82d80aedc8460cd0b3 to your computer and use it in GitHub Desktop.
Code I used to create twitter follow buttons from profile links
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
//Add the twitter-follow-button class to all anchors that contain twitter | |
//The selector could be tweaked to be more specific. | |
$("a[href*=twitter]").addClass("twitter-follow-button"); | |
//Add the twitter API code dynamically | |
! function (d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (!d.getElementById(id)) { | |
js = d.createElement(s); | |
js.id = id; | |
js.src = "//platform.twitter.com/widgets.js"; | |
fjs.parentNode.insertBefore(js, fjs); | |
} | |
}(document, "script", "twitter-wjs"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment