Last active
October 10, 2020 16:47
-
-
Save ykessler/9623f5e85258808f24a3e2f03e6f6f0a to your computer and use it in GitHub Desktop.
Generates a markdown link for the page.
This file contains hidden or 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: | |
var og_site = document.querySelector("meta[property='og:site_name']") ? document.querySelector("meta[property='og:site_name']").getAttribute('content') : null; | |
var og_title = document.querySelector("meta[property='og:title']") ? document.querySelector("meta[property='og:title']").getAttribute('content') : null; | |
var channel = (og_site == 'YouTube' && document.querySelector("a.ytp-ce-channel-title")) ? 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})`; | |
void(prompt('Markdown link', link)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment