-
-
Save Marco3jp/89f4f62bc1d239d47d6abf7c6b1faae3 to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name DLsite Master's Dream | |
// @description DLsiteのプレミアムな購入履歴.jsonをお届けします | |
// @version 1.2 | |
// @author Marco | |
// @homepage https://marco.plus | |
// @namespace https://marco.plus | |
// @website https://twitter.com/Marco_utau | |
// @match https://www.dlsite.com/home/mypage/userbuy | |
// @match https://www.dlsite.com/home/mypage/userbuy/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=dlsite.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const landmarkElement = document.querySelector("#unpaid_list"); | |
const button = document.createElement("button"); | |
button.addEventListener("click", ()=>{ | |
const itemElements = document.querySelectorAll(".work_list_main tr:not(.item_name)"); | |
const items = Array.from(itemElements).map(element => { | |
const date = element.querySelector(".buy_date").textContent.trim(); | |
const workNameElement = element.querySelector(".work_name"); | |
const title = workNameElement.textContent.trim(); | |
const anchorElement = workNameElement.querySelector("a"); | |
const artistName = element.querySelector(".maker_name").textContent.trim(); | |
const artistUrl = element.querySelector(".maker_name a").href; | |
return { | |
date, | |
title, | |
url: anchorElement ? anchorElement.href : undefined, // 特典などの商品ページがないケースがあるのでこんな感じにしている | |
artistName, | |
artistUrl | |
} | |
}); | |
const jsonText = JSON.stringify(items); | |
const jsonBlob = new Blob([jsonText], {type: "application/json"}); | |
const linkElm = document.createElement("a"); | |
linkElm.href = URL.createObjectURL(jsonBlob); | |
linkElm.target = "_self"; | |
const now = new Date(); | |
linkElm.download = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, "0")}-${now.getDate().toString().padStart(2, "0") | |
}_${now.getHours().toString().padStart(2, "0")}-${now.getMinutes().toString().padStart(2, "0")}-${now.getSeconds().toString().padStart(2, "0")}`; | |
linkElm.click(); | |
}); | |
button.textContent = "Save JSON"; | |
landmarkElement.insertAdjacentElement("beforebegin", button); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment