Amazon - Big thumbnails in search results

Doubles the size of thumbnails on search result pages

// ==UserScript==
// @name           Amazon - Big thumbnails in search results
// @description    Doubles the size of thumbnails on search result pages
// @author         James Skinner <spiralx@gmail.com> (http://github.com/spiralx)
// @namespace      http://spiralx.org/
// @version        1.0.0
// @icon           data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABwklEQVQ4y5WTP2hTYRTFf0/zvanagEtDfOAmomCSTdCpeVtdNAaXrHYvGFx0E0FxMQ+3LA7BpU0HR6Gb/8gUBF8yGIT2PWtA83zaoQGPQ9KQv0Uv3OG7H/fcczj3IsmW9FTSrv49doc9tiXpEXCPsWi321SrVT53OliWxfW1NUqlEnPiCZLCcehGo6GTxigxleVyeR6TEEm98cqd9XUljFHedeX7/uh91nHmAfQsST1g+YhTGIYEQUAURfyMY2q1GvV6HYD+4eG0hGiGQavVUiaXm5GQMGYugxmAW8WiEsYok8spCAJVPO9YgBPTnI7oFgoFUqkUzWZz9BfH8awP0wwy2exoYt51JxypeN4CCb+DCRvTjqOEMUo7jiqep0KxqFXXVfw91B//hfRhY5AjF15dXObqFiTPc2zs3ISlc2An4dMDuK2hC3uvpZdI7zekOFi8wL/2pM6m9MOXNs9M7cGXOry7MZiUvAYrLpjTIMCyYH8H9rfhytag3n0Dl+9HlqQQWAGg24CPD+Hb9qCRYT/A0gXIPoN0HvpDN8ypr5akx8DdCa29FnTfQj8aICQvQXp14THZkp5LOviPcz4Y9th/AXFbL8bQrfwSAAAAAElFTkSuQmCC
// @icon64         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAANPElEQVR42t2ba0xbZ5rHfwdsxzcwhnC/BkzUAJuQtiQhaWgVTZSZJDNpp2lHI21Ws52RRlW/jPaSD6uV2u3sl+6s2tHOVtrOrDpqpQxVdjsTujCbaZO0yYdJIJcBEmBCwCQ4YILxBRvH2MZ598Mxjg22cYwT6D7SK0vH73nPef7vc3/PI5GAh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ZrcgVYnlwAAAABJRU5ErkJggg==
// @match          *://*.amazon.tld/s/*
// @grant          GM_addStyle
// @run-at         document-start
// @require        https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js
// @require        https://greasyfork.org/scripts/7602-mutation-observer/code/mutation-observer.js
// ==/UserScript==

/* jshint asi: true, esnext: true */
/* global jQuery, GM_addStyle */

(function($) {
  'use strict';

  // --------------------------------------------------------------------

  function processSummary(summary, message, func) {
    try {
      if (typeof message === 'string') {
        console.log(message, summary.added.length)
      }
      else {
        func = message
      }
      
      func($(summary.added))
    }
    catch (ex) {
      console.error(ex)
    }
  }


  // --------------------------------------------------------------------

  let observer = new MutationSummary({
    callback(summaries) {
      processSummary(summaries[0], /* 'Found %d thumbnails', */ $images => {
        $images
          .removeAttr('width height')
          .attr('src', (i, src) => src.replace(/160_\.jpg/, '320_.jpg').replace(/190,246_\.jpg/, '247,320_.jpg'))
      })
    },
    queries: [
      { element: '.s-access-image' }
    ]
  })
  
  /* jshint newcap: false */  
  GM_addStyle(`
    .s-result-item img {
      height: 320px;
      width: auto;
      max-width: 320px;
    }
  `)

})(jQuery)

jQuery.noConflict()