Created
March 31, 2022 14:00
-
-
Save Kenya-West/9b8f6eb274defee33241f7f5a863e82e to your computer and use it in GitHub Desktop.
Get links of external videos you have in wall (on your profile VK.com)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const config = { | |
timeToLoad: 350, | |
timeToUnload: 350, | |
}; | |
let videoSet = new Set(); | |
let result = []; | |
const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); | |
const getVideoLinks = async () => { | |
// const posts = document.querySelectorAll( | |
// ".post[data-post-id]" | |
// ); | |
const videos = document.querySelectorAll( | |
".post_content .wall_text .page_post_sized_thumbs > a[data-video]" | |
); | |
console.log(`Found ${videos.length} videos`); | |
for (let i = 0; i < videos.length - 1; i++) { | |
const videoId = videos[i].attributes.getNamedItem("data-video")?.value; | |
const listId = videos[i].attributes.getNamedItem("data-list")?.value; | |
console.log( | |
`Open video by id: ${videoId ?? "NOTHING FOUND"} and from list: ${ | |
listId ?? "NOTHING FOUND" | |
}` | |
); | |
showVideo( | |
videoId, | |
listId, | |
{ | |
autoplay:1, | |
queue:1 | |
}, | |
event, | |
this | |
); | |
await sleep(config.timeToLoad); | |
console.log(`Now wait ${config.timeToLoad ?? 500} ms`); | |
const videoSrc = document.querySelector( | |
"#mv_container #mv_main #mv_player_box #video_player" | |
)?.src; | |
console.log( | |
`Found videoSrc: ${videoSrc ?? "NOTHING FOUND"}, adding to collection...` | |
); | |
if (videoSrc) { | |
videoSet.add(videoSrc); | |
console.log(`Added!`); | |
} | |
console.log(`Hide videoplayer and wait...`); | |
await sleep(config.timeToLoad); | |
Videoview.hide(true, true, event, true); | |
} | |
console.log(` | |
LINK TO VIDEOS: | |
`); | |
const result = [...videoSet]; | |
console.dir(result); | |
}; | |
getVideoLinks(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment