-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_all_from_current_page.js
66 lines (56 loc) · 1.5 KB
/
add_all_from_current_page.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
(function()
{
if( location.href.match( /^https:\/\/steamcommunity\.com\/id\/0825771\/myworkshopfiles\/?/ ) === null )
{
alert( 'Please run this on Torte de Lini\'s guide page: https://steamcommunity.com/id/0825771/myworkshopfiles/?section=guides&p=1&numperpage=30' );
window.location = 'https://steamcommunity.com/id/0825771/myworkshopfiles/?section=guides&p=1&numperpage=30';
return;
}
var guideList = [];
var subscribedList = [];
jQuery("script").each(function(){
var guidematch = jQuery(this).html().match(/SharedFileBindMouseHover\( "(.*?)", true, (.*?) \);/);
if(guidematch){
var guidedetail = jQuery.parseJSON(guidematch[2]);
guideList.push(guidedetail.id);
subscribedList[guidedetail.id] = guidedetail.user_subscribed;
}
});
var i = 0,
loaded = 0,
package = 0,
total = guideList.length,
modal = ShowBlockingWaitDialog( 'Executing…',
'Please wait until all requests finish. Ignore all the errors, let it finish.' );
for( ; i < total; i++ )
{
guideid = guideList[ i ];
if( subscribedList[ guideid ] )
{
loaded++;
continue;
}
jQuery.post(
'//steamcommunity.com/sharedfiles/subscribe',
{
appid: 570,
id: guideid,
sessionid: g_sessionID
}
).always( function( )
{
loaded++;
modal.Dismiss();
if( loaded >= total )
{
location.reload();
}
else
{
modal = ShowBlockingWaitDialog( 'Executing…',
'Loaded <b>' + loaded + '</b>/' + total + '.' );
}
}
);
}
}());