MCPcopy Index your code
hub / github.com/hoothin/UserScripts / createImg

Function createImg

RandomSexyPic/randomSexyPic.user.js:521–581  ·  view source on GitHub ↗
(url)

Source from the content-addressed store, hash-verified

519 }
520
521 function createImg(url){
522 let img=document.createElement("img");
523 img.onerror=e=>{
524 img.style.display="none";
525 };
526 img.src=url;
527 img.className="list-show";
528 img.style.width="100%";
529 img.onclick=()=>{
530 if(grabed){
531 grabed=false;
532 return;
533 }
534 window.scrollTo(0,0);
535 var de=document.documentElement;
536 var body=document.body;
537 var backCompat=document.compatMode=='BackCompat';
538 var windowSize={
539 h: backCompat ? body.clientHeight : de.clientHeight,
540 w: backCompat ? body.clientWidth : de.clientWidth,
541 };
542 if(img.style.zIndex==2){
543 restoreImg(img);
544 }else if(img.style.zIndex==1){
545 img.style.bottom="";
546 img.style.width="";
547 img.style.maxWidth="";
548 img.style.maxHeight="";
549 img.style.zIndex=2;
550 img.style.cursor="grab";
551 grabHandler(img,true);
552 document.body.style.overflow="";
553 imgCon.style.maxWidth="100vw";
554 imgCon.style.maxHeight="100vh";
555 }else{
556 if(hasFloatImg)return;
557 hasFloatImg=img;
558 document.body.style.overflow="hidden";
559 img.style.bottom=0;
560 if(img.naturalWidth>windowSize.w || img.naturalHeight>windowSize.h){
561 img.style.zIndex=1;
562 img.style.maxWidth="99%";
563 img.style.maxHeight="99%";
564 }else{
565 img.style.zIndex=2;
566 img.style.maxWidth="";
567 img.style.maxHeight="";
568 }
569 img.style.width="";
570 img.style.position="absolute";
571 img.style.margin="auto";
572 overMask.style.display="block";
573 img.className="";
574 setTimeout(()=>{
575 overMask.style.opacity=1;
576 }, 0);
577 }
578 };

Callers 2

parsePicsFunction · 0.85

Calls 2

restoreImgFunction · 0.85
grabHandlerFunction · 0.85

Tested by

no test coverage detected