Created
December 12, 2023 00:12
-
-
Save yashihei/2d197d6393cecc2fe82dde73b466b9cf to your computer and use it in GitHub Desktop.
スクマ(日付+OGP付き)
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
javascript: (function() { | |
var title = window.prompt(`Scrap "${document.title}" to yashihei-bookmark.`, document.title); | |
if (!title) return; | |
var ogImage = document.querySelector('meta[property="og:image"]') ? document.querySelector('meta[property="og:image"]').getAttribute('content') : ''; | |
var ogDescription = document.querySelector('meta[property="og:description"]') ? document.querySelector('meta[property="og:description"]').getAttribute('content') : ''; | |
var lines = ['[' + window.location.href + ' ' + document.title + ']']; | |
var today = new Date(); | |
var formattedDate = today.getFullYear() + '-' + String(today.getMonth() + 1).padStart(2, '0') + '-' + String(today.getDate()).padStart(2, '0'); | |
lines.push('bookmarked: ' + formattedDate); | |
if (ogImage) lines.push('[' + ogImage + ']'); | |
if (ogDescription) lines.push('> ' + ogDescription); | |
var quote = window.getSelection().toString(); | |
if (quote.trim()) { | |
lines = lines.concat(quote.split(/\n/g).map(function(line) { | |
return ' > ' + line; | |
})); | |
} | |
var body = encodeURIComponent(lines.join('\n')); | |
window.open('https://scrapbox.io/yashihei-bookmark/' + encodeURIComponent(title.trim()) + '?body=' + body); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment