forked from justan/gmscrobber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bus.fm_scrobber.user.js
40 lines (36 loc) · 1.21 KB
/
bus.fm_scrobber.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// ==UserScript==
// @name bus.fm scrobber
// @namespace http://gmscrobber.whosemind.net
// @description 记录 bus.fm 到 last.fm
// @include http://bus.fm/
// @include http://bus.fm/#*
// @include http://bus.fm/?*
// @require https://raw.github.com/justan/lrc/master/lrc.js
// @require https://raw.github.com/justan/gmscrobber/master/simple_scrobbler_user.js
// @version 0.1
// ==/UserScript==
var meta = uso.metaParse(GM_info.scriptMetaStr);
var scrobber = new Scrobbler({
name: 'Bus.fm',
ready: function () {
log('初始化');
scrobber.on('nowplaying', function(){
scrobber.getInfo(scrobber.song, function(info){
document.getElementById('s-title').title = '在 last.fm 中记录: ' + info.len + ' 次';
});
});
scrobber.setSongInfoFN(getSongInfo);
}
});
var getSongInfo = function() {
return {
title: getInfo('s-title')
, artist: getInfo('s-artist')
, album: getInfo('s-album')
, playTime: uso.timeParse(getInfo('pt'))
, duration: Math.round(uso.timeParse(getInfo('tt')) * 100 / parseInt(document.getElementsByClassName('j-seek-bar')[0].style.width, 10))
};
};
var getInfo = function(id){
return document.getElementById(id).innerHTML;
};