Skip to content

Instantly share code, notes, and snippets.

@qrg
Last active July 31, 2019 08:24
Show Gist options
  • Select an option

  • Save qrg/649a7ca0a4c0ee7841dd6e9b69a75d48 to your computer and use it in GitHub Desktop.

Select an option

Save qrg/649a7ca0a4c0ee7841dd6e9b69a75d48 to your computer and use it in GitHub Desktop.
A bookmarklet to copy shared image's source url on Google Photo.
javascript: (function() {
const isSharedPage = url => url.startsWith("https://photos.google.com/share/");
if (!isSharedPage(location.href)) {
alert(
"Cannot run this script.\nTry opening a shared Google Photo page that has following URL.\n\n* https://photos.google.com/share/...\n"
);
return;
}
const copy = text => {
const textarea = document.createElement("textarea");
const selection = document.getSelection();
textarea.textContent = text;
document.body.appendChild(textarea);
selection.removeAllRanges();
textarea.select();
document.execCommand("copy");
selection.removeAllRanges();
document.body.removeChild(textarea);
};
const PARAM = "s0-no";
const src = document.querySelector('.RY3tic').dataset.latestBg;
const link = `${src.split("=")[0]}=${PARAM}`;
copy(link);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment