- Feb 7, 2020
- 228
- 7,435
You must be registered for see medias
Comment
// Get all iframe elements on the page
const iframes = document.querySelectorAll('iframe');
// Initialize an array to hold the transformed URLs
const vimeoLinks = [];
// Loop through each iframe element
iframes.forEach(iframe => {
// Get the src attribute of the iframe
const url = iframe.src;
// Check if the src starts with the specific Vimeo player URL pattern
const match = url.match(/\/\/player\.vimeo\.com\/video\/(\d+)\?h=(\w+)/);
if (match) {
// Transform the URL to the desired format
const transformedUrl = `https://vimeo.com/${match[1]}/${match[2]}`;
vimeoLinks.push(transformedUrl);
}
});
// Log the transformed URLs
console.log(vimeoLinks);
Any help?
Thanks!