Created
November 1, 2023 08:02
-
-
Save htakeuchi/12c99928dea4e7697ebc021100c5f6ac to your computer and use it in GitHub Desktop.
Amazon商品の商品名と画像へのリンクをTextwellに追加するブックマークレット
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (() => { | |
const dest_path = "notes"; //ファイルを格納するパス | |
const amazon_id = "namaraiicom-22"; // アフィリエイトID | |
let p = document.getElementById("productTitle") || document.getElementById("ebooksProductTitle"); //書籍のタイトルの処理 | |
const title = p.innerText.trim(); | |
const asinElement = document.getElementById('ASIN') || document.getElementsByName('ASIN.0')[0]; //ASIN番号の処理 | |
const a = asinElement.value; | |
const url = `https://www.amazon.co.jp/exec/obidos/ASIN/${a}/${amazon_id}/`; | |
const link = `[${title}](${url})`; | |
const image = document.getElementById("landingImage"); | |
const imageurl = image.getAttribute("src"); | |
// 自分が必要なパラメータに変換 | |
let h1title = title.replace(/[\\/:*?"<>|.]/g, char => ({ | |
':': ':', '\\': '\', '/': '/', '?': '?', | |
'*': '*', '"': '”', '<': '<', '>': '>', | |
'|': '|', '.': '.' | |
}[char])); | |
const mdimage = `[![|100](${imageurl})](${url})`; | |
const lines = `${mdimage}%0D%0A%0D%0A${link}%0D%0A`; | |
const app = `textwell:///add?text=${lines}`; | |
window.open(app); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment