Skip to content

Instantly share code, notes, and snippets.

@aoirint
Last active December 7, 2023 15:07
Show Gist options
  • Save aoirint/02b6d9c2b7335800ef6daa8535c5c650 to your computer and use it in GitHub Desktop.
Save aoirint/02b6d9c2b7335800ef6daa8535c5c650 to your computer and use it in GitHub Desktop.
ニコニコポイント通帳をTSV出力するUserScript
// ==UserScript==
// @name niconico_point_book_user_script
// @namespace Violentmonkey Scripts
// @match https://point.nicovideo.jp/index/bank/
// @grant none
// @version 0.1.0
// @author aoirint
// @description 2023-12-07T23:37:39+09:00
// ==/UserScript==
(() => {
const textAreaElement = document.createElement("textarea")
textAreaElement.cols = 80
textAreaElement.rows = 10
textAreaElement.style.fontSize = "6pt"
textAreaElement.style.position = "fixed"
textAreaElement.style.zIndex = 999
textAreaElement.style.left = 0
textAreaElement.style.bottom = 0
document.body.appendChild(textAreaElement)
textAreaElement.addEventListener("click", (event) => {
event.target.select()
})
textAreaElement.value = [...document.querySelectorAll(".passbook-item")].map(
(item) => [
new Date(item.querySelector("dd.date").innerText.trim()).toISOString(),
item.querySelector("dd.purchase_id").innerText.trim(),
item.querySelector("dd.service").innerText.trim(),
new String(
parseInt(
item.querySelector(".passbook-item-point").innerText.trim()
.replace("+", "+")
.replace("−", "-")
.replace(",", "")
),
),
].join("\t"),
).reverse().join("\n")
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment