Upsize Stand-Alone Images

Proportionally enlarge smaller stand-alone images

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Upsize Stand-Alone Images
// @author      Jefferson "jscher2000" Scher
// @namespace   JeffersonScher
// @version     0.5.2
// @copyright   Copyright 2017 Jefferson Scher
// @license     BSD-3-Clause
// @description Proportionally enlarge smaller stand-alone images
// @match       http*://*/*
// @grant       none
// ==/UserScript==

var tgt;
function resizeImg(e){
  var whratio = tgt.width / tgt.height;
  var wnew = window.innerWidth;
  var hnew = Math.round(wnew * (1 / whratio));
  if (hnew > window.innerHeight){
    hnew = window.innerHeight;
    wnew = Math.round(hnew * whratio);
  }
  tgt.width = wnew;
  tgt.height = hnew;
}
var resizeTimeout;
function resizeThrottler(){
  if(!resizeTimeout){
    resizeTimeout = window.setTimeout(function(){resizeTimeout = null; resizeImg();}, 200);
  }
}
if (document.querySelector('head').innerHTML.indexOf('TopLevelImageDocument.css') > -1) {
  tgt = document.querySelector('body img'); // first image in body
  if (tgt.className.indexOf('shrinkToFit') == -1) { 
    window.addEventListener('resize', resizeThrottler, false); 
    window.setTimeout(resizeImg, 100);
  } else {
    // if Firefox is already managing resizing, do nothing
  }
}