Skip to content

Instantly share code, notes, and snippets.

@ammgws
Created August 2, 2023 07:47
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 ammgws/9e3e3ce4fa1bd7193bf1367de1b4209c to your computer and use it in GitHub Desktop.
Save ammgws/9e3e3ce4fa1bd7193bf1367de1b4209c to your computer and use it in GitHub Desktop.
Bookmarklet to get Reddit Video fallback URL (tested in Firefox)
javascript:(function() {
var currentUrl = window.location.href;
if (!currentUrl.includes("reddit")) {
alert("This bookmarklet is designed for Reddit pages only.");
return;
}
var jsonUrl = currentUrl + ".json";
fetch(jsonUrl)
.then(response => response.json())
.then(data => {
var mediaData = data[0]?.data?.children[0]?.data?.media;
var fallbackUrl = mediaData?.reddit_video?.fallback_url;
if (fallbackUrl) {
alert("Fallback URL: " + fallbackUrl);
} else {
alert("No 'fallback_url' property found in the JSON data.");
}
})
.catch(error => {
alert("Error fetching the JSON data: " + error);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment