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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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);