Skip to content

Instantly share code, notes, and snippets.

@HaiTo
Created May 26, 2017 06:14
Show Gist options
  • Save HaiTo/260d8d7da4f8962bb080b93b1a1e8ad8 to your computer and use it in GitHub Desktop.
Save HaiTo/260d8d7da4f8962bb080b93b1a1e8ad8 to your computer and use it in GitHub Desktop.
javascript:(function(d){function l(){(function($){
var i, t, a, tw, img_src, track_range;
var s = function(i){
var e = document.getElementById(i).innerHTML;
return e
.replace(/&/g, "%26")
.replace(/</g, "%3c")
.replace(/>/g, "%3e");
};
t = s("currently-playing-title");
a = s("player-artist");
img_src = $('#playerBarArt').attr('src');
track_range = $("#time_container_duration").attr('aria-label').split(":")[1];
tw = encodeURIComponent("title: " + t + "\nArtist: " + a + "\nduration: " + track_range + "\nJacketImage: " + img_src + "\n#nowplaying");
void(window.open("https://twitter.com/intent/tweet?text=" + tw));
})(jQuery)}if(typeof jQuery=='undefined'){var j=d.createElement('script');j.type='text/javascript';j.src='https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';d.body.appendChild(j);j.onload=l}else{l()}})(document);
// refs
// http://qiita.com/tecking/items/bc081f3a2b546d8f8054
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment