Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Simultaneous Ending Time setter
- // @namespace http://steamcommunity.com/id/tragikos/
- // @version 0.3
- // @description A button that sets the correct ending time for your giveaway according to your timezone
- // @author tragikos
- // @match http://www.steamgifts.com/giveaways/new
- // @grant none
- // @run-at document-end
- // ==/UserScript==
- var eventDateUTC = '1/1/2016 00:00:00 UTC'; // 1st of July
- var startingTimeMinOffset = 5;
- var groupId = "1898";
- var description="##Simultaneous Giveaways Winter 2015 \n\n---------------- \n\n";
- function formatDate(date) {
- var formattedDate = $.datepicker.formatDate('M d, yy', date);
- var hours = date.getHours()%12 < 10 ? '0'+date.getHours()%12 : date.getHours()%12;
- var minutes = date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes();
- var ampm = date.getHours() >= 12 ? 'pm' : 'am';
- formattedDate += " " + hours + ":" + minutes + " " + ampm;
- return formattedDate;
- }
- function applyDates() {
- $("input[name='start_time']").val(formatDate(new Date(new Date().getTime() + startingTimeMinOffset*60000)));
- var date = new Date(eventDateUTC);
- $("input[name='end_time']").val(formatDate(date));
- }
- function applyRegionRestrictions() {
- $("div[data-checkbox-value='0']").trigger("click");
- }
- function applyGroup() {
- $("div[data-checkbox-value='groups']").trigger("click");
- $("div[data-group-id='" + groupId + "']").children('div').eq(1).trigger("click");
- }
- function applyGenericDescription(){
- var newDesc = description + $("textarea[name='description']").val().replace(description, "");
- $("textarea[name='description']").val(newDesc);
- }
- $(".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> SimGive Date</div>');
- $("#dateBtn").css({
- 'height': '32px'
- });
- $("#dateBtn").click(function() {
- applyDates();
- applyRegionRestrictions();
- applyGroup();
- applyGenericDescription();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement