Last active
October 18, 2023 17:54
-
-
Save zakuroishikuro/635baa26ac0cb5726c0cfaf1acf5b57a to your computer and use it in GitHub Desktop.
logseq bookmarklet
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: (()=>{ | |
const {hostname, pathname} = location; | |
let page = hostname + pathname; | |
let content = ""; | |
const now = new Date(); | |
const date = now.toLocaleDateString().replace(/\//g, "-"); | |
const time = now.toLocaleTimeString(); | |
content = `source:: [${document.title}](${location.href})\ncreated:: [[${date}]] ${time}`; | |
if (hostname == "www.youtube.com" && pathname == "/watch") { | |
const title = document.querySelector("#title.ytd-watch-metadata").textContent.trim(); | |
const id = location.search.slice(3); | |
const channel = document.querySelector("#upload-info a").textContent.trim(); | |
page = `${channel}/${title}`; | |
content = `type:: youtube\n ${content}\n{{youtube ${location.href}}}`; | |
} | |
;if (hostname == "www.uta-net.com" && pathname.match(/song/)) { | |
const title = document.querySelector("h2").textContent.trim(); | |
const propElements = [...document.querySelectorAll("[itemprop]")]; | |
const propList = propElements.map(prop=>{ | |
return [prop.attributes.itemprop.value, prop.textContent.trim()]; | |
} | |
); | |
const dict = Object.fromEntries(propList); | |
page = `${title}`; | |
const props = [ | |
`type:: song`, | |
`artist:: ${dict.byArtist}`, | |
`作詞:: ${dict.lyricist}`, | |
`作曲:: ${dict.composer}`, | |
`編曲:: ${dict.arranger}`, | |
content, | |
]; | |
content = props.join("\n"); | |
}; | |
content = encodeURIComponent(content); | |
page = encodeURIComponent(page); | |
const url = `logseq://x-callback-url/quickCapture?page=${page}&content=${content}`; | |
/*const url = `logseq://graph/JungleGraph?page=${page}`;*/ | |
location.href = url; | |
} | |
)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment