forked from thinkswan/jquery-twitter-autolink
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.twitter.autolink.min.js
More file actions
11 lines (8 loc) · 1.16 KB
/
Copy pathjquery.twitter.autolink.min.js
File metadata and controls
11 lines (8 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
/*
jQuery Twitter Autolink - v2.0
Automatically creates links for URLs, email addresses, @-mentions, and hashtags in embedded tweets.
Usage: $(<tweet_element>).twitter_autolink();
Copyright (c) 2013 Graham Swan. Modified By jQueryScript.Net
Licensed under the MIT license - https://github.com/thinkswan/jquery-twitter-autolink/blob/master/LICENSE
*/
!function(a){a.fn.twitter_autolink_constants={TWITTER_BASE_URL:"https://x.com/",TWITTER_SEARCH_URL:"https://x.com/search?q="},a.fn.twitter_autolink_regex_map=new Array({re:/((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g,replace:'<a href="$1">$1</a>'},{re:/(([a-z0-9*._+]){1,}\@(([a-z0-9]+[-]?){1,}[a-z0-9]+\.){1,}([a-z]{2,4}|museum)(?![\w\s?&.\/;#~%"=-]*>))/g,replace:'<a href="mailto:$1">$1</a>'},{re:/(^|\s)@(\w+)/g,replace:'$1<a href="'+a.fn.twitter_autolink_constants.TWITTER_BASE_URL+'$2">@$2</a>'},{re:/(^|\s)#(\w+)/g,replace:'$1<a href="'+a.fn.twitter_autolink_constants.TWITTER_SEARCH_URL+'$2">#$2</a>'}),a.fn.twitter_autolink=function(){return this.each(function(){var b=a(this);a.each(a.fn.twitter_autolink_regex_map,function(a,c){b.html(b.html().replace(c.re,c.replace))})})}}(jQuery);