F365 Image Resizer

Image Resizer for F365 Forum

目前為 2015-06-29 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           F365 Image Resizer
// @namespace      http://f365.com/
// @description    Image Resizer for F365 Forum
// @include        http://forum.football365.com/*
// @exclude        http://forum.football365.com/boss.htm
// @version 0.0.1.20150629150231
// ==/UserScript==


// styles =======================================
	var s = '.forumImage{border:10px solid #CCCCCC;}';
	var cssnode = document.createTextNode(s);
	var css=document.createElement('style');
	css.type='text/css';
	css.appendChild(cssnode);
	document.getElementsByTagName('head')[0].appendChild(css);

// scripts ======================================
	/*
	var scr = '\
	function clickImg(o)\
	{\
		var src;\
		src = o.src;\
		window.open(src,\'new\');\
	}';
	var script=document.createElement('script');
	script.type='text/javascript';
	script.innerHTML = scr;
	document.getElementsByTagName('head')[0].appendChild(script);
	*/
// main =========================================

window.addEventListener("load", function(e) {
	var maxSize, iHeight, iWidth, sizeGuide, size2, sizeRatio, newSize1, newSize2, x;
	var imgsrc;
	maxSize = 810;
	
	for (x=0; x<document.images.length; x++) {
		iHeight = document.images[x].height;
		iWidth = document.images[x].width;
		
		if (iHeight > iWidth){
			sizeGuide = iHeight;
			size2 = iWidth;
		} else {
			sizeGuide = iWidth;
			size2 = iHeight;
		}
		
		if (sizeGuide > maxSize){
			sizeRatio = sizeGuide / size2;
			newSize1 = maxSize;
			newSize2 = newSize1 / sizeRatio;
			
			if (iHeight > iWidth){
				document.images[x].height = newSize1;
				document.images[x].width = newSize2;
			} else {
				document.images[x].width = newSize1;
				document.images[x].height = newSize2;
			}
			document.images[x].className = 'forumImage';
			imgsrc = document.images[x].src;
			var im;
			im = document.images[x];
			im.addEventListener('click', function(thisimg){window.open(this.src,'new');}, true);
		}
	}
}, false);