Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A bookmarklet for downloading currently viewed Flickr image in the biggest available size
/*jslint browser, maxlen: 80 */
/*global DOMParser, fetch */
(function () {
"use strict";
var originalSizeLink = document.querySelector(".Original > a");
var canonicalUrl = document.querySelector("#canonicalurl").href;
var biggestSizeUrl = canonicalUrl + "/sizes/k/";
var secondBiggestSizeUrl = canonicalUrl + "/sizes/h/";
function downloadImage(href) {
var a = document.createElement("a");
a.href = href; = document.title.split(" |")[0] + ".jpg";
function getHrefAndDownloadImage(responseText) {
var href = new DOMParser()
.parseFromString(responseText, "text/html")
.querySelector("#allsizes-photo > img")
if (originalSizeLink) {
.then(function (response) {
return (response.ok && response.url === biggestSizeUrl)
? response
: fetch(secondBiggestSizeUrl);
.then(function (response) {
return response.text();

This comment has been minimized.

Copy link

commented Feb 12, 2018

How to add it to Chrome?
I created a new bookmark and edited the URL as javascript:your code
But nothing happen when clicked!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.