Skip to content

Instantly share code, notes, and snippets.

@jamesona jamesona/.gitignore
Last active Oct 24, 2018

Embed
What would you like to do?
node_modules
package-lock.json
js
bundle.js
const fs = require('fs')
const outFile = 'torn.user.js'
const packageJSON = fs.readFileSync('package.json')
const packageData = JSON.parse(packageJSON)
const headerLines = [
`//==UserScript==`,
`@name ${packageData.name}`,
`@namespace http://tampermonkey.net/`,
`@version ${packageData.version}`,
`@description ${packageData.description}`,
`@author ${packageData.author}`,
`@match https://www.torn.com`,
`@include https://www.torn.com*`,
`@grant none`,
`==/UserScript==`,
]
const insert = new Buffer(headerLines.join('\n//') + '\n')
const data = fs.readFileSync(outFile)
const fd = fs.openSync(outFile, 'w+')
fs.writeSync(fd, insert, 0, insert.length, 0)
fs.writeSync(fd, data, 0, data.length, insert.length)
fs.close(fd, (err) => {
if (err) throw err;
});
import { getImage } from "./getImage";
export function buyAllInBazaar() {
waitForClickAndBuy()
}
async function waitForClickAndBuy() {
const img = await getImage()
buyAll(img)
}
function buyAll(img: HTMLImageElement) {
const query = `[src="${img}"]`
const elements: HTMLElement[] = Array.from(document.querySelectorAll(query))
const prices: number[] = elements.map(getPrice)
const minPrice: number = Math.min(...prices)
const safePurchases: HTMLElement[] = elements.filter(e => getPrice(e) <= minPrice * 1.15)
const total: number = safePurchases.map(getPrice).reduce((a, c) => a + c)
if (confirm(`Buying ${safePurchases.length} items for ${total}. Continue?`)) {
safePurchases.forEach((element: HTMLElement) => {
const baseElement: HTMLElement = element.parentElement;
(baseElement.children[1].children[1] as HTMLElement).click()
setTimeout(() => (baseElement.nextElementSibling.children[1].children[2] as HTMLElement).click(), 300)
setTimeout(() => (baseElement.parentElement.nextElementSibling.children[1].children[1].children[0] as HTMLElement).click(), 300)
setTimeout(() => (baseElement.nextElementSibling.children[1].children[2] as HTMLElement).click(), 300)
})
}
}
function getPrice(e) {
const info: HTMLElement = e.parentElement.parentElement
const description: HTMLElement = (Array.from(info.children) as HTMLElement[])
.find(e => e.className === 'desc')
const price: HTMLElement = (Array.from(description.firstElementChild.children) as HTMLElement[])
.find(e => e.classList.contains('price'))
return Number(price.innerText.replace(/[$,]/g, ''))
}
import { queryBuyButtons } from "./queryBuyButtons";
import { buyMarketItem, parsePrice, getItemType, wait } from "./buyMarketItem";
import { waitAndTryAgain } from "./waitAndTryAgain";
import { Config } from "./config";
export async function buyAllInMarket(maxPrice?: number) {
const allButtons = await waitForButtons()
const buttons = allButtons.filter(button => {
const costElement: HTMLElement = Array.from(
button.parentElement.parentElement.parentElement.children
).find(
(element: HTMLElement) => element.classList.contains('cost')
) as HTMLElement
const price = parsePrice(costElement.innerText)
const type = getItemType()
return (!Config.maxPrices || !Config.maxPrices[type] || price < Config.maxPrices[type])
})
if (!buttons.length) {
const done = await wait(5000)
}
while (buttons.length) {
const button = await buyMarketItem(buttons.shift(), maxPrice)
}
window.location.reload()
}
async function waitForButtons() {
let buttons
while (buttons === undefined) {
buttons = await waitAndTryAgain(
() => queryBuyButtons()
)
}
return buttons
}
import { queryBuyButtons } from "./queryBuyButtons";
import { waitAndTryAgain } from "./waitAndTryAgain";
import { Config } from "./config";
export async function buyMarketItem(buyButton, maxPrice: number) {
if (buyButton instanceof Event) buyButton = undefined
buyButton = buyButton || queryBuyButtons()[0]
return await buyItem(buyButton, maxPrice)
}
export function parsePrice(price: string): number {
return Number(price.replace(/[\$,]/g, ''))
}
function getPrice(confirmBar: HTMLElement): number {
let match: any[] | null = confirmBar.innerText.replace(',','').match(/\$(\d+)/)
if (match) {
return parsePrice(match[1])
} else {
return null
}
}
function queryToObject(query: string): {[key: string]: any} {
return query.replace(/\?/, '').split('&').reduce((prev, cur) => {
const [key, val] = cur.split('=')
prev[key] = val
return prev
}, {})
}
export function getItemType(): number {
const params = window.location.hash.slice(2)
const paramsObj = queryToObject(params)
return paramsObj.type
}
function findYesButton(buyButton) {
const confirmBar = buyButton.parentNode.parentNode
.parentNode.nextElementSibling
.children[0]
if (confirmBar) {
if (confirmBar.classList.contains('t-red') || confirmBar.innerText.includes('sorry')) {
return confirmBar.nextElementSibling
} else {
return confirmBar.children[2]
}
} else {
return undefined
}
}
function findBoughtText(yesButton) {
if (!yesButton
|| !yesButton.parentElement
|| !yesButton.parentElement.parentElement
|| !yesButton.parentElement.parentElement.nextElementSibling
) return undefined
const successBar = yesButton.parentElement.parentElement.nextElementSibling
const children = successBar.children[0].children
// this is a shortcut for when complete
if (children) return children[1]
}
async function waitForYesButton(buyButton) {
let yesButton
while (yesButton === undefined) {
yesButton = await waitAndTryAgain(
() => findYesButton(buyButton)
)
}
return yesButton
}
async function waitForBoughtText(yesButton) {
let bought
while (!bought) {
bought = await waitAndTryAgain(
() => findBoughtText(yesButton)
)
}
return bought
}
async function buyItem(buyButton: HTMLElement, maxPrice?: number) {
if (!buyButton) debugger
buyButton.click()
const yesButton = await waitForYesButton(buyButton)
const price: number = getPrice(yesButton.parentElement)
const type: number = getItemType()
if (maxPrice) {
if (price > maxPrice) return null
}
Config.maxPrices = Config.maxPrices || {}
maxPrice = Config.maxPrices[type]
if (maxPrice && price > maxPrice) {
const message = `The price for this item ($${price})`+
` is greater than your previous max price ($${maxPrice}),` +
' would you like to buy and set a new max?'
if (!confirm(message)) {
const done = await wait(3000)
window.location.reload()
}
}
if (!maxPrice || price > maxPrice) {
Config.maxPrices = {...Config.maxPrices, [type]: price}
}
Config.lastPrices = Config.lastPrices || {}
Config.lastPrices = {...Config.lastPrices, [type]: price}
if (yesButton.classList.contains('close-icon')) {
yesButton.click()
return null
} else {
yesButton.click()
const boughtMessage = await waitForBoughtText(yesButton)
return boughtMessage
}
}
export function wait(time) {
return new Promise(resolve => {
debugger
setTimeout(() => resolve('done!'), time)
})
}
const KEY = 'tornbarconfig'
window.localStorage.__proto__.clear = () => {}
// get(target, prop, receiver) {
// return Reflect.get(realStorage, prop, receiver)
// },
// set(target, prop, value) {
// return Reflect.set(realStorage, prop, value)
// }
function getConfig(): object {
const storage = localStorage.getItem(KEY)
try {
return JSON.parse(storage)
} catch (e) {
debugger
return {}
}
}
function setConfig(config: object): void {
localStorage.setItem(KEY, JSON.stringify(config))
}
export const Config: {[key: string]: any} = new Proxy({}, {
get(target, prop, receiver) {
const _config = getConfig() || {}
return Reflect.get(_config, prop, receiver)
},
set(target, property, value) {
try {
const _config = getConfig() || {}
_config[property] = value
setConfig(_config)
return true
} catch (e) {
debugger
return false
}
}
})
export function getImage(): Promise<HTMLImageElement> {
const style = document.createElement('style')
style.innerHTML = `.item-hover, .image-wrap {cursor: crosshair !important;}`
return new Promise(resolve => {
const onClick = e => {
let img
switch (e.target.className) {
case 'view-h':
case 'buy-h':
case 'item-hover': {
img = e.target.parentElement.previousElementSibling
break
}
case 'image-wrap': {
img = e.target.children[0].children[0]
break
}
default: {
if (e.target.tagName === 'IMG') img = e.target
}
}
if (!img || !img.src) return
window.removeEventListener('click', onClick)
document.body.removeChild(style)
resolve(img.src.replace('https://www.torn.com', ''))
}
document.body.appendChild(style)
window.addEventListener('click', onClick)
})
}
export function getInitials(str: string): string {
return str.split(' ').map(w => w.split('').shift()).join('')
}
import { stringToCharSum } from "./stringToCharSum";
import { getInitials } from "./getInitials";
export function hashItemName(item: string): string {
return stringToCharSum(item.replace(/[^a-zA-Z]/g, '')) + getInitials(item)
}
import { buyMarketItem, getItemType } from "./buyMarketItem";
import { buyAllInMarket } from "./buyAllInMarket";
import { buyAllInBazaar } from "./buyAllInBazaar";
import { sellAll } from "./sellAllInBazaar";
import { Config } from "./config";
function main() {
const header = document.querySelector('.header-wrapper-bottom')
const buttons = document.createElement('div')
buttons.style.margin = 'auto'
buttons.style.maxWidth = '30vw'
buttons.style.position = 'fixed'
const buttonConfigs = [{
name: 'Buy Top Item',
task: buyMarketItem
}, {
name: 'Buy All Listings',
task: buyAllInMarket
}, {
name: 'Buy All In Bazaar',
task: buyAllInBazaar
}, {
name: 'Sell All',
task: sellAll
}]
const autoBuyToggle = createAutoBuyToggle()
appendChildren([...makeButtons(buttonConfigs), autoBuyToggle], buttons)
const style = createStyle()
appendChildren([buttons, style], header)
header && header.appendChild(buttons)
if (window.location.pathname.includes('market') && Config.autoBuy) {
const item = getItemType()
const maxPrice = Config.maxPrices[item]
buyAllInMarket(Number(maxPrice))
}
}
function createStyle() {
const style = document.createElement('style')
style.innerHTML = `
button {
color: gray;
background: black;
border: 1px solid currentColor;
margin: 5px;
cursor: pointer;
}
button:hover {
color: #ccc;
}
`
return style
}
function createButton(config) {
const { name, task } = config
const button = document.createElement('button')
button.innerText = name
button.addEventListener('click', task)
return button
}
function makeButtons(buttons) {
return buttons.map(config => createButton(config))
}
function createAutoBuyToggle() {
const input = document.createElement('input')
input.type = 'checkbox'
input.id = 'auto-buy'
input.onchange = () => {
Config.autoBuy = !!(input.checked)
}
input.checked = !!(Config.autoBuy)
return input
}
function appendChildren(children, parent) {
children.forEach(child => parent.appendChild(child))
}
main()
{
"name": "torn-tools",
"version": "0.4.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"JSONStream": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
"integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==",
"dev": true,
"requires": {
"jsonparse": "^1.2.0",
"through": ">=2.2.7 <3"
}
},
"acorn": {
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.2.tgz",
"integrity": "sha512-GXmKIvbrN3TV7aVqAzVFaMW8F8wzVX7voEBRO3bDA64+EX37YSayggRJP5Xig6HYHBkWKpFg9W5gg6orklubhg==",
"dev": true
},
"acorn-node": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.6.0.tgz",
"integrity": "sha512-ZsysjEh+Y3i14f7YXCAKJy99RXbd56wHKYBzN4FlFtICIZyFpYwK6OwNJhcz8A/FMtxoUZkJofH1v9KIfNgWmw==",
"dev": true,
"requires": {
"acorn": "^6.0.1",
"acorn-walk": "^6.0.1",
"xtend": "^4.0.1"
}
},
"acorn-walk": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.1.0.tgz",
"integrity": "sha512-ugTb7Lq7u4GfWSqqpwE0bGyoBZNMTok/zDBXxfEG0QM50jNlGhIWjRC1pPN7bvV1anhF+bs+/gNcRw+o55Evbg==",
"dev": true
},
"array-filter": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz",
"integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=",
"dev": true
},
"array-map": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz",
"integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=",
"dev": true
},
"array-reduce": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz",
"integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=",
"dev": true
},
"asn1.js": {
"version": "4.10.1",
"resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz",
"integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==",
"dev": true,
"requires": {
"bn.js": "^4.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0"
}
},
"assert": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz",
"integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=",
"dev": true,
"requires": {
"util": "0.10.3"
},
"dependencies": {
"inherits": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz",
"integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=",
"dev": true
},
"util": {
"version": "0.10.3",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
"integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=",
"dev": true,
"requires": {
"inherits": "2.0.1"
}
}
}
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
"base64-js": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
"integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==",
"dev": true
},
"bn.js": {
"version": "4.11.8",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
"integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==",
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"brorand": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=",
"dev": true
},
"browser-pack": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz",
"integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==",
"dev": true,
"requires": {
"JSONStream": "^1.0.3",
"combine-source-map": "~0.8.0",
"defined": "^1.0.0",
"safe-buffer": "^5.1.1",
"through2": "^2.0.0",
"umd": "^3.0.0"
}
},
"browser-resolve": {
"version": "1.11.3",
"resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz",
"integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==",
"dev": true,
"requires": {
"resolve": "1.1.7"
},
"dependencies": {
"resolve": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz",
"integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=",
"dev": true
}
}
},
"browserify": {
"version": "16.2.3",
"resolved": "https://registry.npmjs.org/browserify/-/browserify-16.2.3.tgz",
"integrity": "sha512-zQt/Gd1+W+IY+h/xX2NYMW4orQWhqSwyV+xsblycTtpOuB27h1fZhhNQuipJ4t79ohw4P4mMem0jp/ZkISQtjQ==",
"dev": true,
"requires": {
"JSONStream": "^1.0.3",
"assert": "^1.4.0",
"browser-pack": "^6.0.1",
"browser-resolve": "^1.11.0",
"browserify-zlib": "~0.2.0",
"buffer": "^5.0.2",
"cached-path-relative": "^1.0.0",
"concat-stream": "^1.6.0",
"console-browserify": "^1.1.0",
"constants-browserify": "~1.0.0",
"crypto-browserify": "^3.0.0",
"defined": "^1.0.0",
"deps-sort": "^2.0.0",
"domain-browser": "^1.2.0",
"duplexer2": "~0.1.2",
"events": "^2.0.0",
"glob": "^7.1.0",
"has": "^1.0.0",
"htmlescape": "^1.1.0",
"https-browserify": "^1.0.0",
"inherits": "~2.0.1",
"insert-module-globals": "^7.0.0",
"labeled-stream-splicer": "^2.0.0",
"mkdirp": "^0.5.0",
"module-deps": "^6.0.0",
"os-browserify": "~0.3.0",
"parents": "^1.0.1",
"path-browserify": "~0.0.0",
"process": "~0.11.0",
"punycode": "^1.3.2",
"querystring-es3": "~0.2.0",
"read-only-stream": "^2.0.0",
"readable-stream": "^2.0.2",
"resolve": "^1.1.4",
"shasum": "^1.0.0",
"shell-quote": "^1.6.1",
"stream-browserify": "^2.0.0",
"stream-http": "^2.0.0",
"string_decoder": "^1.1.1",
"subarg": "^1.0.0",
"syntax-error": "^1.1.1",
"through2": "^2.0.0",
"timers-browserify": "^1.0.1",
"tty-browserify": "0.0.1",
"url": "~0.11.0",
"util": "~0.10.1",
"vm-browserify": "^1.0.0",
"xtend": "^4.0.0"
}
},
"browserify-aes": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
"dev": true,
"requires": {
"buffer-xor": "^1.0.3",
"cipher-base": "^1.0.0",
"create-hash": "^1.1.0",
"evp_bytestokey": "^1.0.3",
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"browserify-cipher": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz",
"integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==",
"dev": true,
"requires": {
"browserify-aes": "^1.0.4",
"browserify-des": "^1.0.0",
"evp_bytestokey": "^1.0.0"
}
},
"browserify-des": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz",
"integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==",
"dev": true,
"requires": {
"cipher-base": "^1.0.1",
"des.js": "^1.0.0",
"inherits": "^2.0.1",
"safe-buffer": "^5.1.2"
}
},
"browserify-rsa": {
"version": "4.0.1",
"resolved": "http://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz",
"integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=",
"dev": true,
"requires": {
"bn.js": "^4.1.0",
"randombytes": "^2.0.1"
}
},
"browserify-sign": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz",
"integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=",
"dev": true,
"requires": {
"bn.js": "^4.1.1",
"browserify-rsa": "^4.0.0",
"create-hash": "^1.1.0",
"create-hmac": "^1.1.2",
"elliptic": "^6.0.0",
"inherits": "^2.0.1",
"parse-asn1": "^5.0.0"
}
},
"browserify-zlib": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz",
"integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==",
"dev": true,
"requires": {
"pako": "~1.0.5"
}
},
"buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz",
"integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==",
"dev": true,
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
},
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
"dev": true
},
"buffer-xor": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=",
"dev": true
},
"builtin-status-codes": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz",
"integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=",
"dev": true
},
"cached-path-relative": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.1.tgz",
"integrity": "sha1-0JxLUoAKpMB44t2BqGmqyQ0uVOc=",
"dev": true
},
"cipher-base": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"combine-source-map": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz",
"integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=",
"dev": true,
"requires": {
"convert-source-map": "~1.1.0",
"inline-source-map": "~0.6.0",
"lodash.memoize": "~3.0.3",
"source-map": "~0.5.3"
}
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"concat-stream": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"dev": true,
"requires": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^2.2.2",
"typedarray": "^0.0.6"
}
},
"console-browserify": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",
"integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=",
"dev": true,
"requires": {
"date-now": "^0.1.4"
}
},
"constants-browserify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz",
"integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=",
"dev": true
},
"convert-source-map": {
"version": "1.1.3",
"resolved": "http://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz",
"integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=",
"dev": true
},
"core-util-is": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
"dev": true
},
"create-ecdh": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz",
"integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==",
"dev": true,
"requires": {
"bn.js": "^4.1.0",
"elliptic": "^6.0.0"
}
},
"create-hash": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
"dev": true,
"requires": {
"cipher-base": "^1.0.1",
"inherits": "^2.0.1",
"md5.js": "^1.3.4",
"ripemd160": "^2.0.1",
"sha.js": "^2.4.0"
}
},
"create-hmac": {
"version": "1.1.7",
"resolved": "http://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
"dev": true,
"requires": {
"cipher-base": "^1.0.3",
"create-hash": "^1.1.0",
"inherits": "^2.0.1",
"ripemd160": "^2.0.0",
"safe-buffer": "^5.0.1",
"sha.js": "^2.4.8"
}
},
"crypto-browserify": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz",
"integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==",
"dev": true,
"requires": {
"browserify-cipher": "^1.0.0",
"browserify-sign": "^4.0.0",
"create-ecdh": "^4.0.0",
"create-hash": "^1.1.0",
"create-hmac": "^1.1.0",
"diffie-hellman": "^5.0.0",
"inherits": "^2.0.1",
"pbkdf2": "^3.0.3",
"public-encrypt": "^4.0.0",
"randombytes": "^2.0.0",
"randomfill": "^1.0.3"
}
},
"date-now": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
"integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=",
"dev": true
},
"defined": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz",
"integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
"dev": true
},
"deps-sort": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz",
"integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=",
"dev": true,
"requires": {
"JSONStream": "^1.0.3",
"shasum": "^1.0.0",
"subarg": "^1.0.0",
"through2": "^2.0.0"
}
},
"des.js": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz",
"integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0"
}
},
"detective": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/detective/-/detective-5.1.0.tgz",
"integrity": "sha512-TFHMqfOvxlgrfVzTEkNBSh9SvSNX/HfF4OFI2QFGCyPm02EsyILqnUeb5P6q7JZ3SFNTBL5t2sePRgrN4epUWQ==",
"dev": true,
"requires": {
"acorn-node": "^1.3.0",
"defined": "^1.0.0",
"minimist": "^1.1.1"
}
},
"diffie-hellman": {
"version": "5.0.3",
"resolved": "http://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz",
"integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==",
"dev": true,
"requires": {
"bn.js": "^4.1.0",
"miller-rabin": "^4.0.0",
"randombytes": "^2.0.0"
}
},
"domain-browser": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
"integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==",
"dev": true
},
"duplexer2": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",
"integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=",
"dev": true,
"requires": {
"readable-stream": "^2.0.2"
}
},
"elliptic": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz",
"integrity": "sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==",
"dev": true,
"requires": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
"hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.0"
}
},
"events": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/events/-/events-2.1.0.tgz",
"integrity": "sha512-3Zmiobend8P9DjmKAty0Era4jV8oJ0yGYe2nJJAxgymF9+N8F2m0hhZiMoWtcfepExzNKZumFU3ksdQbInGWCg==",
"dev": true
},
"evp_bytestokey": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz",
"integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==",
"dev": true,
"requires": {
"md5.js": "^1.3.4",
"safe-buffer": "^5.1.1"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"get-assigned-identifiers": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz",
"integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==",
"dev": true
},
"glob": {
"version": "7.1.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"requires": {
"function-bind": "^1.1.1"
}
},
"hash-base": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz",
"integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"hash.js": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.5.tgz",
"integrity": "sha512-eWI5HG9Np+eHV1KQhisXWwM+4EPPYe5dFX1UZZH7k/E3JzDEazVH+VGlZi6R94ZqImq+A3D1mCEtrFIfg/E7sA==",
"dev": true,
"requires": {
"inherits": "^2.0.3",
"minimalistic-assert": "^1.0.1"
}
},
"hmac-drbg": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
"integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=",
"dev": true,
"requires": {
"hash.js": "^1.0.3",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.1"
}
},
"htmlescape": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz",
"integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=",
"dev": true
},
"https-browserify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
"integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=",
"dev": true
},
"ieee754": {
"version": "1.1.12",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz",
"integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==",
"dev": true
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true
},
"inline-source-map": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz",
"integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=",
"dev": true,
"requires": {
"source-map": "~0.5.3"
}
},
"insert-module-globals": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.0.tgz",
"integrity": "sha512-VE6NlW+WGn2/AeOMd496AHFYmE7eLKkUY6Ty31k4og5vmA3Fjuwe9v6ifH6Xx/Hz27QvdoMoviw1/pqWRB09Sw==",
"dev": true,
"requires": {
"JSONStream": "^1.0.3",
"acorn-node": "^1.5.2",
"combine-source-map": "^0.8.0",
"concat-stream": "^1.6.1",
"is-buffer": "^1.1.0",
"path-is-absolute": "^1.0.1",
"process": "~0.11.0",
"through2": "^2.0.0",
"undeclared-identifiers": "^1.1.2",
"xtend": "^4.0.0"
}
},
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
"dev": true
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
"dev": true
},
"json-stable-stringify": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz",
"integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=",
"dev": true,
"requires": {
"jsonify": "~0.0.0"
}
},
"jsonify": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
"dev": true
},
"jsonparse": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
"integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=",
"dev": true
},
"labeled-stream-splicer": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.1.tgz",
"integrity": "sha512-MC94mHZRvJ3LfykJlTUipBqenZz1pacOZEMhhQ8dMGcDHs0SBE5GbsavUXV7YtP3icBW17W0Zy1I0lfASmo9Pg==",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"isarray": "^2.0.4",
"stream-splicer": "^2.0.0"
},
"dependencies": {
"isarray": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.4.tgz",
"integrity": "sha512-GMxXOiUirWg1xTKRipM0Ek07rX+ubx4nNVElTJdNLYmNO/2YrDkgJGw9CljXn+r4EWiDQg/8lsRdHyg2PJuUaA==",
"dev": true
}
}
},
"lodash.memoize": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz",
"integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=",
"dev": true
},
"md5.js": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
"integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==",
"dev": true,
"requires": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1",
"safe-buffer": "^5.1.2"
}
},
"miller-rabin": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz",
"integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==",
"dev": true,
"requires": {
"bn.js": "^4.0.0",
"brorand": "^1.0.1"
}
},
"minimalistic-assert": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==",
"dev": true
},
"minimalistic-crypto-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz",
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=",
"dev": true
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "1.2.0",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
}
}
},
"module-deps": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.1.0.tgz",
"integrity": "sha512-NPs5N511VD1rrVJihSso/LiBShRbJALYBKzDW91uZYy7BpjnO4bGnZL3HjZ9yKcFdZUWwaYjDz9zxbuP7vKMuQ==",
"dev": true,
"requires": {
"JSONStream": "^1.0.3",
"browser-resolve": "^1.7.0",
"cached-path-relative": "^1.0.0",
"concat-stream": "~1.6.0",
"defined": "^1.0.0",
"detective": "^5.0.2",
"duplexer2": "^0.1.2",
"inherits": "^2.0.1",
"parents": "^1.0.0",
"readable-stream": "^2.0.2",
"resolve": "^1.4.0",
"stream-combiner2": "^1.1.1",
"subarg": "^1.0.0",
"through2": "^2.0.0",
"xtend": "^4.0.0"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1"
}
},
"os-browserify": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz",
"integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=",
"dev": true
},
"pako": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz",
"integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==",
"dev": true
},
"parents": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz",
"integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=",
"dev": true,
"requires": {
"path-platform": "~0.11.15"
}
},
"parse-asn1": {
"version": "5.1.1",
"resolved": "http://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz",
"integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==",
"dev": true,
"requires": {
"asn1.js": "^4.0.0",
"browserify-aes": "^1.0.0",
"create-hash": "^1.1.0",
"evp_bytestokey": "^1.0.0",
"pbkdf2": "^3.0.3"
}
},
"path-browserify": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
"integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==",
"dev": true
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
},
"path-parse": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
"dev": true
},
"path-platform": {
"version": "0.11.15",
"resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz",
"integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=",
"dev": true
},
"pbkdf2": {
"version": "3.0.17",
"resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz",
"integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==",
"dev": true,
"requires": {
"create-hash": "^1.1.2",
"create-hmac": "^1.1.4",
"ripemd160": "^2.0.1",
"safe-buffer": "^5.0.1",
"sha.js": "^2.4.8"
}
},
"process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=",
"dev": true
},
"process-nextick-args": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
"dev": true
},
"public-encrypt": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz",
"integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==",
"dev": true,
"requires": {
"bn.js": "^4.1.0",
"browserify-rsa": "^4.0.0",
"create-hash": "^1.1.0",
"parse-asn1": "^5.0.0",
"randombytes": "^2.0.1",
"safe-buffer": "^5.1.2"
}
},
"punycode": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
"integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
"dev": true
},
"querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=",
"dev": true
},
"querystring-es3": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz",
"integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=",
"dev": true
},
"randombytes": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz",
"integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==",
"dev": true,
"requires": {
"safe-buffer": "^5.1.0"
}
},
"randomfill": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz",
"integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==",
"dev": true,
"requires": {
"randombytes": "^2.0.5",
"safe-buffer": "^5.1.0"
}
},
"read-only-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz",
"integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=",
"dev": true,
"requires": {
"readable-stream": "^2.0.2"
}
},
"readable-stream": {
"version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"resolve": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz",
"integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==",
"dev": true,
"requires": {
"path-parse": "^1.0.5"
}
},
"ripemd160": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz",
"integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==",
"dev": true,
"requires": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true
},
"sha.js": {
"version": "2.4.11",
"resolved": "http://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"shasum": {
"version": "1.0.2",
"resolved": "http://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz",
"integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=",
"dev": true,
"requires": {
"json-stable-stringify": "~0.0.0",
"sha.js": "~2.4.4"
}
},
"shell-quote": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz",
"integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=",
"dev": true,
"requires": {
"array-filter": "~0.0.0",
"array-map": "~0.0.0",
"array-reduce": "~0.0.0",
"jsonify": "~0.0.0"
}
},
"simple-concat": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz",
"integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=",
"dev": true
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"dev": true
},
"stream-browserify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz",
"integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=",
"dev": true,
"requires": {
"inherits": "~2.0.1",
"readable-stream": "^2.0.2"
}
},
"stream-combiner2": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz",
"integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=",
"dev": true,
"requires": {
"duplexer2": "~0.1.0",
"readable-stream": "^2.0.2"
}
},
"stream-http": {
"version": "2.8.3",
"resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz",
"integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==",
"dev": true,
"requires": {
"builtin-status-codes": "^3.0.0",
"inherits": "^2.0.1",
"readable-stream": "^2.3.6",
"to-arraybuffer": "^1.0.0",
"xtend": "^4.0.0"
}
},
"stream-splicer": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz",
"integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=",
"dev": true,
"requires": {
"inherits": "^2.0.1",
"readable-stream": "^2.0.2"
}
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true,
"requires": {
"safe-buffer": "~5.1.0"
}
},
"subarg": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz",
"integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=",
"dev": true,
"requires": {
"minimist": "^1.1.0"
}
},
"syntax-error": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz",
"integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==",
"dev": true,
"requires": {
"acorn-node": "^1.2.0"
}
},
"through": {
"version": "2.3.8",
"resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
"dev": true
},
"through2": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz",
"integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=",
"dev": true,
"requires": {
"readable-stream": "^2.1.5",
"xtend": "~4.0.1"
}
},
"timers-browserify": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz",
"integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=",
"dev": true,
"requires": {
"process": "~0.11.0"
}
},
"to-arraybuffer": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
"integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=",
"dev": true
},
"tty-browserify": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz",
"integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==",
"dev": true
},
"typedarray": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
"dev": true
},
"umd": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz",
"integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==",
"dev": true
},
"undeclared-identifiers": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.2.tgz",
"integrity": "sha512-13EaeocO4edF/3JKime9rD7oB6QI8llAGhgn5fKOPyfkJbRb6NFv9pYV6dFEmpa4uRjKeBqLZP8GpuzqHlKDMQ==",
"dev": true,
"requires": {
"acorn-node": "^1.3.0",
"get-assigned-identifiers": "^1.2.0",
"simple-concat": "^1.0.0",
"xtend": "^4.0.1"
}
},
"url": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz",
"integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=",
"dev": true,
"requires": {
"punycode": "1.3.2",
"querystring": "0.2.0"
},
"dependencies": {
"punycode": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz",
"integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=",
"dev": true
}
}
},
"util": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
"integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
"dev": true,
"requires": {
"inherits": "2.0.3"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
"dev": true
},
"vm-browserify": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz",
"integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==",
"dev": true
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"xtend": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=",
"dev": true
}
}
}
{
"name": "torn-tools",
"version": "0.4.3",
"description": "tools for http://torn.com",
"main": "index.user.ts",
"scripts": {
"build": "./node_modules/.bin/tsc && ./node_modules/.bin/browserify ./js/index.js -o torn.user.js && node annotate.js"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gist.github.com/a388028207434279838c2d80a7a13278.git"
},
"author": "Jameson Aranda",
"license": "MIT",
"homepage": "https://gist.github.com/jamesona/a388028207434279838c2d80a7a13278/raw/torn.user.js",
"devDependencies": {
"browserify": "^16.2.3"
}
}
const BUY_BUTTON = 'span.buy-icon'
export function queryBuyButtons() {
return Array.from(document.querySelectorAll(BUY_BUTTON))
}
import { getImage } from "./getImage";
export async function sellAll() {
function setValues(elements, price) {
const inputs = elements.shift()
const checkbox = inputs.amount.firstElementChild.firstElementChild.children[1]
checkbox.click()
const textbox = inputs.price.firstElementChild.firstElementChild
textbox.dispatchEvent(new Event('focus'))
textbox.value = price
textbox.dispatchEvent(new KeyboardEvent('keypress', { key: 'tab' }))
textbox.dispatchEvent(new Event('change'))
textbox.dispatchEvent(new Event('blur'))
setTimeout(() => setValues(elements, price), 10)
}
const src = await getImage()
setTimeout(() => {
const images = Array.from(document.querySelectorAll('[src="' + src + '"]'))
const actions = images.map(e => e.parentElement.parentElement.parentElement.nextElementSibling)
const inputs = actions.map(e => {
const divs = Array.from(e.children[0].children)
return {
amount: divs.find(e => e.className === 'amount'),
price: divs.find(e => e.className === 'price')
}
}).filter(i => i.amount && i.price)
const price = prompt('Enter Price')
setValues(inputs, price)
}, 2000)
}
export function stringToCharSum(str: string): number {
const a = 'abcdefghijklmnopqrstuvwxyz'.split('')
return str.toLowerCase().split('').map(c => a.indexOf(c)).reduce((acc, cur) => acc + cur)
}
//==UserScript==
//@name torn-tools
//@namespace http://tampermonkey.net/
//@version 0.4.3
//@description tools for http://torn.com
//@author Jameson Aranda
//@match https://www.torn.com
//@include https://www.torn.com*
//@grant none
//==/UserScript==
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const getImage_1 = require("./getImage");
function buyAllInBazaar() {
waitForClickAndBuy();
}
exports.buyAllInBazaar = buyAllInBazaar;
function waitForClickAndBuy() {
return __awaiter(this, void 0, void 0, function* () {
const img = yield getImage_1.getImage();
buyAll(img);
});
}
function buyAll(img) {
const query = `[src="${img}"]`;
const elements = Array.from(document.querySelectorAll(query));
const prices = elements.map(getPrice);
const minPrice = Math.min(...prices);
const safePurchases = elements.filter(e => getPrice(e) <= minPrice * 1.15);
const total = safePurchases.map(getPrice).reduce((a, c) => a + c);
if (confirm(`Buying ${safePurchases.length} items for ${total}. Continue?`)) {
safePurchases.forEach((element) => {
const baseElement = element.parentElement;
baseElement.children[1].children[1].click();
setTimeout(() => baseElement.nextElementSibling.children[1].children[2].click(), 300);
setTimeout(() => baseElement.parentElement.nextElementSibling.children[1].children[1].children[0].click(), 300);
setTimeout(() => baseElement.nextElementSibling.children[1].children[2].click(), 300);
});
}
}
function getPrice(e) {
const info = e.parentElement.parentElement;
const description = Array.from(info.children)
.find(e => e.className === 'desc');
const price = Array.from(description.firstElementChild.children)
.find(e => e.classList.contains('price'));
return Number(price.innerText.replace(/[$,]/g, ''));
}
},{"./getImage":5}],2:[function(require,module,exports){
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const queryBuyButtons_1 = require("./queryBuyButtons");
const buyMarketItem_1 = require("./buyMarketItem");
const waitAndTryAgain_1 = require("./waitAndTryAgain");
const config_1 = require("./config");
function buyAllInMarket(maxPrice) {
return __awaiter(this, void 0, void 0, function* () {
const allButtons = yield waitForButtons();
const buttons = allButtons.filter(button => {
const costElement = Array.from(button.parentElement.parentElement.parentElement.children).find((element) => element.classList.contains('cost'));
const price = buyMarketItem_1.parsePrice(costElement.innerText);
const type = buyMarketItem_1.getItemType();
return (!config_1.Config.maxPrices || !config_1.Config.maxPrices[type] || price < config_1.Config.maxPrices[type]);
});
if (!buttons.length) {
const done = yield buyMarketItem_1.wait(5000);
}
while (buttons.length) {
const button = yield buyMarketItem_1.buyMarketItem(buttons.shift(), maxPrice);
}
window.location.reload();
});
}
exports.buyAllInMarket = buyAllInMarket;
function waitForButtons() {
return __awaiter(this, void 0, void 0, function* () {
let buttons;
while (buttons === undefined) {
buttons = yield waitAndTryAgain_1.waitAndTryAgain(() => queryBuyButtons_1.queryBuyButtons());
}
return buttons;
});
}
},{"./buyMarketItem":3,"./config":4,"./queryBuyButtons":7,"./waitAndTryAgain":9}],3:[function(require,module,exports){
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const queryBuyButtons_1 = require("./queryBuyButtons");
const waitAndTryAgain_1 = require("./waitAndTryAgain");
const config_1 = require("./config");
function buyMarketItem(buyButton, maxPrice) {
return __awaiter(this, void 0, void 0, function* () {
if (buyButton instanceof Event)
buyButton = undefined;
buyButton = buyButton || queryBuyButtons_1.queryBuyButtons()[0];
return yield buyItem(buyButton, maxPrice);
});
}
exports.buyMarketItem = buyMarketItem;
function parsePrice(price) {
return Number(price.replace(/[\$,]/g, ''));
}
exports.parsePrice = parsePrice;
function getPrice(confirmBar) {
let match = confirmBar.innerText.replace(',', '').match(/\$(\d+)/);
if (match) {
return parsePrice(match[1]);
}
else {
return null;
}
}
function queryToObject(query) {
return query.replace(/\?/, '').split('&').reduce((prev, cur) => {
const [key, val] = cur.split('=');
prev[key] = val;
return prev;
}, {});
}
function getItemType() {
const params = window.location.hash.slice(2);
const paramsObj = queryToObject(params);
return paramsObj.type;
}
exports.getItemType = getItemType;
function findYesButton(buyButton) {
const confirmBar = buyButton.parentNode.parentNode
.parentNode.nextElementSibling
.children[0];
if (confirmBar) {
if (confirmBar.classList.contains('t-red') || confirmBar.innerText.includes('sorry')) {
return confirmBar.nextElementSibling;
}
else {
return confirmBar.children[2];
}
}
else {
return undefined;
}
}
function findBoughtText(yesButton) {
if (!yesButton
|| !yesButton.parentElement
|| !yesButton.parentElement.parentElement
|| !yesButton.parentElement.parentElement.nextElementSibling)
return undefined;
const successBar = yesButton.parentElement.parentElement.nextElementSibling;
const children = successBar.children[0].children;
// this is a shortcut for when complete
if (children)
return children[1];
}
function waitForYesButton(buyButton) {
return __awaiter(this, void 0, void 0, function* () {
let yesButton;
while (yesButton === undefined) {
yesButton = yield waitAndTryAgain_1.waitAndTryAgain(() => findYesButton(buyButton));
}
return yesButton;
});
}
function waitForBoughtText(yesButton) {
return __awaiter(this, void 0, void 0, function* () {
let bought;
while (!bought) {
bought = yield waitAndTryAgain_1.waitAndTryAgain(() => findBoughtText(yesButton));
}
return bought;
});
}
function buyItem(buyButton, maxPrice) {
return __awaiter(this, void 0, void 0, function* () {
if (!buyButton)
debugger;
buyButton.click();
const yesButton = yield waitForYesButton(buyButton);
const price = getPrice(yesButton.parentElement);
const type = getItemType();
if (maxPrice) {
if (price > maxPrice)
return null;
}
config_1.Config.maxPrices = config_1.Config.maxPrices || {};
maxPrice = config_1.Config.maxPrices[type];
if (maxPrice && price > maxPrice) {
const message = `The price for this item ($${price})` +
` is greater than your previous max price ($${maxPrice}),` +
' would you like to buy and set a new max?';
if (!confirm(message)) {
const done = yield wait(3000);
window.location.reload();
}
}
if (!maxPrice || price > maxPrice) {
config_1.Config.maxPrices = Object.assign({}, config_1.Config.maxPrices, { [type]: price });
}
config_1.Config.lastPrices = config_1.Config.lastPrices || {};
config_1.Config.lastPrices = Object.assign({}, config_1.Config.lastPrices, { [type]: price });
if (yesButton.classList.contains('close-icon')) {
yesButton.click();
return null;
}
else {
yesButton.click();
const boughtMessage = yield waitForBoughtText(yesButton);
return boughtMessage;
}
});
}
function wait(time) {
return new Promise(resolve => {
debugger;
setTimeout(() => resolve('done!'), time);
});
}
exports.wait = wait;
},{"./config":4,"./queryBuyButtons":7,"./waitAndTryAgain":9}],4:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const KEY = 'tornbarconfig';
window.localStorage.__proto__.clear = () => { };
// get(target, prop, receiver) {
// return Reflect.get(realStorage, prop, receiver)
// },
// set(target, prop, value) {
// return Reflect.set(realStorage, prop, value)
// }
function getConfig() {
const storage = localStorage.getItem(KEY);
try {
return JSON.parse(storage);
}
catch (e) {
debugger;
return {};
}
}
function setConfig(config) {
localStorage.setItem(KEY, JSON.stringify(config));
}
exports.Config = new Proxy({}, {
get(target, prop, receiver) {
const _config = getConfig() || {};
return Reflect.get(_config, prop, receiver);
},
set(target, property, value) {
try {
const _config = getConfig() || {};
_config[property] = value;
setConfig(_config);
return true;
}
catch (e) {
debugger;
return false;
}
}
});
},{}],5:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getImage() {
const style = document.createElement('style');
style.innerHTML = `.item-hover, .image-wrap {cursor: crosshair !important;}`;
return new Promise(resolve => {
const onClick = e => {
let img;
switch (e.target.className) {
case 'view-h':
case 'buy-h':
case 'item-hover': {
img = e.target.parentElement.previousElementSibling;
break;
}
case 'image-wrap': {
img = e.target.children[0].children[0];
break;
}
default: {
if (e.target.tagName === 'IMG')
img = e.target;
}
}
if (!img || !img.src)
return;
window.removeEventListener('click', onClick);
document.body.removeChild(style);
resolve(img.src.replace('https://www.torn.com', ''));
};
document.body.appendChild(style);
window.addEventListener('click', onClick);
});
}
exports.getImage = getImage;
},{}],6:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const buyMarketItem_1 = require("./buyMarketItem");
const buyAllInMarket_1 = require("./buyAllInMarket");
const buyAllInBazaar_1 = require("./buyAllInBazaar");
const sellAllInBazaar_1 = require("./sellAllInBazaar");
const config_1 = require("./config");
function main() {
const header = document.querySelector('.header-wrapper-bottom');
const buttons = document.createElement('div');
buttons.style.margin = 'auto';
buttons.style.maxWidth = '30vw';
buttons.style.position = 'fixed';
const buttonConfigs = [{
name: 'Buy Top Item',
task: buyMarketItem_1.buyMarketItem
}, {
name: 'Buy All Listings',
task: buyAllInMarket_1.buyAllInMarket
}, {
name: 'Buy All In Bazaar',
task: buyAllInBazaar_1.buyAllInBazaar
}, {
name: 'Sell All',
task: sellAllInBazaar_1.sellAll
}];
const autoBuyToggle = createAutoBuyToggle();
appendChildren([...makeButtons(buttonConfigs), autoBuyToggle], buttons);
const style = createStyle();
appendChildren([buttons, style], header);
header && header.appendChild(buttons);
if (window.location.pathname.includes('market') && config_1.Config.autoBuy) {
const item = buyMarketItem_1.getItemType();
const maxPrice = config_1.Config.maxPrices[item];
buyAllInMarket_1.buyAllInMarket(Number(maxPrice));
}
}
function createStyle() {
const style = document.createElement('style');
style.innerHTML = `
button {
color: gray;
background: black;
border: 1px solid currentColor;
margin: 5px;
cursor: pointer;
}
button:hover {
color: #ccc;
}
`;
return style;
}
function createButton(config) {
const { name, task } = config;
const button = document.createElement('button');
button.innerText = name;
button.addEventListener('click', task);
return button;
}
function makeButtons(buttons) {
return buttons.map(config => createButton(config));
}
function createAutoBuyToggle() {
const input = document.createElement('input');
input.type = 'checkbox';
input.id = 'auto-buy';
input.onchange = () => {
config_1.Config.autoBuy = !!(input.checked);
};
input.checked = !!(config_1.Config.autoBuy);
return input;
}
function appendChildren(children, parent) {
children.forEach(child => parent.appendChild(child));
}
main();
},{"./buyAllInBazaar":1,"./buyAllInMarket":2,"./buyMarketItem":3,"./config":4,"./sellAllInBazaar":8}],7:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const BUY_BUTTON = 'span.buy-icon';
function queryBuyButtons() {
return Array.from(document.querySelectorAll(BUY_BUTTON));
}
exports.queryBuyButtons = queryBuyButtons;
},{}],8:[function(require,module,exports){
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const getImage_1 = require("./getImage");
function sellAll() {
return __awaiter(this, void 0, void 0, function* () {
function setValues(elements, price) {
const inputs = elements.shift();
const checkbox = inputs.amount.firstElementChild.firstElementChild.children[1];
checkbox.click();
const textbox = inputs.price.firstElementChild.firstElementChild;
textbox.dispatchEvent(new Event('focus'));
textbox.value = price;
textbox.dispatchEvent(new KeyboardEvent('keypress', { key: 'tab' }));
textbox.dispatchEvent(new Event('change'));
textbox.dispatchEvent(new Event('blur'));
setTimeout(() => setValues(elements, price), 10);
}
const src = yield getImage_1.getImage();
setTimeout(() => {
const images = Array.from(document.querySelectorAll('[src="' + src + '"]'));
const actions = images.map(e => e.parentElement.parentElement.parentElement.nextElementSibling);
const inputs = actions.map(e => {
const divs = Array.from(e.children[0].children);
return {
amount: divs.find(e => e.className === 'amount'),
price: divs.find(e => e.className === 'price')
};
}).filter(i => i.amount && i.price);
const price = prompt('Enter Price');
setValues(inputs, price);
}, 2000);
});
}
exports.sellAll = sellAll;
},{"./getImage":5}],9:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function waitAndTryAgain(fn, ttl = 100) {
return new Promise(resolve => {
setTimeout(() => {
resolve(fn());
}, ttl);
});
}
exports.waitAndTryAgain = waitAndTryAgain;
},{}]},{},[6]);
{
"compileOnSave": true,
"compilerOptions": {
"outDir": "./js",
"sourceMap": true,
"declaration": false,
"noImplicitAny": false,
"target": "es6",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2016",
"dom"
],
"module": "commonjs"
},
"include": ["**/*.ts"],
"exclude": []
}
export function waitAndTryAgain(fn: () => void, ttl: number = 100): Promise<void> {
return new Promise(resolve => {
setTimeout(() => {
resolve(fn())
}, ttl)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.