Image Window Fitter

When looking at a large image file that extends beyond the borders of the screen, this will fit it onto your screen

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

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 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       Image Window Fitter
// @namespace  http://use.i.E.your.homepage/
// @version    0.1
// @description  When looking at a large image file that extends beyond the borders of the screen, this will fit it onto your screen
// @match      http*://*/*.jpg
// @match      http*://*/*.jpeg
// @match      http*://*/*.png
// @match      http*://*/*.gif
// @match      http*://*/*.tif
// @match      http*://*/*.tiff
// @match      http*://*/*.bmp
// @author 	   wpatter6
// @copyright  2014+, wpatter6
// ==/UserScript==

function addJQuery(callback) {
  var script = document.createElement("script");
  script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
  script.addEventListener('load', function() {
    var script = document.createElement("script");
    script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
    document.body.appendChild(script);
  }, false);
  document.body.appendChild(script);
}

function main() {    
	jQ('img').each(function (){
        if(jQ(this).width() > Math.min(jQ(this).parent().width(), jQ(window).width())){
            console.log("Resizing image " + (jQ(this).attr("id") || ""));
            jQ(this).css({"width":"100%"});
        }
    });
}

addJQuery(main);