Skip to content

Instantly share code, notes, and snippets.

@litvinovvo
litvinovvo / vk_add_audio_to_the_playlist.js
Created August 23, 2020 12:46
add vk audio to the given playlist
// scroll down fully
var songs = document.querySelectorAll('.audio_row');
var playlistId = '15359214_51903820';
for (var i = songs.length - 1; i >= 0; i--) {
console.log(i, 'more');
const mouseoverEvent = new Event('mouseover');
songs[i].dispatchEvent(mouseoverEvent);
await new Promise((a)=>setTimeout(a, 500));
songs[i].querySelector('.audio_row__action_more').click();
@litvinovvo
litvinovvo / getboundingClientRect.js
Created March 5, 2020 16:27
Long task free getboundingClientRect
function getBoundingClientRect(element) {
return new Promise(resolve => {
const observer = new IntersectionObserver(([entity]) => {
observer.unobserve(element);
observer.disconnect();
resolve(entity.boundingClientRect);
});
observer.observe(element);
});