Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. var log = console.log.bind(console); // just a shortcut to console.log
  2. var options = {
  3. group: 915505, // if the user isn't in this group, he'll be ignored
  4. waitTime: 5000 // number of milliseconds to wait between messages
  5. };
  6.  
  7. // called when we want to send to all users
  8. function run() {
  9. var promise = Promise.resolve();
  10. var elms = document.querySelectorAll(
  11. "#ctl00_cphRoblox_rbxGroupRoleSetMembersPane_GroupMembersUpdatePanel .GroupMember .Name"
  12. );
  13. for (var i = 0, j = elms.length; i < j; ++i) {
  14. var id = elms[i].href.match(/\d+/)[0],
  15. name = elms[i].textContent;
  16.  
  17. // IIFE so id and name don't change
  18. (function(id, name) {
  19. // add to the queue
  20. promise = promise.then(function() {
  21. return new Promise(function(resolve) {
  22. setTimeout(resolve.bind(null, {
  23. id: id,
  24. name: name
  25. }, waitTime));
  26. });
  27. })
  28. .then(checkUser)
  29. .then(sendMsg)
  30. .then(function(user) {
  31. log("Sent message to", user.name, "(", user.id, ")");
  32. })
  33. .catch(function(err) {
  34. // log any errors to console
  35. console.error("Error sending to", name, "(", id, "):", err);
  36. // if we got blocked for flood reasons, wait another 5 seconds
  37. if (err.shortMessage && err.shortMessage.find("flood")) {
  38. return new Promise(function(resolve) {
  39. setTimeout(resolve, 5000); // whoo, magic numbers
  40. });
  41. }
  42. });
  43. })(id, name);
  44. }
  45.  
  46. __doPostBack('ctl00$cphRoblox$rbxGroupRoleSetMembersPane$dlUsers_Footer$ctl02$ctl00', '');
  47. }
  48.  
  49. // check if a user is in a group. User format: {id: <String>, name: <String>}
  50. function checkUser(user) {
  51. if (!options.group) {
  52. return user; // pass the user on to the next function
  53. }
  54.  
  55. // if we *do* have a group to filter by, do so
  56. return
  57. $.get('http://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid=' + userId + '&groupid=' + group)
  58. .done(function(response) {
  59. if (response.indexOf("true") === -1) {
  60. return user; // pass the user on to the next function
  61. } else {
  62. throw "User is already in the group."
  63. }
  64. });
  65. }
  66.  
  67. // send a message to the user. User format: {id: <String>, name: <String>}
  68. function sendMsg(user) {
  69. return $.post('http://www.roblox.com/messages/send', {
  70. subject: "Subject",
  71. body: "Body",
  72. recipientid: user.id,
  73. cacheBuster: Date.now()
  74. })
  75. .done(function(response) {
  76. if (response.success == true) {
  77. return;
  78. } else {
  79. throw response;
  80. }
  81. })
  82. }
  83.  
  84. // I have no idea what this is doing here
  85. function __doPostBack(eventTarget, eventArgument) {
  86. if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
  87. theForm.__EVENTTARGET.value = eventTarget;
  88. theForm.__EVENTARGUMENT.value = eventArgument;
  89. theForm.submit();
  90. }
  91. }
  92.  
  93.  
  94. // wait for the DOM to load - you could also place the <script> tag
  95. // as the last child of the <body>. I personally prefer that approach
  96. document.addEventListener("DOMContentLoaded", function() {
  97. // call run when the DOM loads, and also when #__EVENTTARGET changes its value
  98. document.getElementById('__EVENTTARGET').addEventListener("change", function() {
  99. if (this.value === "") {
  100. run();
  101. }
  102. });
  103. run();
  104. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement