Skip to content

Commit

Permalink
[FIX #108] new.vk.com is vk.com now!; (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Gusev authored and cgravolet committed Aug 21, 2016
1 parent 08867d1 commit 5f9f32b
Showing 1 changed file with 20 additions and 40 deletions.
60 changes: 20 additions & 40 deletions src/js/plugins/vk.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,26 @@ var vk = Object.create(Plugin);
vk.init("vk", "VK");

vk.scrape = function () {
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;
}

var hostname = window.location.hostname;
return hostname.startsWith('new.vk') ? vknew() : vkold();
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;
};

module.exports = vk;

0 comments on commit 5f9f32b

Please sign in to comment.