Skip to content

Instantly share code, notes, and snippets.

@BH4HPA
Last active February 11, 2021 02:11
Show Gist options
  • Save BH4HPA/8847bda4de6779503ad2d7a785d33680 to your computer and use it in GitHub Desktop.
Save BH4HPA/8847bda4de6779503ad2d7a785d33680 to your computer and use it in GitHub Desktop.
Steam 个人资料批量评论
// 前往 https://steamcommunity.com/my/friends
// 按下 F12 ,复制本代码并粘贴,然后按回车,接着在网页上操作。
ToggleManageFriends();
jQuery("#manage_friends").after('<br><div class="commentthread_entry"><div class="commentthread_entry_quotebox"><textarea rows="1" class="commentthread_textarea" id="comment_textarea" placeholder="键入留言内容.." style="overflow: hidden; height: 20px;"></textarea></div><div class="commentthread_entry_submitlink" style=""><a class="btn_grey_black btn_small_thin" href="javascript:CCommentThread.FormattingHelpPopup( \'Profile\' );"><span>格式帮助</span></a> <span class="emoticon_container"><span class="emoticon_button small" id="emoticonbtn"></span></span><span class="btn_green_white_innerfade btn_small" id="comment_submit"><span>开始留言</span></span></div></div><div id="log"><span id="log_head"></span><span id="log_body"></span></div>');
new CEmoticonPopup($J('#emoticonbtn'), $J('#commentthread_Profile_0_textarea'));
jQuery("#comment_submit").click(function () {
const total = jQuery(".selected").length;
const msg = jQuery("#comment_textarea").val();
if (total > 0 && msg.length > 0) {
jQuery("#log_head, #log_body").html("");
jQuery("#log_head").html("<br><img src=\"https://pro-video.xiaoheiban.cn/wyo/b8d309ac-1aab-4329-a669-12f95e744253.svg\" style=\"height: 20px;position: absolute;\"><b style=\"margin-left: 24px;\">即将开始对 " + total + " 个好友进行批量留言,刷新本页以撤销该操作..<b>");
setTimeout(function () {
jQuery(".selected").each(function (i) {
let profileID = this.getAttribute("data-steamid");
let profileName;
if (jQuery(".selected > .friend_block_content")[i].innerHTML.indexOf("<span class=\"player_nickname_hint\"") !== -1) {
profileName = jQuery(".selected > .friend_block_content")[i].innerHTML.substring(0, jQuery(".selected > .friend_block_content")[i].innerHTML.indexOf("<span"))
} else {
profileName = jQuery(".selected > .friend_block_content")[i].innerHTML.substring(0, jQuery(".selected > .friend_block_content")[i].innerHTML.indexOf("<br>"))
}
(function (i, profileID) {
setTimeout(function () {
jQuery("#log_head").html("<br><img src=\"https://pro-video.xiaoheiban.cn/wyo/b8d309ac-1aab-4329-a669-12f95e744253.svg\" style=\"height: 20px;position: absolute;\"><b style=\"margin-left: 24px;\">正在提交请求...<b>");
jQuery.post("//steamcommunity.com/comment/Profile/post/" + profileID + "/-1/", { comment: msg, count: 6, sessionid: g_sessionID }, function (response) {
if (response.success === false) {
jQuery("#log_body")[0].innerHTML += "<br><img src=\"https://pro-video.xiaoheiban.cn/yhf/1647b11e-cc7b-4ae5-a9e4-c475f28dabfb.svg\" style=\"height: 20px;position: absolute;\"><span style=\"margin-left: 24px;\"><a href=\"http://steamcommunity.com/profiles/" + profileID + "\">" + profileName + " ( " + profileID + " ) " + "</a> 留言失败:" + response.error + ";</span>";
} else {
jQuery("#log_body")[0].innerHTML += "<br><img src=\"https://pro-video.xiaoheiban.cn/pwp/699cde5f-fb30-4be0-a9b2-c7c5e60b09de.svg\" style=\"height: 20px;position: absolute;\"><span style=\"margin-left: 24px;\"><a href=\"http://steamcommunity.com/profiles/" + profileID + "\">" + profileName + " ( " + profileID + " ) " + "</a> 留言成功;</span>";
}
}).fail(function () {
jQuery("#log_body")[0].innerHTML += "<br><img src=\"https://pro-video.xiaoheiban.cn/yhf/1647b11e-cc7b-4ae5-a9e4-c475f28dabfb.svg\" style=\"height: 20px;position: absolute;\"><span style=\"margin-left: 24px;\"><a href=\"http://steamcommunity.com/profiles/" + profileID + "\">" + profileName + " ( " + profileID + " ) " + "</a> 留言失败:请求失败;</span>";
}).always(function () {
if (i + 1 !== total) {
jQuery("#log_head").html("<br><img src=\"https://pro-video.xiaoheiban.cn/wyo/b8d309ac-1aab-4329-a669-12f95e744253.svg\" style=\"height: 20px;position: absolute;\"><b style=\"margin-left: 24px;\">" + (i + 1) + " / " + total + " 已完成,延迟以防被封禁...<b>");
} else {
jQuery("#log_head").html("<br><img src=\"https://pro-video.xiaoheiban.cn/wyo/b8d309ac-1aab-4329-a669-12f95e744253.svg\" style=\"height: 20px;position: absolute;\"><b style=\"margin-left: 24px;\">任务已结束。<b>");
jQuery("#log_body")[0].innerHTML += "<br><img src=\"https://pro-video.xiaoheiban.cn/sxn/8d89f5a8-e233-4c84-a114-b9e63b3e85f9.svg\" style=\"height: 20px;position: absolute;\"><span style=\"margin-left: 24px;\">Powered by <a href=\"https://r-ay.cn/\">Ray</a>.</span>";
}
});
}, i * 6000);
})(i, profileID);
});
}, 6000);
} else {
let errMsg = total === 0 ? "请选择至少一个好友" : "请键入留言内容";
jQuery("#log_head").html("<br><img src=\"https://pro-video.xiaoheiban.cn/yhf/1647b11e-cc7b-4ae5-a9e4-c475f28dabfb.svg\" style=\"height: 20px;position: absolute;\"><b style=\"margin-left: 24px;\">发生错误:" + errMsg + "<b>");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment