Advertisement
PunasaurusRex

Puna's Trains

Jan 1st, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Puna's trains
  3. // @namespace http://steamcommunity.com/id/tragikos/
  4. // @version 0.9
  5. // @description A button that sets some predifined values for Puna's trains
  6. // @author tragikos
  7. // @match http://www.steamgifts.com/giveaways/new
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. var startingTimeMinOffset = 5; // 5 minutes after creation
  13. var eventDateUTC = '1/23/2016 12:00:00 UTC'; // 23rd of January / -6 hours from UTC
  14. var startingTimeMinOffset = 5;
  15. var levelRequirement = 7;
  16. var description="##Everybody Love Everybody's 3rd Bday Giveaways \n\n---------------- \n\nIf you enter something, please bump [ELE Bday Topic](http://www.steamgifts.com/discussion/zkbVr/eles-3rd-b-day-giveaway-party) \n\nIf you meet our requirements, and are interested in joining, please post [here](http://www.steamgifts.com/discussion/2gTRA/ele-is-recruiting-as-of-november-21-2015) \n\n---------------- \n\nPlease Enjoy This Game \n\nAlso, when the giveaway has ended, please be patient as there are 100+ for me to pass out";
  17.  
  18. function formatDate(date) {
  19. var formattedDate = $.datepicker.formatDate('M d, yy', date);
  20. var hours = date.getHours()%12 < 10 ? '0'+date.getHours()%12 : date.getHours()%12;
  21. var minutes = date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes();
  22. var ampm = date.getHours() >= 12 ? 'pm' : 'am';
  23. formattedDate += " " + hours + ":" + minutes + " " + ampm;
  24.  
  25. return formattedDate;
  26. }
  27.  
  28. function applyDates() {
  29. $("input[name='start_time']").val(formatDate(new Date(new Date().getTime() + startingTimeMinOffset*60000)));
  30.  
  31. var endDate = new Date(eventDateUTC);
  32. $("input[name='end_time']").val(formatDate(endDate));
  33. }
  34.  
  35. function applyRegionRestrictions() {
  36. $("div[data-checkbox-value='0']").trigger("click");
  37. }
  38.  
  39. function applyGroup() {
  40. $("div[data-checkbox-value='invite_only']").trigger("click");
  41. }
  42.  
  43. function applyLevel() {
  44. $("input[name='contributor_level']").val(levelRequirement);
  45. }
  46.  
  47. function applyGenericDescription(){
  48. var newDesc = description + $("textarea[name='description']").val().replace(description, "");
  49. $("textarea[name='description']").val(newDesc);
  50. }
  51.  
  52. $(".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>');
  53. $("#dateBtn").css({
  54. 'height': '32px'
  55. });
  56.  
  57. $("#dateBtn").click(function() {
  58. applyDates();
  59. applyRegionRestrictions();
  60. applyGroup();
  61. applyLevel();
  62. applyGenericDescription();
  63. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement