4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GooglePlayMusicのNow PlayingをTweetするだけのBookmarklet

Last updated at Posted at 2016-05-23

なんとなく初投稿です.

動機

特に無いですが,暇つぶし.調べて出てくるブックマークレットが使えなかったので,とりあえず自分で作ってみました.

コード

Gistはここ

google-music-bookmarklet.js
javascript:(function(){
    var song = document.querySelector("#currently-playing-title").innerHTML;
    var artist = document.querySelector("#player-artist").innerHTML;
    var album = document.querySelector(".player-album").innerHTML;
    var text = encodeURIComponent("Now playing on Google Play Music: " + song + " - " + artist + " in " + album);
    window.open('https://twitter.com/intent/tweet?text=' + text + '&hashtags=NowPlaying', '', 'width=550, height=420');
})();

(これ書いててquerySelectorっていうメソッドの存在を初めて知ったんですけど,getElementBy*より汎用性高くて良くないですか?)(最近jQuery使ってたからか)

曲名のidがcurrently-playng-titleだったりするのがポイントでしょうか.ググって出てくる過去の遺産を見てるとplay-songなるidがあるけど,今は見当たらず…

ちょっとモニョッたこと

Web Intentからだと画像の投稿ができないのがちょっと残念です.認証通ってればmedia/uploadに上げてから埋め込みできるけど,流石にブックマークレットでやるにはちょっとやり過ぎ感ありますね.

2016/09/25追記

続編ができました

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?