Advertisement
Guest User

SimGive winter event

a guest
Nov 27th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Simultaneous Ending Time setter
  3. // @namespace http://steamcommunity.com/id/tragikos/
  4. // @version 0.3
  5. // @description A button that sets the correct ending time for your giveaway according to your timezone
  6. // @author tragikos
  7. // @match http://www.steamgifts.com/giveaways/new
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. var eventDateUTC = '1/1/2016 00:00:00 UTC'; // 1st of July
  13. var startingTimeMinOffset = 5;
  14. var groupId = "1898";
  15. var description="##Simultaneous Giveaways Winter 2015 \n\n---------------- \n\n";
  16.  
  17. function formatDate(date) {
  18. var formattedDate = $.datepicker.formatDate('M d, yy', date);
  19. var hours = date.getHours()%12 < 10 ? '0'+date.getHours()%12 : date.getHours()%12;
  20. var minutes = date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes();
  21. var ampm = date.getHours() >= 12 ? 'pm' : 'am';
  22. formattedDate += " " + hours + ":" + minutes + " " + ampm;
  23.  
  24. return formattedDate;
  25. }
  26.  
  27. function applyDates() {
  28. $("input[name='start_time']").val(formatDate(new Date(new Date().getTime() + startingTimeMinOffset*60000)));
  29.  
  30. var date = new Date(eventDateUTC);
  31. $("input[name='end_time']").val(formatDate(date));
  32. }
  33.  
  34. function applyRegionRestrictions() {
  35. $("div[data-checkbox-value='0']").trigger("click");
  36. }
  37.  
  38. function applyGroup() {
  39. $("div[data-checkbox-value='groups']").trigger("click");
  40. $("div[data-group-id='" + groupId + "']").children('div').eq(1).trigger("click");
  41. }
  42.  
  43. function applyGenericDescription(){
  44. var newDesc = description + $("textarea[name='description']").val().replace(description, "");
  45. $("textarea[name='description']").val(newDesc);
  46. }
  47.  
  48. $(".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>');
  49. $("#dateBtn").css({
  50. 'height': '32px'
  51. });
  52.  
  53. $("#dateBtn").click(function() {
  54. applyDates();
  55. applyRegionRestrictions();
  56. applyGroup();
  57. applyGenericDescription();
  58. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement