arXiv のページを開いた上で、ブックマークレットで javascript を使ってページから適当な要素を抽出し Obsidian URI に投げればいい。
自分が使っているスクリプトは以下。(文字列の中に不要なスペースが入ってしまうので)スペースを開けずに 1 行に結合したうえでコピーしブックマークレットとして使用する。
- arXiv 以外にも IEEE Xplore や CVF Open Access の論文にも使いたいので場合分けしている
- 最後に URI を使って Vault 名やパスを指定しているので、お使いの環境に合わせてください
javascript:(function(){
if (document.baseURI.includes('arxiv.org/pdf')){
window.location.href = document.baseURI.replace('pdf','abs').replace('.pdf','');
} if (document.baseURI.includes('arxiv.org')){
site_name = 'arXiv';
title = document.getElementsByClassName("title mathjax")[0].innerText;
authors = document.getElementsByClassName('authors')[0].innerText;
year = document.baseURI.split('/').pop().split('.')[0];
year = year.substring(0,2) + '/' + year.substring(2,4);
}else if (document.baseURI.includes('ieeexplore.ieee.org')){
site_name = 'IEEE Xplore';
title = document.getElementsByClassName("document-title")[0].innerText;
authors = document.getElementsByClassName('authors-info-container')[0].innerText.split(';').join(',');
year = '';
}else if (document.baseURI.includes('openaccess.thecvf.com')) {
site_name = document.getElementById("header_title").innerText;
title = document.getElementById("papertitle").innerText;
authors = document.getElementById("authors").children[1].innerText;
if (document.baseURI.split('/')[3] == 'content') {
year = document.baseURI.split('/')[4] /* 'CVPR2023' */;
if (year.includes('cvpr') || year.includes('CVPR')) {
year = year.split('CVPR').at(-1) + '/06';
} else if (year.includes('iccv') || year.includes('ICCV')) {
year = year.split('ICCV').at(-1) + '/10';
} else {
year = year.split('ECCV').at(-1) + '/10';
}
}else{
year = document.baseURI.split('/')[3] /* 'content_cvpr_2018' */;
if (year.includes('cvpr') || year.includes('CVPR')) {
year = year.split('_').at(-1) + '/06';
} else if (year.includes('iccv') || year.includes('ICCV')) {
year = year.split('_').at(-1) + '/10';
} else {
year = year.split('_').at(-1) + '/10';
}
}
}else{
alert("Website not compatible!");
}
const title_nocolon = title.replace(/[:\/\\]/g, " ---");
authors_split_with_newlines = authors.replace(/,/g, '\n-');
content = `---\n
title: "${title}"\n
authors:\n
- ${authors_split_with_newlines}\n
published: ${year}\n
tags:\n
- draft\n
aliases:\n
paper link: ${document.baseURI}\n
---\n
\n
`;
window.open('obsidian://new?vault=research_vault&file=related papers/%27+ encodeURIComponent(title_nocolon.trim())+ %27&content=%27+ encodeURIComponent(content)); })()