Created
March 31, 2018 18:34
-
-
Save Steppschuh/60ae2fbea4beb0309071b741f3068eff to your computer and use it in GitHub Desktop.
Get the image URL of photos viewed on 500px
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
/** | |
* Copy & paste this code into the Google Chrome console | |
* while viewing a photo on 500px and it will open the | |
* image URL in a new tab. | |
* | |
* You can toggle the console by pressing: | |
* Ctrl+Shift+J (Windows / Linux) | |
* Cmd+Opt+J (Mac) | |
*/ | |
var imageSrc = getImageSrc(); | |
if (imageSrc) { | |
console.log(imageSrc) | |
openInNewTab(imageSrc) | |
} else { | |
console.log("Image element not found. XPaths may be outdated.") | |
} | |
function getImageSrc() { | |
const signedInXPath = "//*[@id=\"content\"]/div/div[3]/div[1]/img" | |
const signedOutXPath = "//*[@id=\"modal_content\"]/div/div[2]/div[1]/img" | |
const signedInImage = $x(signedInXPath)[0]; | |
const signedOutImage = $x(signedOutXPath)[0]; | |
if (signedInImage) { | |
return signedInImage.src | |
} else if (signedOutImage) { | |
return signedOutImage.src | |
} | |
} | |
function openInNewTab(url) { | |
var win = window.open(url, '_blank'); | |
win.focus(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment