您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Enables Maxthon4 to zoom in images smaller than the screen to fit into the window or zoom back to its original size.
当前为
- // ==UserScript==
- // @name SmallImageZoom
- // @author ElDoRado1239
- // @version 0.93
- // @description Enables Maxthon4 to zoom in images smaller than the screen to fit into the window or zoom back to its original size.
- // @include *.jpg
- // @include *.jpeg
- // @include *.png
- // @include *.gif
- // @namespace https://greasyfork.org/users/6103
- // ==/UserScript==
- var img = document.getElementById('img_elem');
- var drag = false;
- var mdown = false;
- var state = 0;
- setTimeout(init,10);
- function init(){
- if(img.naturalWidth == 0) setTimeout(init,10);
- else{
- if(img.naturalHeight >= window.innerHeight || img.naturalWidth >= window.innerWidth){
- img.onmousemove = undefined;
- img.onmouseup = undefined;
- img.onmousedown = undefined;
- return;
- }
- img.onmousedown = mouseDown;
- img.onmousemove = mouseMove;
- img.onmouseup = mouseUp;
- window.onresize = mouseUp;
- mouseUp('init');
- }
- }
- function mouseDown(e){
- if(e.which != 3) mdown = true;
- }
- function mouseMove(){
- if(mdown){
- drag = true;
- img.style.cursor = "all-scroll";
- }
- }
- function mouseUp(e){
- if(mdown==false && e!='init') return;
- mdown = false;
- switch(state){
- case 0:{
- if(drag){
- drag = false;
- img.style.cursor = "-webkit-zoom-in";
- return;
- }
- if(img.naturalHeight>=img.naturalWidth){
- img.style.height = window.innerHeight;
- img.style.width = window.innerHeight*(img.naturalWidth/img.naturalHeight);
- img.style.left = ((window.innerWidth-parseInt(img.style.width))/2)+"px";
- img.style.top = "0px";
- }
- if(img.naturalWidth>img.naturalHeight){
- img.style.width = window.innerWidth;
- img.style.height = window.innerWidth*(img.naturalHeight/img.naturalWidth);
- img.style.left = "0px";
- img.style.top = ((window.innerHeight-parseInt(img.style.height))/2)+"px";
- }
- if(parseInt(img.style.width)>window.innerWidth){
- img.style.width = window.innerWidth;
- img.style.height = window.innerWidth*(img.naturalHeight/img.naturalWidth);
- img.style.left = "0px";
- img.style.top = ((window.innerHeight-parseInt(img.style.height))/2)+"px";
- }
- if(parseInt(img.style.height)>window.innerHeight){
- img.style.height = window.innerHeight;
- img.style.width = window.innerHeight*(img.naturalWidth/img.naturalHeight);
- img.style.left = ((window.innerWidth-parseInt(img.style.width))/2)+"px";
- img.style.top = "0px";
- }
- img.style.cursor = "-webkit-zoom-out";
- state++;
- return;
- }
- case 1:{
- if(drag){
- drag = false;
- img.style.cursor = "-webkit-zoom-out";
- return;
- }
- img.style.width = img.naturalWidth;
- img.style.height = img.naturalHeight;
- img.style.left = ((window.innerWidth-parseInt(img.style.width))/2)+"px";
- img.style.top = ((window.innerHeight-parseInt(img.style.height))/2)+"px";
- img.style.cursor = "-webkit-zoom-in";
- state--;
- return;
- }
- }
- }