Skip to content

Commit

Permalink
Added support for new.vk.com (#108) (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
4r2r authored and cgravolet committed Aug 16, 2016
1 parent 7012f1f commit 08867d1
Showing 1 changed file with 38 additions and 10 deletions.
48 changes: 38 additions & 10 deletions src/js/plugins/vk.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,46 @@ var vk = Object.create(Plugin);
vk.init("vk", "VK");

vk.scrape = function () {
var gpPlay = $("#gp_play");
var isPlaying = gpPlay && gpPlay.hasClass("playing");
var info = {
stopped: !isPlaying
};

if (isPlaying) {
info.artist = $("#gp_performer").text();
info.title = $("#gp_title").text();
function vknew() {
var info = { stopped: true };

var player = $("#top_audio_player");
if(!player.length) { return info; }

var playing = player.hasClass("top_audio_player_playing");
if(!playing) { return info; }

var title =
player
.find('.top_audio_player_title')
.text()
.split('–'); // Unicode: EN DASH
if(title.length != 2) { return info; }

info.stopped = false;
info.artist = title[0];
info.title = title[1];

return info;
}

function vkold() {
var gpPlay = $("#gp_play");
var isPlaying = gpPlay && gpPlay.hasClass("playing");
var info = {
stopped: !isPlaying
};

if (isPlaying) {
info.artist = $("#gp_performer").text();
info.title = $("#gp_title").text();
}

return info;
}

return info;
var hostname = window.location.hostname;
return hostname.startsWith('new.vk') ? vknew() : vkold();
};

module.exports = vk;

0 comments on commit 08867d1

Please sign in to comment.