Styx / iStock Easy Download

// ==UserScript==
// @name         iStock Easy Download
// @namespace    https://openuserjs.org/users/Styx
// @version      0.5
// @description  Helps to download images from iStock
// @author       Styx
// @copyright    2017, Styx (https://fanfics.me/user159153)
// @license      MIT; https://opensource.org/licenses/MIT
// @include      https://www.istockphoto.com/*
// @grant        none
// @noframes
// @updateURL    https://openuserjs.org/meta/Styx/iStock_Easy_Download.meta.js
// ==/UserScript==

// ==OpenUserJS==
// @author Styx
// ==/OpenUserJS==

function addCSS() {
  const CSS = `
    .ised-button {
      position: absolute; left: 16px; top: 16px; display: block;
      width: 41px; line-height: 41px; text-align: center;
      padding: 0 8px; font-size: 20px; cursor: pointer;
      background: rgba(12,13,13,0.65); border-radius: 2px;
      font-weight: 400;
      color: #fff; opacity: 0;
      -webkit-transition: opacity .25s ease-in-out;
      transition: opacity .25s ease-in-out;
    }
    .ised-button.ised-last {
      left: 64px;
    }
    .ised-button:hover {
      background-color: #02a388;
      color: #fff;
    }
    article.gallery-mosaic-asset__container .ised-button {
      width: 38px;
      line-height: 38px;
      top: 10px;
      left: 10px;
    }
    article.gallery-mosaic-asset__container .ised-button.ised-last {
      left: 58px;
    }
    article.gallery-mosaic-asset__container:hover .ised-button {
      opacity: 1;
    }
    .image-card .ised-button {
      opacity: 1;
    }    
  `;

  const head = document.head || document.getElementsByTagName('head')[0];
  const style = document.createElement('style');
  style.type = 'text/css';
  if (style.styleSheet) {
    style.styleSheet.cssText = CSS;
  } else {
    style.appendChild(document.createTextNode(CSS));
  }
  head.appendChild(style);
}

addCSS();

const $A = $('<a class="ised-button" target="_blank">A</a>');
const $a = $('<a class="ised-button ised-last" target="_blank">a</a>');
const $G = $('<a class="ised-button ised-last">G</a>');

$(document).on('mouseenter', 'article.gallery-mosaic-asset__container', function (e) {
  const $e = $(e.target).closest('article.gallery-mosaic-asset__container');
  const el = $e.get(0);
  if (el.classList.contains('ised')) {
    return;
  }
  let i, src;
  i = el.querySelector('meta[itemprop="thumbnailUrl"]');
  if (i != null) {
    src = i.getAttribute('content');
  } else {
    i = el.querySelector('a > figure > img');
    src = i.getAttribute('src');
  }
  const srcBig = src.split('?').shift() + '?s=2048x2048';
  $A.clone().attr('href', srcBig).appendTo(el);
  $a.clone().attr('href', src).appendTo(el);
  el.classList.add('ised');
});

$('.image-card').each(function (idx, el) {
  if (el.classList.contains('ised')) {
    return;
  }
  const i = el.querySelector('.preview');
  const srcBig = i.getAttribute('data-zoom-url');
  const srcGIS = 'https://www.google.com/searchbyimage?image_url=' + encodeURIComponent(srcBig);
  $A.clone().attr('href', srcBig).appendTo(el);
  $G.clone().attr('href', srcGIS).appendTo(el);
  el.classList.add('ised');
});