Skip to content

Instantly share code, notes, and snippets.

@ykessler
Last active September 19, 2020 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ykessler/750c9b599a92c29e897b0b7ff93b0ed2 to your computer and use it in GitHub Desktop.
Save ykessler/750c9b599a92c29e897b0b7ff93b0ed2 to your computer and use it in GitHub Desktop.
Generates a markdown link for the page, along with an italicized page description. See also https://gist.github.com/ykessler/9623f5e85258808f24a3e2f03e6f6f0a.
javascript: var og_site = document.querySelector("meta[property='og:site_name']").getAttribute('content');
var og_title = document.querySelector("meta[property='og:title']").getAttribute('content');
var og_desc = document.querySelector("meta[property='og:description']").getAttribute('content').replace(/\s+/g, " ");
var channel = (og_site == 'YouTube') ? document.querySelector("a.ytp-ce-channel-title").text : null;
var title = og_title ? `${og_title}` : document.title;
if(channel){title = `${title} - ${channel}`};
if(og_site){title = `${title} - ${og_site}`};
if (title) {
var re = /(\\|\/|:|\*|\?|\"|<|>|\|)/gi;
title = title.replace(re, '');
link = `[${title}](${window.location}) - __${og_desc}__`;
void(prompt('Markdown snnip', link));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment