forked from dodying/UserJs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhvRepairEpument.user.js
87 lines (87 loc) · 2.74 KB
/
hvRepairEpument.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// ==UserScript==
// @name [HV]RepairEpument
// @author dodying
// @namespace https://github.com/dodying/Dodying-UserJs
// @supportURL https://github.com/dodying/Dodying-UserJs/issues
// @icon http://cdn4.iconfinder.com/data/icons/mood-smiles/80/mood-29-48.png
// @include http*://hentaiverse.org/?s=Forge&ss=re*
// @include http://alt.hentaiverse.org/?s=Forge&ss=re*
// @version 1.00
// @grant none
// @run-at document-end
// ==/UserScript==
(function () {
var Material = [
{
'name': 'Scrap Cloth',
'code': '60051',
'cost': '100'
},
{
'name': 'Scrap Leather',
'code': '60052',
'cost': '100'
},
{
'name': 'Scrap Metal',
'code': '60053',
'cost': '100'
},
{
'name': 'Scrap Wood',
'code': '60054',
'cost': '100'
},
{
'name': 'Energy Cell',
'code': '60071',
'cost': '200'
}
]
var materialsList = document.querySelectorAll('#repairall+div span')
var xhr = new window.XMLHttpRequest()
xhr.open('GET', window.location.origin + '/?s=Bazaar&ss=is&filter=ma')
xhr.setRequestHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
xhr.responseType = 'document'
xhr.onload = function () {
var token = xhr.response.querySelector('input[name="storetoken"]').value
if (materialsList.length > 0) {
for (var i = 0; i < materialsList.length; i++) {
var amount = materialsList[i].innerHTML.match(/\d+/)[0]
var code = Material[materialsName2Code(materialsList[i].innerHTML.match(/\d+x (.*)/)[1])].code
Buy(code, amount, Material[i].cost, token)
}
setTimeout(function () {
document.querySelector('#repairall div').click()
}, 3000)
}
}
xhr.send(null)
})()
/// ////////////////////////////////////////////////////////////
function materialsName2Code (name) {
switch (name) {
case 'Scrap Cloth':
return '0'
case 'Scrap Leather':
return '1'
case 'Scrap Metal':
return '2'
case 'Scrap Wood':
return '3'
case 'Energy Cell':
return '4'
}
}
function Buy (code, amount, cost, token) {
var xhr = 'xhr_Buy' + Math.random().toString()
xhr = new window.XMLHttpRequest()
xhr.open('POST', window.location.origin + '/?s=Bazaar&ss=is&filter=ma')
var parm = 'storetoken=' + token + '&select_mode=shop_pane&select_item=' + code + '&select_count=' + amount // item_pane卖 shop_pane买
xhr.setRequestHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
xhr.send(parm)
xhr.onload = function () {
}
}