MCPcopy Create free account
hub / github.com/hoothin/UserScripts / getImgWH

Function getImgWH

JiandanHero/JiandanHero.user.js:23–40  ·  view source on GitHub ↗
(img,callBack)

Source from the content-addressed store, hash-verified

21(function() {
22 'use strict';
23 var timer,tempImg=document.createElement("img"),getImgWH=function(img,callBack){
24 if(timer)clearInterval(timer);
25 tempImg.src="";
26 tempImg.src=img.src;
27 var check=function(){
28 if(tempImg.width>0 || tempImg.height>0){
29 if(timer)clearInterval(timer);
30 callBack(tempImg.width,tempImg.height);
31 return true;
32 }else{
33 return false;
34 }
35 };
36 var geted=check();
37 if(!geted){
38 timer = setInterval(check,40);
39 }
40 };
41
42 document.addEventListener("keyup", function(e) {
43 if(/INPUT|TEXTAREA/.test(document.activeElement.tagName))return;

Callers 1

Calls 1

checkFunction · 0.85

Tested by

no test coverage detected