Skip to content

Instantly share code, notes, and snippets.

@Steppschuh
Created March 31, 2018 18:34
Show Gist options
  • Save Steppschuh/60ae2fbea4beb0309071b741f3068eff to your computer and use it in GitHub Desktop.
Save Steppschuh/60ae2fbea4beb0309071b741f3068eff to your computer and use it in GitHub Desktop.
Get the image URL of photos viewed on 500px
/**
* 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