Skip to content

Instantly share code, notes, and snippets.

@take-cheeze
Last active June 17, 2020 03:55
Show Gist options
  • Save take-cheeze/deb1b8502aa9e2188abf1ef0b36ba818 to your computer and use it in GitHub Desktop.
Save take-cheeze/deb1b8502aa9e2188abf1ef0b36ba818 to your computer and use it in GitHub Desktop.
calc_booth.userscript.js
// ==UserScript==
// @name Booth Total
// @namespace https://take-cheeze.dev/
// @version 0.1
// @description try to take over the world!
// @author @take-cheeze
// @match https://booth.pm/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
const title = document.querySelector('.manage-page-head-title');
if (!title) return;
const default_head_title = title.textContent;
setInterval(() => {
let total = 0;
document.querySelectorAll('.cart-box-subtotal-price').forEach((v) => {
total += parseInt(v.innerHTML.replace(/[^0-9]/g, ''));
});
let dl_total = 0;
document.querySelectorAll('.u-tpg-caption1').forEach((v) => {
if (v.textContent === "ダウンロード商品") {
const priceStr = v.parentNode.children[0].textContent;
const price = parseInt(priceStr.replace(/[^0-9]/g, ''));
dl_total += price;
}
});
let updated = `${default_head_title}<br/>¥${total.toLocaleString()}`;
updated += ` (DL: ¥${dl_total.toLocaleString()}, Other: ¥${(total - dl_total).toLocaleString()})`;
title.innerHTML = updated;
}, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment