Last active
March 31, 2026 13:29
-
-
Save nna774/597a9e769dbad467f030b626f3202582 to your computer and use it in GitHub Desktop.
my-dlsite-lib
This file contains hidden or 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:(function () { | |
| const aid = 'tydja'; | |
| const sb_base_uri = 'https://scrapbox.io/my-dlsite-lib/'; | |
| const titleEl = document.getElementById('work_name'); | |
| const idMatch = document.URL.match(/([A-Z]{2}\d+)\.html$/); | |
| if (!titleEl || !idMatch) { | |
| alert('情報の抽出に失敗した。'); | |
| return; | |
| } | |
| const title = titleEl.textContent.trim(); | |
| const id = idMatch[1]; | |
| let creatorsText = '\n'; | |
| const seen = new Set(); | |
| // touch版の作品情報リストを探索する | |
| const infoItems = document.querySelectorAll('.c-productInfo__item'); | |
| infoItems.forEach(item => { | |
| const keyEl = item.querySelector('.c-productInfo__key'); | |
| const valEl = item.querySelector('.c-productInfo__value'); | |
| if (keyEl && valEl) { | |
| const key = keyEl.textContent.trim().replace(/[::\s]/g, ''); | |
| let val = ''; | |
| // サークルの場合は余計なフォローボタンのテキストが含まれるため、名前部分だけを狙い撃ちする | |
| const makerNameEl = valEl.querySelector('.c-productInfo__makerName'); | |
| if (makerNameEl) { | |
| val = makerNameEl.textContent.trim(); | |
| } else { | |
| // 作者などの場合はこれまで通り中身をそのまま取得する | |
| val = valEl.textContent.trim().replace(/\s+/g, ' '); | |
| } | |
| // 抽出したい項目のホワイトリスト | |
| if (['サークル', '作者', '著者', 'イラスト'].includes(key)) { | |
| if (!seen.has(val)) { | |
| creatorsText += `[${key}:${val}]\n`; | |
| seen.add(val); | |
| } | |
| } | |
| } | |
| }); | |
| // 万が一、上記のリストから見つからなかった場合の保険 | |
| if (!creatorsText) { | |
| const authorEl = document.querySelector('.c-productTitleBox__author'); | |
| const makerEl = document.querySelector('.c-productInfo__makerName'); | |
| if (authorEl) creatorsText += `[著者:${authorEl.textContent.trim()}]\n`; | |
| if (makerEl) creatorsText += `[サークル/出版社:${makerEl.textContent.trim()}]\n`; | |
| } | |
| const sale_uri = `https://dlaf.jp/home/dlaf/=/t/s/link/work/aid/${aid}/id/${id}.html`; | |
| const body = `${sale_uri}\n${creatorsText}\n[作品:]\n[キャラクター:]\n[タグ:]\nレート: \n感想: `; | |
| location.href = `${sb_base_uri}${encodeURIComponent(title)}?body=${encodeURIComponent(body)}`; | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment