Advertisement
Guest User

Berlin train

a guest
Apr 4th, 2016
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Berlin train
  3. // @namespace    http://steamcommunity.com/id/Per3zat/
  4. // @version      0.1
  5. // @description  A button that sets the correct ending time for your giveaway according to your timezone
  6. // @author       Per3zat
  7. // @match        http://www.steamgifts.com/giveaways/new
  8. // @grant        none
  9. // @run-at       document-end
  10. // ==/UserScript==
  11. // based on tragikos' SimGive script, thanks matey!
  12.  
  13. var eventDateUTC = '5/1/2016 12:00:00 UTC'; // event end date
  14. var description="Replace this later with the Description provided by the line operator";
  15.  
  16. function formatDate(date) {
  17.     var formattedDate = $.datepicker.formatDate('M d, yy', date);
  18.     var hours = date.getHours()%12 < 10 ? '0'+date.getHours()%12 : date.getHours()%12;
  19.     var minutes = date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes();
  20.     var ampm = date.getHours() >= 12 ? 'pm' : 'am';
  21.     formattedDate += " " + hours + ":" + minutes + " " + ampm;
  22.    
  23.     return formattedDate;
  24. }
  25.  
  26. function applyDates() {
  27.     $("input[name='start_time']").val(formatDate(new Date(new Date().getTime())));
  28.    
  29.     var date = new Date(eventDateUTC);
  30.     $("input[name='end_time']").val(formatDate(date));
  31. }
  32.  
  33. function applyRegionRestrictions() {
  34.     $("div[data-checkbox-value='0']").trigger("click");
  35. }
  36.  
  37. function applyGroup() {
  38.     $("div[data-checkbox-value='invite_only']").trigger("click");
  39. }
  40.  
  41. function applyLevel() {
  42.     $("input[name='contributor_level']").val('1');
  43. }
  44.  
  45. function applyGenericDescription(){
  46.     var newDesc = description + $("textarea[name='description']").val().replace(description, "");
  47.     $("textarea[name='description']").val(newDesc);
  48. }
  49.  
  50. $(".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> Berlin Train</div>');
  51. $("#dateBtn").css({
  52.     'height': '32px'
  53. });
  54.  
  55. $("#dateBtn").click(function() {
  56.     applyDates();
  57.     applyRegionRestrictions();
  58.     applyGroup();
  59.     applyLevel();
  60.     applyGenericDescription();
  61. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement