((window, document) => {
  let encode = window.encodeURIComponent;
  let t;
  let url = (t=document.querySelector("link[rel=canonical]")) && t.href;
  url = url || ((t=document.querySelector('meta[property="og:url"],meta[property="twitter:url"]')) && t.content);
  url = url || location.href;
  let title = (t=document.querySelector('meta[property="og:title"],meta[property="twitter:title"]')) && t.content;
  title = title || document.title;

  let q = {
    url: encode(url),
    caption: encode(`<a href="${url}">${title}</a>`),
  };

  // extract imgage

  // twitter images
  let query = "#permalink-overlay [data-element-context='platform_photo_card'] img";
  let imgs = Array.from(document.querySelectorAll(query))
      .map(i => i.src + ":orig");
  if (imgs.length !== 0) {
    q.posttype = "photo";
    q.content = imgs.map(encode).join(",");
  }

  window.open('https://www.tumblr.com/widgets/share/tool?'+Object.entries(q).map(e => e.join("=")).join("&"),
              '_blank');
})(window, document);

((window, document) => {
  const encode = window.encodeURIComponent;
  const $ = document.querySelector.bind(document);
  const $$ = document.querySelectorAll.bind(document);
  const url = ((t=$("link[rel=canonical]")) && t.href)
        || ((t=$('meta[property="og:url"],meta[property="twitter:url"]')) && t.content)
        || location.href;
  const title = document.title;

  const q = {
    url: encode(url),
    caption: encode(`<a href="${url}">${title}</a>`),
  };

  // extract imgage
  // twitter
  const query = "#permalink-overlay [data-element-context='platform_photo_card'] img";
  const imgs = Array.from($$(query))
      .map(i => i.src + ":orig");
  if (imgs.length !== 0) {
    q.posttype = "photo";
    q.content = imgs.map(encode).join(",");
  }

  window.open('https://www.tumblr.com/widgets/share/tool?'+Object.entries(q).map(e => e.join("=")).join("&"),
              '_blank');
})(window, document);

Fix title