-
Notifications
You must be signed in to change notification settings - Fork 0
/
scriptautorunner.js
69 lines (66 loc) · 2.71 KB
/
scriptautorunner.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
sumHL = function(selector) {
var sumHL = 0;
var sum = 0;
var toTest = $(selector).length;
$(selector).each(function() {
var urlFrag = $(this).find('.full-link').attr('href') + ' #game-header-historical-low-prices .lowest-recorded > .numeric';
var div = $('<div>');
var toAddTo = $(this).find('.game-price');
var toSum = $(this).find('.game-price-new');
sum += Number(toSum.text().replace( /[^0-9,]/g, '' ).replace( ',', '.' ));
var howLongIs = "https://howlongis.io/results?search_query=" + $(this).find('.game-info-title').text().replaceAll(' ','+');
var checkWrapper = $(this).find('.game-options-wrapper');
var div2 = $('<a style="left:24px;text-align:center;vertical-align:middle;font-weight:bolt" class="game-options-trigger-btn" href='+howLongIs+'>@</a>');
checkWrapper.append(div2);
div.load(urlFrag, function() {
sumHL += Number(div.find('span').text().replace( /[^0-9,]/g, '' ).replace( ',', '.'));
toAddTo.append($(this));
toTest -= 1;
if (toTest == 0) {
console.log(sum + " out of lowest: " + sumHL);
var sumStr = (Math.ceil(100*sum)/100).toString().replace('.',',');
var totNr = $('.wishlist-item .game-price-new').length;
var avgStr = (Math.ceil(100*sum/totNr)/100).toString().replace('.',',');
var sumHLStr = (Math.ceil(100*sumHL )/100).toString().replace('.',',');
$('.main-title').append(" (Page avg.: ~€" + avgStr + "; tot.: ~€" + sumStr + " / ~€" + sumHLStr + " )");
return;
}
});
});
}
sumB = function(selector) {
var sumHL = 0;
var sum = 0;
var toTest = $(selector).length;
$(selector).each(function() {
var owned = $(this).find('.svg-icon-owned-fill');
var urlFrag = $(this).find('.full-link').attr('href') + ' #game-header-historical-low-prices .lowest-recorded > .numeric';
var div = $('<div>');
var toAddTo = $(this).find('.game-info-title');
div.load(urlFrag, function() {
var nrTest = div.find('span').text().replace( /[^0-9,]/g, '' ).replace( ',', '.');
if (owned.width() == 12) {
if ($.isNumeric(nrTest)) {
sumHL += Number(nrTest);
}
toAddTo.append($(this));
}
toTest -= 1;
if (toTest == 0) {
console.log(sum + " out of lowest: " + sumHL);
var sumHLStr = (Math.ceil(100*sumHL )/100).toString().replace('.',',');
$('.game-item-column-head').append(" (~€" + sumHLStr + " )");
return;
}
});
});
}
if (window.location.toString().includes("/wishlist/")) {
sumHL('.game-list-item');
}
if (window.location.toString().includes("/alerts/")) {
sumHL('.game-list-item');
}
else if (window.location.toString().includes("/bundle/")) {
sumB('.game-item-in-bundle');
}