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) + '/01';
}
}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) + '/01';
}
}
}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
input:\n
output:\n
novelty:\n
---\n
\n
# What:\n
> What does the paper solve?\n
# Why:\n
> Why is it important?\n
> Why is it better than previous work?\n
> Why can't past methods solve the problem?\n
# How:\n
> What is the key idea?\n
# Results:\n
> How do they demonstrate success?\n
> How do they evaluate the method?\n
# Thoughts:\n
> How can the key idea be used elsewhere?\n
> What is unsolved/wrong?\n
> What did you learn?\n
> **What do you read next?**\n
`;
window.open('obsidian://new?vault=research_vault&file=related papers/%27+ encodeURIComponent(title_nocolon.trim())+ %27&content=%27+ encodeURIComponent(content)); })()
- すでに同じファイルが存在している場合は重複したファイルが作成されてしまうので修正が必要