B1KMusic

Newgrounds Image Dump Item fullsize viewer script ALT

May 3rd, 2014
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Newgrounds image viewer script by Braden Best
  3.  * To use: inject this script into a NG dump item page, and click on the image
  4.  */
  5.  
  6. (function(){
  7.   function push(url){
  8.     var img = document.createElement('img'),
  9.         img_helper = document.createElement('div');
  10.     // Image
  11.     img.src = url;
  12.     img.style.position = 'absolute';
  13.     img.style.left = '0px';
  14.     img.style.top  = '40px';
  15.     img.style.zIndex = '10000'; // this is to push it above everything else, so the NG navbar doesn't float over it.
  16.     // Image helper
  17.     img_helper.innerHTML = "Click here to close image";
  18.     img_helper.style.position = 'absolute';
  19.     img_helper.style.left = '0px';
  20.     img_helper.style.top  = '0px';
  21.     img_helper.style.margin = '0';
  22.     img_helper.style.padding = '5px 0';
  23.     img_helper.style.width = '100%';
  24.     img_helper.style.height='30px';
  25.     img_helper.style.background = '#fff';
  26.     img_helper.style.color = '#000';
  27.     img_helper.style.fontSize = '24px';
  28.     img_helper.style.textAlign = 'center';
  29.     img_helper.style.zIndex = '10000';
  30.     // append to body
  31.     document.body.appendChild(img);
  32.     document.body.appendChild(img_helper);
  33.     // helper on-click
  34.     img_helper.onclick = function(){
  35.       document.body.removeChild(img);
  36.       document.body.removeChild(img_helper);
  37.       img_helper.onclick = null;
  38.     }
  39.   }
  40.   if(dimage) {
  41.     dimage.onclick = function(){
  42.       push(dimage.src);
  43.     }
  44.   } else {
  45.     var orig = document.getElementByID('dimage');
  46.     if(orig) {
  47.       orig.onclick = function(){
  48.         push(orig.src);
  49.       }
  50.     } else {
  51.       console.log("Something went wrong. Are you on an NG dump item, specifically an image?");
  52.     }
  53.   }
  54. })();
Add Comment
Please, Sign In to add comment