Skip to content

Instantly share code, notes, and snippets.

@fogrew
Last active December 7, 2016 12:01
Show Gist options
  • Save fogrew/e0dedb5e1c1fa3803f82 to your computer and use it in GitHub Desktop.
Save fogrew/e0dedb5e1c1fa3803f82 to your computer and use it in GitHub Desktop.
vk.com music bookmarklets
// Alarm
var played = 0;
var time = prompt("Во сколько разбудить?", "6:55");
var waiting = setInterval(function() {
if ((new Date()) > (new Date("May,05,2015,"+time)) && played == 0) { // it is time to awake?
played = 1;
document.getElementById('play72450163_91647005').click();
clearInterval(waiting);
}
}, 1000 * 60 * 3); // to check every 3 minutes
// Lullaby
// run on page
// https://new.vk.com/audios72450163?q=snow
// https://vk.com/audios72450163?q=snow
$ = (query) => document.querySelector(query);
is = (node, query) => node.classList.contains(query);
var timer = prompt("When the turn off?", 30);
var repeat = $('#ac_repeat') || $('._audio_page_player_repeat');
var play = $('#ac_play') || $('._audio_page_player_play');
// turn track repeat
if(!is(repeat, 'on') && !is(repeat, 'audio_page_player_btn_enabled')) {
repeat.click();
}
// turn track
if(!is(play, 'audio_playing')) {
$('#play_72450163_163994377').click();
}
// stop playing when timer expires
setTimeout(() => play.click(), 1000 * 60 * timer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment