Royalgamer06

Steam Community - Friends Poster

Jul 3rd, 2018
7,509
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var delay = 7; // Seconds in between posting profile comments
  2. ToggleManageFriends();
  3. console.log("Find the original userscript here:", "https://greasyfork.org/en/scripts/26001-steam-community-friends-poster/");
  4. jQuery("#manage_friends > .row:last").before(`
  5.     <div class="row commentthread_entry" style="background-color: initial; padding-right: 24px;">
  6.         <div class="commentthread_entry_quotebox">
  7.             <textarea rows="3" class="commentthread_textarea" id="comment_textarea" placeholder="Add a comment" style="overflow: hidden; height: 20px;"></textarea>
  8.         </div>
  9.         <div class="commentthread_entry_submitlink" style="">
  10.             <a class="btn_grey_black btn_small_thin" href="javascript:CCommentThread.FormattingHelpPopup('Profile');">
  11.             <span>Formatting help</span>
  12.             </a>
  13.             <span class="emoticon_container">
  14.             <span class="emoticon_button small" id="emoticonbtn">
  15.             </span>
  16.             </span>
  17.             <span class="btn_green_white_innerfade btn_small" id="comment_submit">
  18.             <span>Post Comments to Selected Friends</span>
  19.             </span>
  20.         </div>
  21.     </div>
  22.     <div class="row" id="log">
  23.         <span id="log_head"></span>
  24.         <span id="log_body"></span>
  25.     </div>`);
  26.  
  27. new CEmoticonPopup($J('#emoticonbtn'), $J('#commentthread_Profile_0_textarea'));
  28. jQuery("#comment_submit").click(() => {
  29.     const total = jQuery(".selected").length;
  30.     const msg = jQuery("#comment_textarea").val();
  31.     if (total === 0 || msg.length === 0) {
  32.         alert("Please make sure you entered a message and selected 1 or more friends.");
  33.         return;
  34.     }
  35.  
  36.     jQuery("#log_head, #log_body").html("");
  37.     jQuery(".selected").each((i, elem) => {
  38.         let profileID = jQuery(elem).data("steamid");
  39.         setTimeout(() => $.post("//steamcommunity.com/comment/Profile/post/" + profileID + "/-1/", {
  40.                 comment: msg,
  41.                 count: 6,
  42.                 sessionid: g_sessionID
  43.             }, response => {
  44.                 jQuery("#log_body").get()[0].innerHTML += "<br>" + (response.success === false ? response.error : "Successfully posted comment on <a href=\"https://steamcommunity.com/profiles/" + profileID + "/#commentthread_Profile_" + profileID + "_0_area\">" + profileID + "</a>");
  45.                 jQuery(".friend_block_v2[data-steamid=" + profileID + "]").removeClass("selected").find(".select_friend_checkbox").prop("checked", false);
  46.                 UpdateSelection();
  47.             })
  48.             .fail(() => jQuery("#log_body").get()[0].innerHTML += "<br>Failed to post comment on <a href=\"http://steamcommunity.com/profiles/" + profileID + "\">" + profileID + "</a>")
  49.             .always(() => jQuery("#log_head").html("<br><b>Processed " + (i + 1) + " out of " + total + " friend" + (total.length === 1 ? "" : "s") + ".<b>")), delay * i * 1000);
  50.     });
  51.  
  52. });
Advertisement
Add Comment
Please, Sign In to add comment