Auto zoom lone images

Automatically zoom small standalone images

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           Auto zoom lone images
// @id             dc989f0a-f9e6-4507-ba5f-a0730a614553@http://forums.mozillazine.org/memberlist.php?mode=viewprofile&u=261941
// @version        2.5
// @namespace      http://forums.mozillazine.org/memberlist.php?mode=viewprofile&u=261941
// @author         Gingerbread Man
// @description    Automatically zoom small standalone images
// @include      /http?://.*\.gif.*
// @include      /http?://.*\.jpg.*
// @include      /http?://.*\.png.*
// @include      /https?://.*\.gif.*
// @include      /https?://.*\.jpg.*
// @include      /https?://.*\.png.*
// @include      /https?://.*\.webp.*
// @exclude  https://www.google.com/imgres*
// @run-at         window-load
// @license			MIT
// ==/UserScript==

// Reference: https://support.mozilla.org/en-US/questions/942713

var img = document.images[0];
var iw = img.width;
var ih = img.height;
var ir = iw / ih;

function togglezoom() {
	if (img.width>iw||img.height>ih) {
		img.width = iw;
		img.height = ih;
		img.setAttribute("style","cursor:-moz-zoom-in");
	}
	else zoomin();
}

function zoomin() {
	var ww = window.innerWidth;
	var wh = window.innerHeight;

	if (iw<ww&&ih<wh) {
            console.log("here0");
		img.addEventListener("click", togglezoom, false);
		var zohw = wh * ir;

		if (zohw<=ww) {
            console.log("here1");
			img.height = wh;
			img.width = img.height * ir;
			img.setAttribute("style","cursor:-moz-zoom-out");
		}

		else {
            console.log("here2");
			img.width = ww;
			img.height = img.width / ir;
			img.setAttribute("style","cursor:-moz-zoom-out");
		}

	}

}

zoomin();

//.user.js