Great addition.
I think it may not work with this page if you’re using Obsidian in Windows because the file it’s trying to create contains a colon character (: ) as it’s obtained from the page title. And Windows doesn’t allow it.
To fix this minor issue I’ve just cleaned the filename replacing non-word characters from the title with a hyphen (-):
const file = title.replaceAll(/[^\w]/ig, '-').replaceAll(/[_-]+/g, '-');
The final bookmarklet looks like this:
javascript:(function(){
const title = document.title;
const file = title.replaceAll(/[^\w]/ig, '-').replaceAll(/[_-]+/g, '-');
const selectedText = window.getSelection().toString();
const url = document.location.href;
const tag = '#saved_from_chrome';
const content = `# ${title}
${selectedText != "" ? `${"\n"} > ${selectedText.replaceAll("\n", "\n> ")}` : "" }
${"\n\n"}
- [${title}](${url})
${"\n\n"}
${tag}`;
document.location.href = `obsidian://new?name=${encodeURIComponent(file)}&content=${encodeURIComponent(content)}&vault=VAULTNAMEHERE`
})();