Skip to content

Instantly share code, notes, and snippets.

@litvinovvo
litvinovvo / vk_add_audio_to_the_playlist.js
Created Aug 23, 2020
add vk audio to the given playlist
View vk_add_audio_to_the_playlist.js
// 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 Mar 5, 2020
Long task free getboundingClientRect
View getboundingClientRect.js
function getBoundingClientRect(element) {
return new Promise(resolve => {
const observer = new IntersectionObserver(([entity]) => {
observer.unobserve(element);
observer.disconnect();
resolve(entity.boundingClientRect);
});
observer.observe(element);
});