Created
July 21, 2017 16:17
-
-
Save matthewpizza/60f26db61f51a4db444d349cd8f47ee4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function()%7Bvar%20images%20%3D%20document.querySelectorAll('meta%5Bname%3D%22og%3Aimage%22%5D%2Cmeta%5Bproperty%3D%22og%3Aimage%22%5D')%3Bif%20(!images.length)%20%7Breturn%3B%7Dvar%20el%20%3D%20document.createElement('div')%3BObject.assign(el.style%2C%20%7Bposition%20%20%20%20%20%20%20%3A%20'fixed'%2Ctop%20%20%20%20%20%20%20%20%20%20%20%20%3A%200%2Cleft%20%20%20%20%20%20%20%20%20%20%20%3A%200%2CzIndex%20%20%20%20%20%20%20%20%20%3A%20'2147483647'%2Cwidth%20%20%20%20%20%20%20%20%20%20%3A%20'400px'%2Cheight%20%20%20%20%20%20%20%20%20%3A%20'100%25'%2Coverflow%20%20%20%20%20%20%20%3A%20'scroll'%2CbackgroundColor%3A%20'white'%7D)%3Bfor%20(var%20i%20%3D%200%2C%20len%20%3D%20images.length%3B%20i%20%3C%20len%3B%20i%2B%2B)%20%7Bvar%20img%20%3D%20new%20Image()%3Bimg.src%20%3D%20images%5Bi%5D.content%3BObject.assign(img.style%2C%20%7Bdisplay%3A%20'block'%2Cwidth%20%20%3A%20'380px'%2Cheight%20%3A%20'auto'%2Cmargin%20%3A%20'20px%20auto'%7D)%3Bel.appendChild(img)%3B%7Dfunction%20closePanel(event)%20%7Bif%20(1%20!%3D%3D%20event.which)%20%7Breturn%3B%7Del.removeEventListener('click'%2C%20closePanel)%3Bdocument.body.removeChild(el)%3Bel%20%3D%20null%3B%7Del.addEventListener('click'%2C%20closePanel%2C%20false)%3Bdocument.body.appendChild(el)%7D)() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var images = document.querySelectorAll('meta[name="og:image"],meta[property="og:image"]'); | |
if (!images.length) { | |
return; | |
} | |
var el = document.createElement('div'); | |
Object.assign(el.style, { | |
position : 'fixed', | |
top : 0, | |
left : 0, | |
zIndex : '2147483647', | |
width : '400px', | |
height : '100%', | |
overflow : 'scroll', | |
backgroundColor: 'white' | |
}); | |
for (var i = 0, len = images.length; i < len; i++) { | |
var img = new Image(); | |
img.src = images[i].content; | |
Object.assign(img.style, { | |
display: 'block', | |
width : '380px', | |
height : 'auto', | |
margin : '20px auto' | |
}); | |
el.appendChild(img); | |
} | |
function closePanel(event) { | |
if (1 !== event.which) { | |
return; | |
} | |
el.removeEventListener('click', closePanel); | |
document.body.removeChild(el); | |
el = null; | |
} | |
el.addEventListener('click', closePanel, false); | |
document.body.appendChild(el); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment