Vault Copy

description

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Vault Copy
// @namespace    namespace
// @version      0.1
// @description  description
// @author       tos
// @match       *.torn.com/properties.php*
// @grant        GM_addStyle
// @grant        GM_setClipboard
// ==/UserScript==

GM_addStyle(`
#x_button_right {
  background-color: #c13c3c;
  color: #eaeaea;
  cursor: pointer;
  padding: 1em;
  position: fixed;
  right: 0;
}
`)

document.querySelector('div.content').insertAdjacentHTML('beforebegin', `<div id="x_button_right">Copy Vault</div>`)

document.querySelector('#x_button_right').addEventListener('click', (e) => {
  let csv = []
  document.querySelectorAll('UL.vault-trans-list>LI').forEach((li) => {
    let line = []
    line.push(li.querySelector('li.date').innerText.replace(/ AM| PM/g, ''))
    line.push(li.querySelector('li.user img') ? li.querySelector('li.user img').title : 'User')
    line.push(li.querySelector('li.type').innerText)
    line.push(li.querySelector('li.amount').innerText)
    line.push(li.querySelector('li.balance').innerText)
    //console.log(line)
    csv.push(line.join('\t'))
  })
  GM_setClipboard(csv.join('\n'))
})