Skip to content

Instantly share code, notes, and snippets.

@shanept
Last active June 4, 2023 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanept/6dfa520d825e9a50a0f39c0573ca0881 to your computer and use it in GitHub Desktop.
Save shanept/6dfa520d825e9a50a0f39c0573ca0881 to your computer and use it in GitHub Desktop.
Get Vimeo URLs
(function(){
// Quick check to make sure we are in a vimeo document
if (window.location.host !== 'player.vimeo.com') {
console.error('Not in a vimeo player document. Try again...');
return;
}
if (!window.playerConfig) {
// Vimeo URLs are stored in a script tag after the player element in the body
var s = document.getElementById("player").nextElementSibling;
// We only want the config object, let's discard the rest
var o = s.innerText.indexOf('{');
var t = s.innerText.substring(o).split("; if (!config.request)")[0];
// Now we can parse the text and turn it into a JS object
var config = JSON.parse(t);
} else {
var config = window.playerConfig;
}
// Sort so that the highest resolution video is first
config.request.files.progressive.sort(function(x,y) {
if (x.width > y.width) return -1;
if (x.width < y.width) return +1;
return 0;
});
// And open it in a new window
window.open(config.request.files.progressive[0].url);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment