-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsteamToolsExport.user.js
More file actions
104 lines (104 loc) · 3.6 KB
/
steamToolsExport.user.js
File metadata and controls
104 lines (104 loc) · 3.6 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// ==UserScript==
// @name steamToolsExport
// @namespace KlappPcSteamToolsExport
// @include http://steam.tools/itemvalue/*
// @include https://steamcommunity.com/tradeoffer/new/*
// @version 1
// @grant GM_getValue
// @grant GM_setValue
// @grant unsafeWindow
// ==/UserScript==
var fullString = '';
function addItem(ele) {
var counter = ele.getElementsByClassName('counter ng-binding') [0];
var price = ele.getElementsByClassName('price ng-binding') [0];
fullString += unescape(ele.href.substring(46)).replace('-', ';');
fullString += ';';
fullString += counter.innerText.substring(1);
fullString += ';';
fullString += price.innerText.substring(0, price.innerText.length).replace('.', '').replace(',', '').replace('$', '').replace('€', '');
fullString += '\n';
}
function main1() {
try {
var itemBox = document.getElementsByClassName('itemBox');
var items = itemBox[0].getElementsByTagName('a');
for (var i = 0; i < items.length; i++) {
addItem(items[i]);
}
GM_setValue('g_inventoryPrices', fullString);
console.debug('prices set');
} catch (err) {
console.debug(err.message);
}
}
var ME = 'KlappPcBot1';
var toSend = [
];
function doTradeOffer(elem) {
var item = elem.element.rgItem;
var markethash = item.market_hash_name;
var index = toSend.indexOf(markethash);
if (index > - 1) {
console.debug('moveitem ' + markethash);
unsafeWindow.MoveItemToTrade(elem.element);
toSend.splice(index, 1);
} else {
console.debug('ignoreitem ' + markethash);
}
}
function main() {
if (typeof GM_getValue('g_inventoryPrices') === 'undefined') {
console.debug('not doing shit');
alert('loadPricesFirst');
} else {
toSend = [
];
//var type = prompt('Please enter the type (0=value+above, 1= value, 2= value and below', '1');
var minvalue = prompt('Please enter the value in cent', '7');
var fullstring = GM_getValue('g_inventoryPrices');
var arr = fullstring.split('\n');
for (var i = 0; i < arr.length; i++) {
var arr2 = arr[i].split(';');
if (parseInt(minvalue) > 0) {
if (parseInt(arr2[3]) >= parseInt(minvalue)) {
for (var j = 0; j < parseInt(arr2[2]); j++) {
toSend.push(arr2[0] + '-' + arr2[1]);
}
} else {
console.debug('ignored' + arr2[0] + '-' + arr2[1] + ' (' + parseInt(arr2[3]) + ')');
}
}
if (parseInt(minvalue) <= 0) {
if (parseInt(arr2[3]) <= - parseInt(minvalue)) {
for (var j = 0; j < parseInt(arr2[2]); j++) {
toSend.push(arr2[0] + '-' + arr2[1]);
}
} else {
console.debug('ignored' + arr2[0] + '-' + arr2[1] + ' (' + parseInt(arr2[3]) + ')');
}
}
}
var inv = unsafeWindow.Draggables.drags;
for (var i = 0; i < inv.length; i++) {
doTradeOffer(inv[i]);
}
alert('Done');
// MoveItemToTrade(elem);
//console.debug(fullMap); //.forEach(function (owner){owner.forEach(console.debug)});
}
}
if (!document.URL.includes('community')) {
var btn = document.createElement('BUTTON');
var t = document.createTextNode('CLICK ME');
btn.appendChild(t);
btn.onclick = main1;
document.body.insertBefore(btn, document.getElementById('container'));
} else {
var btn = document.createElement('BUTTON'); // Create a <button> element
var t = document.createTextNode('Add'); // Create a text node
btn.appendChild(t);
btn.onclick = main;
parent = document.getElementById('mainContent'); // Append the text to <button>
parent.insertBefore(btn, document.getElementById('trade_escrow_header')); // Append <button> to <body>
}