View difference between Paste ID: KHvUURXd and fCYTf2bH
SHOW: | | - or go back to the newest paste.
1
// ==UserScript==
2-
// @name         Student's trains
2+
// @name         A SG Train Making Script
3
// @namespace    http://steamcommunity.com/id/tragikos/
4-
// @version      0.3
4+
// @version      0.4
5
// @description  A button that sets the correct ending time for your giveaway according to your timezone
6-
// @author       tragikos
6+
// @author       tragikos updated by Leomoty
7
// @match        http://www.steamgifts.com/giveaways/new
8
// @grant        none
9
// @run-at       document-end
10
// ==/UserScript==
11
12-
var startDateUTC = '6/5/2015 00:00:00 UTC'; // 5th of June
12+
13-
var eventDateUTC = '6/15/2015 00:00:00 UTC'; // 15th of June
13+
14-
var startingTimeMinOffset = 5;
14+
var startDateUTC = '6/4/2015 18:59:00 UTC'; // 4th of June
15
var eventDateUTC = '6/14/2015 14:00:00 UTC'; // 14th of June
16-
var description="##My giveaway train  \n\n----------------  \n\n";
16+
var startingTimeMinOffset = 0;
17
var ContributorLevel = 3;
18
var groupId = "1898";
19
var description="##Description Here  \n\n----------------  \n\n";
20
21
function formatDate(date) {
22
    var formattedDate = $.datepicker.formatDate('M d, yy', date);
23
    var hours = date.getHours()%12 < 10 ? '0'+date.getHours()%12 : date.getHours()%12;
24
    var minutes = date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes();
25
	var ampm = date.getHours() >= 12 ? 'pm' : 'am';
26
    formattedDate += " " + hours + ":" + minutes + " " + ampm;
27
    
28
    return formattedDate;
29
}
30
31
function applyDates() {
32
	var startDate = new Date(startDateUTC)
33
    $("input[name='start_time']").val(formatDate(startDate));
34
    
35
    var endDate = new Date(eventDateUTC);
36
    $("input[name='end_time']").val(formatDate(endDate));
37
}
38
39
function applyRegionRestrictions() {
40
    $("div[data-checkbox-value='0']").trigger("click");
41
}
42
43
function applyGroup() {
44
    $("div[data-checkbox-value='invite_only']").trigger("click");
45
}
46
47
function applyLevel() {
48
$('input[name=contributor_level]').val(ContributorLevel);
49
}
50
51
52
function applyGenericDescription(){
53
    var newDesc = description + $("textarea[name='description']").val().replace(description, "");
54
    $("textarea[name='description']").val(newDesc);
55
}
56
57
$(".form__time-container").children('div').eq(1).after('<div id="dateBtn" class="form__submit-button js__submit-form"><i class="fa fa-arrow-circle-right"></i> My Train</div>');
58
$("#dateBtn").css({
59
    'height': '32px'
60
});
61
62
$("#dateBtn").click(function() {
63
	applyDates();
64
    applyRegionRestrictions();
65
    applyGroup();
66
    applyLevel();
67
    applyGenericDescription();
68
});