書誌情報を取り込むブックマークレット
code:bookmarklet.js
code:ob.js
javascript:(function(){
var p = document.getElementById("productTitle");//書籍のタイトルの処理
if (!p) var p = document.getElementById("ebooksProductTitle");
var title = p.innerText.trim();
var asin = document.getElementById('ASIN');//ASIN番号の処理
if(asin){
var a = asin.value;
}else{
var asin = document.getElementsByName('ASIN.0')0,a = asin.value; }
//登録情報欄を取得
var detail = document.getElementById('detailBullets_feature_div');
if (!detail) {
var subdoc = document.getElementById("product-description-iframe").contentWindow.document;
var detail = subdoc.getElementById("detailBullets_feature_div");
}
var detailtext = detail.innerText;
var pubdata = detailtext.split(/\n/);
pubdata2 = pubdata2.slice(10);//出版社 pubdata1 = pubdata1.slice(10);//出版社 //var publish = pubdata.filter(pubdata => detailtext.match(/\出版社/));
//var publisher = publish0;//出版社 var image=document.getElementById("imgTagWrapperId");//書影の処理
if (!image) var image = document.getElementById("ebooksImgBlkFront");
var imageurl = image.querySelector("img").getAttribute("src");
var pub = [];//著者情報の処理
// 既存のコードを改善
var c = document.getElementsByClassName('author');
var pub = [];
var ct_list = []; // ctの各要素を保存する配列を新たに定義
for (g = 0; g < c.length ;g++){
var at = cg.innerText.replace(/\r?\n/g, '').replace(/,/,''); var pu = at.match(/\(.+\)/);
var ct = at.replace(/\(.+\)/,'').replace(/ /g,'');
ct_list.push(ct); // ctを配列に追加
pub.push(pu + ' [+ ct + ']');
}
// ct_listを用いて新しいauthorの形式を生成
var author_list = ct_list.map(function(ct, index) {
return "- " + ct;
}).join('%0A');
var author = pub.join(' ');
// 自分が必要なパラメータに変換
var h1title = '『'+title+'』';
if (/:|\\|\/|\?|"|<|>|\|\.|/.test(h1title)) {
h1title = h1title.replace(/:/g, ':')
.replace(/\\/g, '\')
.replace(/\//g, '/')
.replace(/\?/g, '?')
.replace(/"/g, '”')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\|/g, '|')
.replace(/\./g, ' ');
}
var mdimage = '%0A!|100(' +imageurl+ ')%0A'; // 表示させたい項目
var lines= '---%0D%0Aauthor:%0A' + author_list + '%0D%0Adate%3A%0D%0Andl%3A%0D%0Atags%3A%20review%20%0D%0A---%0D%0A%0A' + link + mdimage + author +'%0A'+ pubdata1 + '%0A' + pubdata2 +'%0A%0A%23 関連・思い出した本 %0A%0A%23 読書メモ%0A%0A'; var lines2 = '![+ title + '(' + url + ')](' + imageurl + ')';
const obsidian = 'obsidian://advanced-uri?vault=obsidian_local&filepath='+h1title+ '&data='+lines;
window.open(obsidian);
})();
code:guitar.js
javascript:(function(){
var p = document.getElementById("productTitle");//書籍のタイトルの処理
if (!p) var p = document.getElementById("ebooksProductTitle");
var title = p.innerText.trim();
if (/:|\\|\/|\?|"|<|>|\|\.|/.test(title)) {
title = title.replace(/:/g, ':')
.replace(/\\/g, '\')
.replace(/\//g, '/')
.replace(/\?/g, '?')
.replace(/"/g, '”')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/&/g, '&')
.replace(/\|/g, '|')
.replace(/\./g, ' ');
}
var asin = document.getElementById('ASIN');//ASIN番号の処理
if(asin){
var a = asin.value;
}else{
var asin = document.getElementsByName('ASIN.0')0,a = asin.value; }
//登録情報欄を取得
var detail = document.getElementById('detailBullets_feature_div');
if (!detail) {
var subdoc = document.getElementById("product-description-iframe").contentWindow.document;
var detail = subdoc.getElementById("detailBullets_feature_div");
}
var detailtext = detail.innerText;
var pubdata = detailtext.split(/\n/);
pubdata2 = pubdata2.slice(10);//出版社 pubdata1 = pubdata1.slice(10);//出版社 //var publish = pubdata.filter(pubdata => detailtext.match(/\出版社/));
//var publisher = publish0;//出版社 var image=document.getElementById("imgTagWrapperId");//書影の処理
if (!image) var image = document.getElementById("ebooksImgBlkFront");
var imageurl = image.querySelector("img").getAttribute("src");
var pub = [];//著者情報の処理
var c = document.getElementsByClassName('author');
for (g = 0; g < c.length ;g++){
var at = cg.innerText.replace(/\r?\n/g, '').replace(/,/,''); var pu = at.match(/\(.+\)/);
var ct = at.replace(/\(.+\)/,'').replace(/ /g,'');
pub.push(pu + ' [+ ct + ']');
}
var author = pub.join(' ');
// 自分が必要なパラメータに変換
var h1title = '『'+title+'』';
var mdimage = '%0A!|100(' +imageurl+ ')%0A'; // 表示させたい項目
var lines= '---%0D%0Adate%3A%0D%0Andl%3A%0D%0Atags%3A%20review%20%0D%0A---%0D%0A%0A'+link + mdimage + author +'%0A'+ pubdata1 + '%0A' + pubdata2 +'%0A%0A%23 関連・思い出した本 %0A%0A%23 読書メモ%0A%0A'; var lines2 = '![+ title + '(' + url + ')](' + imageurl + ')';
const obsidian = 'obsidian://advanced-uri?vault=guitar&filepath=' +h1title+ '&data=' +lines;
window.open(obsidian);
})();
code:script.js
javascript:(function(){
var p = document.getElementById("productTitle");//書籍のタイトルの処理
if (!p) var p = document.getElementById("ebooksProductTitle");
var title = p.innerText.trim();
var asin = document.getElementById('ASIN');//ASIN番号の処理
if(asin){
var a = asin.value;
}else{
var asin = document.getElementsByName('ASIN.0')0,a = asin.value; }
//登録情報欄を取得
var detail = document.getElementById('detailBullets_feature_div');
if (!detail) {
var subdoc = document.getElementById("product-description-iframe").contentWindow.document;
var detail = subdoc.getElementById("detailBullets_feature_div");
}
var detailtext = detail.innerText;
var pubdata = detailtext.split(/\n/);
pubdata2 = pubdata2.slice(10);//出版社 pubdata1 = pubdata1.slice(10);//出版社 //var publish = pubdata.filter(pubdata => detailtext.match(/\出版社/));
//var publisher = publish0;//出版社 var image=document.getElementById("imgTagWrapperId");//書影の処理
if (!image) var image = document.getElementById("ebooksImgBlkFront");
var imageurl = image.querySelector("img").getAttribute("src");
var pub = [];//著者情報の処理
// 既存のコードを改善
var c = document.getElementsByClassName('author');
var pub = [];
var ct_list = []; // ctの各要素を保存する配列を新たに定義
for (g = 0; g < c.length ;g++){
var at = cg.innerText.replace(/\r?\n/g, '').replace(/,/,''); var pu = at.match(/\(.+\)/);
var ct = at.replace(/\(.+\)/,'').replace(/ /g,'');
ct_list.push(ct); // ctを配列に追加
pub.push(pu + ' [+ ct + ']');
}
// ct_listを用いて新しいauthorの形式を生成
var author_list = ct_list.map(function(ct, index) {
return "- " + ct;
}).join('%0A');
var author = pub.join(' ');
// 自分が必要なパラメータに変換
var h1title = '『'+title+'』';
if (/:|\\|\/|\?|"|<|>|\|\.|/.test(h1title)) {
h1title = h1title.replace(/:/g, ':')
.replace(/\\/g, '\')
.replace(/\//g, '/')
.replace(/\?/g, '?')
.replace(/"/g, '”')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/\|/g, '|')
.replace(/\./g, ' ');
}
var mdimage = '%0A!|100(' +imageurl+ ')%0A'; // 表示させたい項目
var lines= '---%0D%0Aauthor:%0A' + author_list + '%0D%0Adate%3A%0D%0Andl%3A%0D%0Atags%3A%20review%20%0D%0A---%0D%0A%0A' + link + mdimage + author +'%0A'+ pubdata1 + '%0A' + pubdata2 +'%0A%0A%23 関連・思い出した本 %0A%0A%23 読書メモ%0A%0A'; var lines2 = '![+ title + '(' + url + ')](' + imageurl + ')';
const obsidian = 'obsidian://advanced-uri?filepath='+h1title+ '&data='+lines;
window.open(obsidian);
})();
code:script2.js
javascript:(function(){
var p = document.getElementById("productTitle");//書籍のタイトルの処理
if (!p) var p = document.getElementById("ebooksProductTitle");
var title = p.innerText.trim();
var asin = document.getElementById('ASIN');//ASIN番号の処理
if(asin){
var a = asin.value;
}else{
var asin = document.getElementsByName('ASIN.0')0,a = asin.value; }
if(document.getElementById('detailBullets_feature_div') || document.getElementById("product-description-iframe")){
//登録情報欄を取得
var detail = document.getElementById('detailBullets_feature_div');
if (!detail) {
var subdoc = document.getElementById("product-description-iframe").contentWindow.document;
var detail = subdoc.getElementById("detailBullets_feature_div");
}
var detailtext = detail.innerText;
var pubdata = detailtext.split(/\n/);
pubdata2 = pubdata2.slice(10);//出版社 pubdata1 = pubdata1.slice(10);//出版社 //var publish = pubdata.filter(pubdata => detailtext.match(/\出版社/));
//var publisher = publish0;//出版社 }
if(document.getElementById("imgBlkFront") || document.getElementById("ebooksImgBlkFront")){
var image=document.getElementById("imgBlkFront");//書影の処理
if (!image) var image = document.getElementById("ebooksImgBlkFront");
if (!image) var image = document.getElementById("landingImage");
var imageurl = image.getAttribute("src");
var pub = [];//著者情報の処理
var c = document.getElementsByClassName('author');
for (g = 0; g < c.length ;g++){
var at = cg.innerText.replace(/\r?\n/g, '').replace(/,/,''); var pu = at.match(/\(.+\)/);
var ct = at.replace(/\(.+\)/,'').replace(/ /g,'');
pub.push(pu + ' [+ ct + ']');
var author = pub.join(' ');
}
}
// 自分が必要なパラメータに変換
var h1title = '# 『'+title+'』\n\n';
var mdimage = '\n!|100(' +imageurl+ ')\n'; // 表示させたい項目
var lines= h1title + link + mdimage + author +'\n';
var lines2 = '![+ title + '(' + url + ')](' + imageurl + ')';
document.getElementById('centerCol').innerHTML = '<textarea id="link" style="height:200px">'+lines+'</textarea>' + '<textarea style="height:200px">'+lines2+'</textarea>';
document.getElementById('link').select();
})();
code:script-haru.js
javascript:(function(){
var p = document.getElementById("productTitle");//書籍のタイトルの処理
if (!p) var p = document.getElementById("ebooksProductTitle");
var title = p.innerText.trim();
var asin = document.getElementById('ASIN');//ASIN番号の処理
if(asin){
var a = asin.value;
}else{
var asin = document.getElementsByName('ASIN.0')0,a = asin.value; }
//登録情報欄を取得
var detail = document.getElementById('detailBullets_feature_div');
if (!detail) {
var subdoc = document.getElementById("product-description-iframe").contentWindow.document;
var detail = subdoc.getElementById("detailBullets_feature_div");
}
var detailtext = detail.innerText;
var pubdata = detailtext.split(/\n/);
pubdata2 = pubdata2.slice(10);//出版社 pubdata1 = pubdata1.slice(10);//出版社 //var publish = pubdata.filter(pubdata => detailtext.match(/\出版社/));
//var publisher = publish0;//出版社 var image=document.getElementById("imgBlkFront");//書影の処理
if (!image) var image = document.getElementById("ebooksImgBlkFront");
var imageurl = image.getAttribute("src");
var pub = [];//著者情報の処理
var c = document.getElementsByClassName('author');
for (g = 0; g < c.length ;g++){
var at = cg.innerText.replace(/\r?\n/g, '').replace(/,/,''); var pu = at.match(/\(.+\)/);
var ct = at.replace(/\(.+\)/,'').replace(/ /g,'');
pub.push(pu + ' [+ ct + ']');
}
var author = pub.join(' ');
// 自分が必要なパラメータに変換
var h1title = '📘'+title+'\n\n';
var mdimage = '\n!|100(' +imageurl+ ')\n'; // 表示させたい項目
var lines= h1title + link + mdimage + author +'\n'+ pubdata1 + '\n' + pubdata2; var lines2 = '![+ title + '(' + url + ')](' + imageurl + ')';
document.getElementById('centerCol').innerHTML = '<textarea id="link" style="height:200px">'+lines+'</textarea>' + '<textarea style="height:200px">'+lines2+'</textarea>';
document.getElementById('link').select();
})();
code:ob-haru.js
javascript:(function(){
try {
// 書籍のタイトルの処理
var p = document.getElementById("productTitle");
if (!p) p = document.getElementById("ebooksProductTitle");
if (!p) {
throw new Error("Title element not found");
}
var title = p.innerText.trim();
console.log("Title:", title);
// ASIN番号の処理
var asin = document.getElementById('ASIN');
if(asin){
var a = asin.value;
} else {
asin = document.getElementsByName('ASIN.0')0; if (!asin) {
throw new Error("ASIN element not found");
}
var a = asin.value;
}
console.log("ASIN:", a);
// 登録情報欄を取得
var detail = document.getElementById('detailBullets_feature_div');
if (!detail) {
var subdoc = document.getElementById("product-description-iframe").contentWindow.document;
detail = subdoc ? subdoc.getElementById("detailBullets_feature_div") : null;
if (!detail) {
throw new Error("Detail element not found");
}
}
console.log("Detail:", detail.innerText);
var detailtext = detail.innerText;
var pubdata = detailtext.split(/\n/);
console.log("Publisher data:", pubdata);
// Amazonリンクを作成
var link = '+ title + '(' + url + ')';
console.log("Link:", link);
// 書影の処理
var image = document.getElementById("imgTagWrapperId");
if (!image) image = document.getElementById("ebooksImgBlkFront");
if (!image) {
throw new Error("Image element not found");
}
var imageurl = image.querySelector("img").getAttribute("src");
console.log("Image URL:", imageurl);
// 著者情報の処理
var pub = [];
var c = document.getElementsByClassName('author');
for (var g = 0; g < c.length ;g++){
var at = cg.innerText.replace(/\r?\n/g, '').replace(/,/,''); var pu = at.match(/\(.+\)/);
var ct = at.replace(/\(.+\)/,'').replace(/ /g,'');
pub.push(pu + ' [+ ct + ']');
}
var author = pub.join(' ');
console.log("Author:", author);
// 自分が必要なパラメータに変換
var h1title = '📘' + title;
if (/:|\\|\//.test(h1title)) {
h1title = h1title.replace(/:/g, ':').replace(/\\/g, '\').replace(/\//g, '/');
}
var mdimage = '%0A!|100(' + imageurl + ')%0A'; // 表示させたい項目
var today = new Date();
var yyyy = today.getFullYear().toString();
var mm = ('0' + (today.getMonth()+1)).slice(-2);
var dd = ('0' + today.getDate()).slice(-2);
var formattedDate = yyyy + mm + dd;
var lines = '%23 📘'+ title +'%0A'+formattedDate+':%0A%0A' + link + mdimage + author +'%0A'+ pubdata1 +'%0A'+ pubdata2 +'%0A%0Aこの本は:' + '%0A%0A%23%23 目次 %0A%0A'; var lines2 = '![+ title + '(' + url + ')](' + imageurl + ')';
var obsidian = 'obsidian://advanced-uri?filepath=' + encodeURIComponent(h1title) + '&data=' + encodeURIComponent(lines);
window.open(obsidian);
} catch (e) {
console.error("Error:", e);
}
})();