Originally based on this bookmarklet. Updated to only link the issue/PR id for Github urls
- Right click bookmarks bar and click "add page"
- Change name to "Copy URL as markdown"
- Change url to
javascript:
, followed by the bookmarklet script.
Originally based on this bookmarklet. Updated to only link the issue/PR id for Github urls
javascript:
, followed by the bookmarklet script.(function() { | |
function copyToClipboard(text) { | |
if (document.queryCommandSupported && document.queryCommandSupported("copy")) { | |
var textarea = document.createElement("textarea"); | |
textarea.textContent = text; | |
textarea.style.position = "fixed"; /* Prevent scrolling to bottom of page in MS Edge.*/ | |
document.body.appendChild(textarea); | |
textarea.select(); | |
try { | |
return document.execCommand("copy"); /* Security exception may be thrown by some browsers.*/ | |
} catch (ex) { | |
console.warn("Copy to clipboard failed.", ex); | |
return false; | |
} finally { | |
document.body.removeChild(textarea); | |
} | |
} | |
} | |
var markdown = null; | |
var urlObject = new URL(window.location.href); | |
urlObject.searchParams.delete('utm_source'); | |
var url = urlObject.toString(); | |
if (window.location.origin === "https://github.com") { | |
var titleBlock = document.querySelector(".gh-header-title"); | |
if (titleBlock) { | |
var title = titleBlock.querySelector(".markdown-title").innerText; | |
var issue = titleBlock.querySelector(".color-fg-muted").innerText; | |
markdown = `[${title} - ${issue}](${url})`; | |
} | |
} | |
if (!markdown) { | |
markdown = `[${document.title}](${url})`; | |
} | |
copyToClipboard(markdown); | |
})(); |