Last active
August 22, 2023 13:51
-
-
Save ErikDeBruijn/4d85042d0bd3be54b80e57593dccd20e to your computer and use it in GitHub Desktop.
Boost: cmd-shift-m to convert current page to markdown link.
This file contains 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
// You can use this as a boost! | |
// This code can be found at: https://gist.github.com/ErikDeBruijn/4d85042d0bd3be54b80e57593dccd20e | |
function showNotice(message) { | |
// Create a new div element for the notice | |
const noticeDiv = document.createElement('div'); | |
noticeDiv.className = 'notice'; | |
noticeDiv.innerHTML = message; | |
// Apply the CSS styles | |
noticeDiv.style.position = 'fixed'; | |
noticeDiv.style.top = '10px'; | |
noticeDiv.style.right = '10px'; | |
noticeDiv.style.backgroundColor = '#f44336'; | |
noticeDiv.style.color = 'white'; | |
noticeDiv.style.padding = '10px'; | |
noticeDiv.style.borderRadius = '5px'; | |
noticeDiv.style.cursor = 'pointer'; | |
noticeDiv.style.zIndex = '1000'; | |
// Append the notice to the body | |
document.body.appendChild(noticeDiv); | |
// Add a click event listener to dismiss the notice | |
noticeDiv.addEventListener('click', () => { | |
noticeDiv.style.display = 'none'; | |
}); | |
// Optionally, set a timeout to auto-dismiss the notice after 5 seconds | |
setTimeout(() => { | |
noticeDiv.style.display = 'none'; | |
}, 5000); | |
return "notice displayed"; | |
} | |
document.addEventListener('keydown', (event) => { | |
if ((event.metaKey || event.ctrlKey) && event.key === 'm') { | |
const url = window.location.href; | |
const title = document.title; | |
const clipStr = `[⛺️ ${title}](${url})`; | |
navigator.clipboard.writeText(clipStr); | |
console.log(showNotice(`📋 The Markdown link is on your clipboard!`)); | |
console.log("Yay. Copied markdown to clipboard..."); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment