obsidian web clipper
必要十分で自分向けに作った
General
https://scrapbox.io/files/62dca103477ba7001d5689c0.png
code:js
const url = document.URL;
const title = document.title;
const vault = "tkat0" // please replace
const folder = ""
const date = new Date();
const yyyy = date.getFullYear().toString();
const mm = (date.getMonth()+1).toString();
const dd = date.getDate().toString();
const tag = #${yyyy}/${mm}/${dd}
const fileName = ${title.replaceAll(':', '').replaceAll(/\//g, '-').replaceAll(/\\/g, '-')}.md
const content = ${tag}\n\n[${title}](${url})\n\n
// To open in a new tab, use obsidian-advanced-uri
document.location.href = obsidian://advanced-uri?
+ filepath=${encodeURIComponent(folder + fileName)}
+ &data=${encodeURIComponent(content)}
+ &mode=prepend
+ &vault=${encodeURIComponent(vault)}
update
2022/07/27
fix to use replaceAll
add the .md suffix
2022/07/24
created
Amazon
https://scrapbox.io/files/62e06ffd510a5d00223592f0.png
code:js
// please replace
const vault = "tkat0"
const folder = "books"
const tags = "#book"
const url = document.URL;
const title = document.getElementById("productTitle").innerText.trim();
const img = (document.getElementById("imgBlkFront") || document.getElementById("ebooksImgBlkFront")).src;
const date = new Date();
const yyyy = date.getFullYear().toString();
const mm = (date.getMonth()+1).toString();
const dd = date.getDate().toString();
const tag = #${yyyy}/${mm}/${dd}
const fileName = ${title.replaceAll(':', '').replaceAll(/\//g, '-').replaceAll(/\\/g, '-')}.md
const content = `${tags}
${tag}
![](${img})
`
// To open in a new tab, use obsidian-advanced-uri
document.location.href = obsidian://advanced-uri?
+ filepath=${encodeURIComponent(folder + fileName)}
+ &data=${encodeURIComponent(content)}
+ &mode=prepend
+ &vault=${encodeURIComponent(vault)}
update
2022/07/27
created