-哔哩猫-(试用版)

注:练手作品,多多包涵,不接受恶意差评,有问题群内咨询(Q群1031014013):批量播放视频;批量拉黑;批量关注;动态艾特消息提醒(友情天选群746790091 )

当前为 2021-11-22 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/422731/990910/-%E5%93%94%E5%93%A9%E7%8C%AB-%EF%BC%88%E8%AF%95%E7%94%A8%E7%89%88%EF%BC%89.js

  1. // ==UserScript==
  2. // @name -哔哩猫-(试用版)
  3. // @description 注:练手作品,多多包涵,不接受恶意差评,有问题群内咨询(Q群1031014013):批量播放视频;批量拉黑;批量关注;动态艾特消息提醒(友情天选群746790091 )
  4. // @namespace http://tampermonkey.net/
  5. // @version 2.5.13
  6. // @iconURL https://gitee.com/java_cn/BILIBLI_RES/raw/master/PIC/PC_1606377718.gif
  7. // @author 荒年(QQ:2019676120)
  8. // @match *://space.bilibili.com/*
  9. // @match *://www.bilibili.com/v/newbie/*
  10. // @match *://www.bilibili.com/judgement/*
  11. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
  12. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex.min.js
  13. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex-formVerify.js
  14. // @resource animate http://cdn.javaex.cn/javaex/pc/css/animate.css
  15. // @resource common http://cdn.javaex.cn/javaex/pc/css/common.css
  16. // @resource defaultCss http://cdn.javaex.cn/javaex/pc/css/skin/default.css
  17. // @grant unsafeWindow
  18. // @grant GM_getValue
  19. // @grant GM_setValue
  20. // @grant GM_xmlhttpRequest
  21. // @grant GM_getResourceText
  22. // @grant GM_setClipboard
  23. // @grant GM_openInTab
  24. // @grant GM_addStyle
  25. // @run-at document-idle
  26. // @license MIT License
  27. // @connect github.com
  28. // @connect gitee.com
  29. // @connect api.bilibili.com
  30. // @connect qmsg.zendee.cn
  31. // @connect biliapi.net
  32. // @connect qcloud-sdkact-api.biligame.com
  33. // @connect passport.bilibili.com
  34. // @connect api.live.bilibili.com
  35. // @connect mcloc.cn
  36. // @namespace http://tampermonkey.net/
  37. // ==/UserScript==
  38.  
  39.  
  40.  
  41.  
  42. GM_addStyle(
  43. `
  44. #switch-qsmg:before {
  45. content: "开关";
  46. letter-spacing: 16px;
  47. top: 4px;
  48. left: 10px;
  49. }
  50. #left_navbar{
  51. z-index: 1000;
  52. position: absolute;
  53. top: 100px;
  54. left: 5px;
  55. }
  56. button[hnBtn="btn_open"] {
  57. z-index: 1001;
  58. z-index: 1000px;
  59. position: absolute;
  60. top: 58px;
  61. left: 220px;
  62. }
  63. .javaex-panel.javaex-panel-right.javaex-animated-zoom-in {
  64. top: 60px;
  65. }
  66. .javaex-menu-container {
  67. border: 1px solid #eee;
  68. }
  69. .javaex-panel-box p {
  70. text-align: center;
  71. background: #fb7299;
  72. }
  73. .fontbold{
  74. color: #00a1d6;
  75. font-weight: bold;
  76. cursor: pointer;
  77. }
  78. .hideLogo {
  79. position: absolute;
  80. top: 88px;
  81. left: 10px;
  82. width: 50px;
  83. height: 57px;
  84. z-index: 9999;
  85. cursor: pointer;
  86. }
  87. #auto_check_question {
  88. position: absolute;
  89. border-radius: 20%;
  90. font-size: 24px;
  91. text-align: center;
  92. border: 2px solid red;
  93. top: 91%;
  94. right: 44%;
  95. width: 81px;
  96. color: #fff;
  97. cursor: pointer;
  98. z-index: 999;
  99. }
  100. `
  101. );
  102.  
  103.  
  104. let HN_SETUP_CONFIG = {
  105.  
  106. qmsg_key: null, //后期改为kull 存储到本地
  107. qmsg_checked: false,
  108. Booking_last_sid: null,
  109. }
  110.  
  111. let replyList = ["哇⊙ω⊙", "仙女震惊", "都关注这么久了给个吧", "大佬,看下孩子吧,这次一定", "会有我吗?黑幕一手",
  112. "酋长在线拉低中奖率", "好耶(✪▽✪)", "好运", "希望欧一次", "永不缺席", " 永不中奖", " 永不放弃!", "万一呢", "在", "冲吖~", "来了",
  113. "芜湖,都想要,抽中那个都不亏阿", "从未中,从未停", "来力", "秋", "懂我意思吧", "今天去吃面", "从不缺席",
  114. "站友保佑抽到", "可以", "恰", "不会吧", "233", "好耶", "rush", "来了!!!", "来来", "ok", "冲", "凑热闹", "我要我要", "我还能中!", "让我中!!!",
  115. "是我的", "我是天选之子?", "给我中一次吧!", "坚持不懈,迎难而上", "开拓创新!", "我来抽个奖", "中中中中中", "我我我", "搞笑 这不得转", "我下手了",
  116. "看这里就想中一次", "不可能", "我不挑,都可以", "俺要当分母", "万一呢"
  117. ];
  118.  
  119. let HN_YUN_URL = {
  120. "tx_room": "https://gitee.com/java_cn/BILIBLI_RES/raw/master/TX/tx_room.json",
  121. "notice": "https://gitee.com/shanmite/lottery-notice/raw/master/notice.json",
  122. }
  123.  
  124.  
  125. let Live_info = {
  126. room_id: undefined,
  127. uid: undefined,
  128. blocked: undefined,
  129. csrf_token: undefined,
  130. SESSDATA: undefined,
  131. visit_id: undefined,
  132. rnd: undefined,
  133. ruid: undefined,
  134. uname: undefined,
  135. user_level: undefined,
  136. ruid: undefined,
  137. };
  138.  
  139. let BILIBLI_PATH = {
  140.  
  141. "live": "https://api.live.bilibili.com",
  142. "vcapi": "https://api.vc.bilibili.com",
  143. "passport": "https://passport.bilibili.com",
  144. "api": "https://api.bilibili.com",
  145. "video": "https://www.bilibili.com/video/",
  146. "single_unread": "http://api.vc.bilibili.com/",
  147.  
  148. }
  149.  
  150. let BILIBILI_URL = {
  151. // 导航栏用户信息
  152. "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
  153. }
  154.  
  155. let BiliData = {
  156.  
  157. this_uid: window.location.href.split("/")[3], //当前页面uid
  158. author_uid: 99439379,
  159. login_code: null,
  160. login_message: "",
  161. LoginData: {},
  162. CoinLog: {},
  163. Unread: null,
  164. Video: {},
  165. replyAction: {},
  166. upCard: {},
  167. BVList: [],
  168. }
  169.  
  170. window.onload = function() {
  171.  
  172.  
  173. //界面显示
  174. init();
  175.  
  176.  
  177.  
  178. addHideLogo();
  179.  
  180.  
  181. /* var myVar = setInterval(function() {
  182. console.log("yunxing");
  183. AA ();
  184. }, 1000);
  185. function AA (){
  186. if ((new Date()).getMinutes() == 47) {
  187. console.log("stop");
  188. clearInterval(myVar);
  189. }
  190. } */
  191.  
  192.  
  193. }
  194.  
  195. function addHideLogo() {
  196.  
  197. let isHide = true;
  198.  
  199. $("#left_navbar").after(
  200. '<div id="hideLogo" class="hideLogo"> <img src="https://gitee.com/java_cn/BILIBLI_RES/raw/master/PIC/PC_1606377718.gif" alt="点击显示隐藏" width="100%" height="100%"></div>'
  201. );
  202. if (isHide) {
  203. $("#left_navbar").hide();
  204. isHide = false;
  205. } else {
  206. isHide = true;
  207. }
  208. $("#hideLogo").bind("click", async function() {
  209.  
  210. if (isHide) {
  211. $("#left_navbar").hide();
  212. isHide = false;
  213. } else {
  214. $("#left_navbar").show();
  215. isHide = true;
  216. }
  217. });
  218.  
  219. let newbie = window.location.href.indexOf("newbie") > -1;
  220. if (newbie) {
  221. $("#hideLogo").hide();
  222. //document.querySelector(".tv-type-text").innerHTML += '<span id="auto_check_question">答题</span>';
  223. $("#basic-1").after('<span id="auto_check_question">答题</span>');
  224. $("#basic-2").after('<span id="auto_check_question">答题</span>');
  225.  
  226. $("#optional-qa").after('<span id="auto_check_question">答题</span>');
  227.  
  228. }
  229.  
  230. /**
  231. * 一键答题
  232. */
  233.  
  234. $("#auto_check_question").bind("click", async function() {
  235.  
  236. for (let i = 0; i < 60; i++) {
  237.  
  238. //1.查询状态
  239. let status = await HNAPI.answer_status();
  240. await HNTOOL.Sleep(1000);
  241.  
  242. if (status.progress == 100) {
  243.  
  244. let submitData = {
  245. "re_src": 0,
  246. "csrf": Live_info.csrf_token,
  247. }
  248.  
  249.  
  250. let submitReul = await HNAPI.basePost("https://api.bilibili.com/x/answer/v4/submit",
  251. submitData);
  252. window.location.reload();
  253. }
  254.  
  255. if (status.status != 3 && status.result == "failed") {
  256. // 基础题
  257. if (status.stage == "base") {
  258. //拉取题目
  259. let base = await HNAPI.pull_answer("base");
  260. if (base == 1) {
  261. continue;
  262. }
  263. if (base == false) {
  264. alert("基础题答题错误:答题过快或错误太多||用户答题记录不存在");
  265. break;
  266. }
  267. let question = base.question;
  268. for (let j = 0, len = question.options.length; j < len; j++) {
  269.  
  270. //1.答题
  271. let check = await HNAPI.answer_check(question.id, question.options[j].hash, "base");
  272. if (check == 1) {
  273. continue;
  274. }
  275. await HNTOOL.Sleep(1000);
  276. if (check.passed == true) {
  277. console.log("开始基础题第" + question.number + "题!---当前得分:" + status.score);
  278. javaex.tip({
  279. content: "开始基础题第" + question.number + "题!---当前得分:" + status.score,
  280. type: "success"
  281. });
  282. break;
  283. }
  284. }
  285.  
  286.  
  287. //附加题
  288. } else if (status.stage == "extra") {
  289.  
  290. //拉取题目
  291. let extra = await HNAPI.pull_answer("extra");
  292. if (extra == 1) {
  293. continue;
  294. }
  295. if (extra == false) {
  296. alert("违规发言题答题错误:答题过快或错误太多||用户答题记录不存在");
  297. break;
  298. }
  299. let question = extra.question;
  300. let check = await HNAPI.answer_check(question.id, question.options[0].hash, "extra");
  301. await HNTOOL.Sleep(1000);
  302. if (check == 1) {
  303. continue;
  304. }
  305. if (check.passed == true) {
  306. console.log("开始违规发言题第" + question.number + "题!---当前得分:" + status.score);
  307. javaex.tip({
  308. content: "开始违规发言题第" + question.number + "题!---当前得分:" + status.score,
  309. type: "success"
  310. });
  311. if (question.number == 50) {
  312. window.location.reload();
  313. }
  314. }
  315.  
  316. } else if (status.stage == "pro") {
  317.  
  318. //拉取题目
  319. let pro = await HNAPI.pull_answer("pro");
  320. if (pro == 1) {
  321. continue;
  322. }
  323. if (pro == false) {
  324. alert("自选题答题错误:答题过快或错误太多||用户答题记录不存在");
  325. break;
  326. }
  327. let question = pro.question;
  328. let num = HNTOOL.random(0, question.options.length);
  329. let check = await HNAPI.answer_check(question.id, question.options[num].hash, "pro");
  330. await HNTOOL.Sleep(1000);
  331. if (check == 1) {
  332. continue;
  333. }
  334. if (check.passed == true) {
  335. console.log("开始自选题第" + question.number + "题!---当前得分:" + status.score);
  336. javaex.tip({
  337. content: "开始自选题第" + question.number + "题!---当前得分:" + status.score,
  338. type: "success"
  339. });
  340.  
  341. }
  342.  
  343. } else {
  344. break;
  345. }
  346.  
  347. }
  348.  
  349. }
  350.  
  351. });
  352.  
  353.  
  354. }
  355.  
  356.  
  357. function init() {
  358.  
  359. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  360. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  361. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  362.  
  363. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&54988";
  364.  
  365.  
  366. addStyle();
  367. addSetPage();
  368.  
  369. HNTOOL.chackAtMsg();
  370.  
  371. $("#getCoinLog").bind("click", async function() {
  372.  
  373.  
  374. if (HNAPI.getCoinLog()) {
  375.  
  376. await HNTOOL.Sleep(500);
  377. let html = '';
  378. html += '<div class="javaex-panel-box" style="width: 250px;">';
  379. html += ' <ul>';
  380. html += ` <p style="color: #FFF;">硬币使用记录</p>`;
  381.  
  382. BiliData.CoinLog.list.forEach(function(item) {
  383.  
  384. let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
  385. if (BV.indexOf("BV") != -1) {
  386. html +=
  387. `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
  388. }
  389. html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
  390.  
  391.  
  392. });
  393. html += ' <hr class="javaex-divider"></hr>';
  394. html += ' </ul>';
  395. html += '</div>';
  396.  
  397. javaex.panel(this, {
  398. position: "right",
  399. //offsetTop: "104",
  400. content: html
  401. });
  402. javaex.tip({
  403. content: "获取用户成功!",
  404. type: "success"
  405. });
  406.  
  407. } else {
  408. javaex.tip({
  409. content: "获取硬币记录失败,请稍后重试!",
  410. type: "error"
  411. });
  412. }
  413.  
  414.  
  415. });
  416.  
  417. $("#getUnread").bind("click", async function() {
  418.  
  419. javaex.tip({
  420. content: "获取中,请稍候...",
  421. type: "submit"
  422. });
  423. HNAPI.getUnread();
  424.  
  425.  
  426. });
  427.  
  428.  
  429. $("#likeInDynamicComments").bind("click", async function() {
  430.  
  431. let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get(
  432. "likeInDynamic_PRID");
  433. let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get(
  434. "likeInDynamic_OID");
  435.  
  436. let html = '';
  437.  
  438. html += '<div style="padding: 10px 10px 10px 0px;">'
  439. html += '<form id="likeInDynamic_form">'
  440. html += ' <div class="javaex-unit clear">'
  441. html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
  442. html += ' <div class="javaex-unit-right">'
  443. html +=
  444. ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
  445. html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
  446. html += ' </div>'
  447. html += ' </div>'
  448. html += ' <div class="javaex-unit clear">'
  449. html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
  450. html += ' <div class="javaex-unit-right">'
  451. html +=
  452. ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
  453. html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
  454. html += ' </div>'
  455. html += ' </div>'
  456. html += ' <div class="javaex-unit clear tc">'
  457. html +=
  458. ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
  459. html +=
  460. ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
  461. html += ' </div>'
  462. html += '</form>';
  463. html += '<hr class="javaex-divider"></hr>';
  464. html += '</div>';
  465.  
  466.  
  467. javaex.panel(this, {
  468. position: "right",
  469. content: html
  470. });
  471.  
  472.  
  473. // 监听点击保存按钮事件
  474. $("#likeInDynamic_yes").click(async function() {
  475. // 表单验证函数
  476. if (javaexVerify()) {
  477.  
  478. HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex
  479. .getSelectVal(
  480. "#likeInDynamic_PRID"), 1);
  481. await HNTOOL.Sleep(1000);
  482.  
  483. if (BiliData.replyAction.code == 0) {
  484.  
  485. LocalData.set("likeInDynamic_PRID", javaex.getSelectVal(
  486. "#likeInDynamic_PRID"));
  487. LocalData.set("likeInDynamic_OID", javaex.getSelectVal(
  488. "#likeInDynamic_OID"));
  489.  
  490. javaex.tip({
  491. content: "评论区点赞成功!",
  492. type: "success"
  493. });
  494. } else {
  495. javaex.tip({
  496. content: "评论区点赞失败!",
  497. type: "error"
  498. });
  499. }
  500. if (BiliData.replyAction.code == 65006) {
  501. javaex.tip({
  502. content: "请勿重复点赞!",
  503. type: "error"
  504. });
  505. }
  506. }
  507. });
  508.  
  509. // 监听点击返回按钮事件
  510. $("#likeInDynamic_no").click(async function() {
  511.  
  512. if (javaexVerify()) {
  513.  
  514. HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +
  515. javaex.getLocalStorage(
  516. "#likeInDynamic_PRID"), 0);
  517. await HNTOOL.Sleep(500);
  518.  
  519. if (BiliData.replyAction.code == 0) {
  520.  
  521. javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal(
  522. "#likeInDynamic_PRID"));
  523. javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal(
  524. "#likeInDynamic_OID"));
  525.  
  526. javaex.tip({
  527. content: "评论区取消点赞成功!",
  528. type: "success"
  529. });
  530. } else {
  531. javaex.tip({
  532. content: "评论区取消点赞失败!",
  533. type: "error"
  534. });
  535. }
  536. if (BiliData.replyAction.code == 65006) {
  537. javaex.tip({
  538. content: "请勿重复取消点赞!",
  539. type: "error"
  540. });
  541. }
  542. }
  543. });
  544.  
  545. });
  546.  
  547. $("#biliUserMsg").bind("click", async function() {
  548.  
  549.  
  550. //刷新信息
  551. HNAPI.getUserNav();
  552. await HNTOOL.Sleep(500);
  553.  
  554. let isLogin = "未登录";
  555. let vipType = "无";
  556. //判断是否成功
  557. if (BiliData.login_code == 0) {
  558.  
  559.  
  560. if (BiliData.LoginData.isLogin) {
  561. isLogin = "已登录";
  562. }
  563.  
  564. if (BiliData.LoginData.vipType == 1) {
  565. vipType = "月度大会员";
  566. } else if (BiliData.LoginData.vipType == 2) {
  567. vipType = "年度大会员";
  568. }
  569.  
  570. let html = '';
  571. html += '<div class="javaex-panel-box" style="width: 250px;">';
  572. html += ' <ul>';
  573. html += ` <p style="color: #FFF;">用户信息</p>`;
  574. html +=
  575. ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
  576. html += ` <li>用户状态:${isLogin} </li> `;
  577. html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
  578. html +=
  579. ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
  580. html += ` <li>UID${BiliData.LoginData.mid} </li> `;
  581. html +=
  582. ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
  583. html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
  584. html += ` <li>会员:${vipType} </li> `;
  585. html += ' <hr class="javaex-divider"></hr>';
  586. html += ' </ul>';
  587. html += '</div>';
  588.  
  589.  
  590. javaex.panel(this, {
  591. position: "right",
  592. content: html
  593. });
  594.  
  595. javaex.tip({
  596. content: "获取用户成功!",
  597. type: "success"
  598. });
  599.  
  600. } else {
  601. javaex.tip({
  602. content: "获取用户信息失败!",
  603. type: "error"
  604. });
  605. }
  606.  
  607.  
  608. });
  609.  
  610. $("#getAtMsg").bind("click", async function() {
  611.  
  612. if (HNAPI.getMsgfeed("at") && typeof(HNAPI.getMsgfeed("at")) != "undefined") {
  613.  
  614. javaex.tip({
  615. content: "可能中奖了!!!",
  616. type: "success"
  617. });
  618. }
  619. });
  620.  
  621.  
  622. $("#disUser").bind("click", async function() {
  623.  
  624. let html = '';
  625. html += '<div class="javaex-panel-box" style="width: 500px;">';
  626. html += ' <div class="javaex-unit clear">';
  627. html += ' <div class="javaex-unit-left ml-10 mt-10">*UID列表</div>';
  628. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  629. html +=
  630. ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
  631. html += ' </div>';
  632. html += ' </div>';
  633. html += ' <div class="javaex-unit clear tc">';
  634. html += ' <input type="button" id="disUser_block" class="javaex-btn yes" value="拉黑" />';
  635. html +=
  636. ' <input type="button" id="disUser_cancelAtt_uid" class="javaex-btn yes" value="UID取关" />';
  637. html +=
  638. ' <input type="button" id="disUser_cancelAtt_room" class="javaex-btn yes" value="房间号取关" />';
  639. html += ' </div>';
  640. html += '</div>';
  641.  
  642. javaex.panel(this, {
  643. position: "right",
  644. content: html
  645. });
  646.  
  647. let disUser_str;
  648. //拉黑
  649. $("#disUser_block").bind("click", async function() {
  650.  
  651. disUser_str = javaex.getSelectVal("#disUser_uidList");
  652. let disUser_uidList = disUser_str.split(",");
  653. let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
  654.  
  655. for (const vmid of disUserStr) {
  656.  
  657. HNAPI.batchModify(vmid.toString(), 5);
  658. await HNTOOL.Sleep(2000);
  659. }
  660. });
  661. //取关uid
  662. $("#disUser_cancelAtt_uid").bind("click", async function() {
  663. disUser_str = javaex.getSelectVal("#disUser_uidList");
  664. let disUser_uidList = disUser_str.split(",");
  665.  
  666. javaex.tip({
  667. content: "根据uid批量取关开始!!!",
  668. type: "success"
  669. });
  670.  
  671. /*
  672. let disuidList = [];
  673. let PN = 100;
  674. PN = disUser_uidList.length == 1 ? 0 : PN;
  675. for (var i = 0; i < PN; i++) {
  676. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  677. javaex.tip({
  678. content: "获取第" + i + "页黑名单成功!",
  679. type: "success"
  680. });
  681. await HNTOOL.Sleep(1000);
  682. if (uidList.length == 0) {
  683. break;
  684. }
  685. if (uidList == null) {
  686. continue;
  687. }
  688. for (let disuid of uidList) {
  689. if (disuidList.indexOf(disuid.mid) == -1) {
  690. disuidList.push(disuid.mid + "");
  691. }
  692. }
  693. } */
  694. let J = 1;
  695.  
  696. for (let uid of disUser_uidList) {
  697.  
  698. /* let uidType = "未在黑名单";
  699. if (disuidList.indexOf(uid) == -1) {
  700. await HNAPI.cancelAtt(uid, 2);
  701. } else {
  702. await HNAPI.cancelAtt(uid, 6, 116);
  703. uidType = "黑名单用户";
  704. } */
  705. await HNAPI.cancelAtt(uid, 2);
  706.  
  707. javaex.tip({
  708. content: "【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" +
  709. disUser_uidList.length + ")",
  710. type: "success"
  711. });
  712. await HNTOOL.Sleep(1000);
  713. }
  714.  
  715.  
  716. alert("根据uid批量取关完成!");
  717.  
  718. /* javaex.alert({
  719. content: "根据uid批量取关完成!",
  720. confirm: function() {
  721. //return false;
  722. }
  723. }); */
  724.  
  725. });
  726. //取关room
  727. $("#disUser_cancelAtt_room").bind("click", async function() {
  728.  
  729. javaex.tip({
  730. content: "根据房间号批量取关开始!!!",
  731. type: "success"
  732. });
  733.  
  734. disUser_str = javaex.getSelectVal("#disUser_uidList");
  735. let disUser_roomList = disUser_str.split(",");
  736. /* let disuidList = [];
  737. let PN = 100;
  738. PN = disUser_roomList.length == 1 ? 0 : PN;
  739. for (var i = 0; i < PN; i++) {
  740. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  741. javaex.tip({
  742. content: "获取第" + i + "页黑名单成功!",
  743. type: "success"
  744. });
  745. await HNTOOL.Sleep(1000);
  746. if (uidList.length == 0) {
  747. break;
  748. }
  749. if (uidList == null) {
  750. continue;
  751. }
  752. for (let disuid of uidList) {
  753. if (disuidList.indexOf(disuid.mid) == -1) {
  754. disuidList.push(disuid.mid);
  755. }
  756. }
  757. } */
  758. let J = 1;
  759. for (let room of disUser_roomList) {
  760.  
  761. let uid = await HNAPI.getRoomMsg(room);
  762.  
  763. await HNTOOL.Sleep(1000);
  764.  
  765. if (uid == false) {
  766. javaex.tip({
  767. content: "uid查询失败跳过!",
  768. type: "error"
  769. });
  770. continue;
  771. }
  772. /* let uidType = "未在黑名单";
  773. if (disuidList.indexOf(uid) == -1) {
  774. await HNAPI.cancelAtt(uid, 2);
  775. } else {
  776. await HNAPI.cancelAtt(uid, 6, 116);
  777. uidType = "黑名单用户";
  778. } */
  779. await HNAPI.cancelAtt(uid, 2);
  780.  
  781. javaex.tip({
  782. content: "Room:" + room + "-【UID:" + uid + "】" + "取关成功!(" + (J++) +
  783. "/" + disUser_roomList.length +
  784. ")",
  785. type: "success"
  786. });
  787. await HNTOOL.Sleep(1000);
  788.  
  789.  
  790. }
  791. alert("根据房间号批量取关完成!");
  792. /* javaex.alert({
  793. content: ,
  794. confirm: function() {
  795. return false;
  796. }
  797. }); */
  798.  
  799. });
  800.  
  801. });
  802.  
  803. $("#getNeetCookie").bind("click", async function() {
  804.  
  805. let html = '';
  806. html += '<div class="javaex-panel-box" style="width: 750px;">';
  807. html += ' <div class="javaex-unit clear">';
  808. html += ' <div class="javaex-unit-left ml-10 mt-10">*cookie</div>';
  809. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  810. html +=
  811. ' <textarea id="neetCookie" class="javaex-desc" placeholder="获取需要的cookie,注意需要取消掉application->cookie>SESSDATA httpOnly 的对钩"></textarea>';
  812. html += ' </div>';
  813. html += ' </div>';
  814. html += ' <div class="javaex-unit clear tc">';
  815. html += ' <input type="button" id="getCookie_type1" class="javaex-btn yes" value="方式一" />';
  816. html += ' <input type="button" id="getCookie_type2" class="javaex-btn yes" value="方式二" />';
  817. html += ' <input type="button" id="getCookie_type3" class="javaex-btn yes" value="方式三" />';
  818. html += ' <input type="button" id="getCookie_copy" class="javaex-btn yes" value="复制" />';
  819. html += ' </div>';
  820. html += '</div>';
  821.  
  822. javaex.panel(this, {
  823. position: "right",
  824. content: html
  825. });
  826.  
  827. $('#getCookie_copy').bind('click', function() {
  828.  
  829. HNTOOL.copyText("neetCookie");
  830.  
  831. });
  832.  
  833. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  834. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  835. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  836.  
  837.  
  838. $("#getCookie_type1").bind("click", async function() {
  839.  
  840. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA
  841. .replace(/%25/g, "%") +
  842. "; bili_jct=" + Live_info.csrf_token +
  843. "; "
  844. document.getElementById("neetCookie").value = cookie01;
  845.  
  846. });
  847. $("#getCookie_type3").bind("click", async function() {
  848.  
  849. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA
  850. .replace(/%25/g, "%%") +
  851. "; bili_jct=" + Live_info.csrf_token +
  852. "; "
  853. document.getElementById("neetCookie").value = cookie01;
  854.  
  855. });
  856.  
  857. $("#getCookie_type2").bind("click", async function() {
  858.  
  859. var cookie02 = Live_info.uid + "\n" + Live_info.SESSDATA.replace(/%25/g, "%") +
  860. "\n" + Live_info.csrf_token;
  861. document.getElementById("neetCookie").value = cookie02;
  862. });
  863.  
  864. });
  865.  
  866. $("#arrUnique").bind("click", async function() {
  867.  
  868. let html = '';
  869. html += '<div class="javaex-panel-box" style="width: 500px;">';
  870. html += ' <div class="javaex-unit clear">';
  871. html += ' <div id="arrNub" class="javaex-unit-left ml-10 mt-10">*数组0</div>';
  872. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  873. html +=
  874. ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  875. html += ' </div>';
  876. html += ' </div>';
  877. html += ' <div class="javaex-unit clear tc">';
  878. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="去重" />';
  879. //html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="粘贴" />';
  880. html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="复制" />';
  881. html += ' </div>';
  882. html += '</div>';
  883.  
  884. javaex.panel(this, {
  885. position: "right",
  886. content: html
  887. });
  888.  
  889. $('#arrUnique_str').bind('input propertychange', function() {
  890.  
  891. $('#arrNub').text("*数组" + $(this).val().split(",").length);
  892.  
  893. });
  894. $('#arrUnique_copy').bind('click', function() {
  895.  
  896. HNTOOL.copyText("arrUnique_str");
  897.  
  898. });
  899.  
  900.  
  901.  
  902.  
  903. $("#arrUnique_beg").bind("click", async function() {
  904.  
  905. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  906. let arrUnique_uidList = arrUnique_str.split(",");
  907.  
  908. let new_arr = HNTOOL.arrUnique(arrUnique_uidList);
  909.  
  910. document.getElementById("arrUnique_str").value = new_arr.toString();
  911.  
  912. $('#arrNub').text("*数组" + new_arr.length);
  913.  
  914. });
  915.  
  916. });
  917.  
  918. $("#yunBatchFollow").bind("click", async function() {
  919.  
  920.  
  921. let tx_room = await HNAPI.getMyJson(HN_YUN_URL.tx_room);
  922. let notice = await HNAPI.getMyJson(HN_YUN_URL.notice);
  923. let blacklist = notice.config.blacklist.split(",");
  924. let num1 = 0;
  925. let num2 = 0;
  926. //获取关注
  927. let followList = await HNAPI.getAllFollow();
  928. await HNTOOL.Sleep(1000);
  929.  
  930. for (let room of tx_room) {
  931. let uid = await HNAPI.getRoomMsg(room);
  932. if (followList.indexOf(uid) > -1) {
  933. await HNAPI.cancelAtt(uid, 2);
  934. HNTOOL.console("取关 \n 天选相关:" + uid + "\n room:" + room,"FF0000");
  935. num1++;
  936. } else {
  937. HNTOOL.console("未关注:" + uid + "---room:" + room);
  938. }
  939. await HNTOOL.Sleep(1000);
  940. }
  941.  
  942. for (let uid2 of blacklist) {
  943. if (followList.indexOf(uid2) > -1 && uid2 != BiliData.author_uid) {
  944. await HNAPI.cancelAtt(uid2, 2);
  945. HNTOOL.console("取关 \n 动态相关:" + uid2,"FF0000");
  946. num2++;
  947. } else {
  948. HNTOOL.console("未关注:" + uid2);
  949. }
  950. await HNTOOL.Sleep(1000);
  951. }
  952.  
  953. alert("取关完成: \n 【天选相关-" + num1 + "】\n【动态相关-" + num2 + "】");
  954.  
  955.  
  956. });
  957.  
  958. $("#batchFollow").bind("click", async function() {
  959.  
  960. var thisUPName = $("#h-name").text();
  961.  
  962.  
  963. let html = '';
  964. html += '<div class="javaex-panel-box" style="width: 600px;">';
  965. html += ' <div class="javaex-unit clear">';
  966. html += ' <div id="followNub" class="javaex-unit-left ml-10 mt-10">*关注列表0</div>';
  967. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  968. html +=
  969. ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
  970. html += ' </div>';
  971. html += ' </div>';
  972. html += ' <div class="javaex-unit clear tc" >';
  973. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  974. //html += ' <input type="button" id="check_follow" class="javaex-btn yes tc" value="筛选关注" />';
  975. html +=
  976. ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="获取全部关注" />';
  977. html += ' </div>';
  978. html += '</div>';
  979.  
  980. javaex.panel(this, {
  981. position: "right",
  982. content: html
  983. });
  984.  
  985. $('#batchFollow_uidList').bind('input propertychange', function() {
  986.  
  987. $('#followNub').text("*关注列表" + $(this).val().split(",").length);
  988.  
  989. });
  990.  
  991. $("#disFollow_thisUp").bind("click", async function() {
  992.  
  993. HNAPI.batchModify(BiliData.this_uid, 5);
  994.  
  995. });
  996.  
  997. $("#Follow_thisUp").bind("click", async function() {
  998.  
  999. HNAPI.batchModify(BiliData.this_uid);
  1000.  
  1001. });
  1002.  
  1003. $("#batchFollow_beg").bind("click", async function() {
  1004.  
  1005. let mid_str = javaex.getSelectVal("#batchFollow_uidList");
  1006. let mid_list = mid_str.split(",");
  1007.  
  1008. let all_ollow = await HNAPI.getAllFollow();
  1009. await HNTOOL.Sleep(1000);
  1010. //删除已关注的数据
  1011. for (let i in mid_list) {
  1012.  
  1013. if (all_ollow.indexOf(parseInt(mid_list[i])) != -1) {
  1014. mid_list.splice(i, 1);
  1015. }
  1016.  
  1017. }
  1018.  
  1019. document.getElementById("batchFollow_uidList").value = mid_list.toString();
  1020. $('#followNub').text("*关注列表" + mid_list.length);
  1021.  
  1022. let mid_Lists = HNTOOL.split_array(mid_list, 15);
  1023. for (const mids of mid_Lists) {
  1024.  
  1025. HNAPI.batchModify(mids.toString());
  1026. await HNTOOL.Sleep(8000);
  1027. }
  1028.  
  1029. alert("关注完成!")
  1030.  
  1031. });
  1032.  
  1033. $("#crawler_follow").bind("click", async function() {
  1034.  
  1035. let followList = await HNAPI.getAllFollow();
  1036. document.getElementById("batchFollow_uidList").value = followList.toString();
  1037.  
  1038. });
  1039.  
  1040. $("#check_follow").bind("click", async function() {
  1041.  
  1042. let followList = await HNAPI.getAllFollow();
  1043. await HNTOOL.Sleep(1000);
  1044. let fList = [];
  1045. let fansmin = prompt("请输入最小粉丝数量", "5000");
  1046. let fansmax = prompt("请输入最大粉丝数量", "-1");
  1047. let fansrole = window.confirm('是否认证?');
  1048. //let fansmassage = window.confirm('是否有过私信?');
  1049. let fansfollow = window.confirm('是否执行取消关注?');
  1050.  
  1051. for (const mid of followList) {
  1052.  
  1053. if (fansmin == null || fansmax == null) {
  1054. break;
  1055. }
  1056.  
  1057.  
  1058. let midCard = await HNAPI.getInterfaceCard(mid);
  1059. await HNTOOL.Sleep(1000);
  1060. fansmax = fansmax == -1 ? Infinity : fansmax;
  1061. if (midCard.fans > fansmax || midCard.fans < fansmin) {
  1062. continue;
  1063. }
  1064.  
  1065. if ((midCard.official_verify.type != -1) == fansrole) {
  1066. fList.push(mid);
  1067. } else {
  1068. fList.push(mid);
  1069. }
  1070.  
  1071.  
  1072.  
  1073. if (fansfollow) {
  1074.  
  1075. await HNAPI.cancelAtt(mid, 2);
  1076. console.log(mid + "---" + midCard.name + "取消关注!!!")
  1077. await HNTOOL.Sleep(1000);
  1078. }
  1079. document.getElementById("batchFollow_uidList").value = fList.toString();
  1080.  
  1081. }
  1082.  
  1083.  
  1084.  
  1085. });
  1086.  
  1087.  
  1088. });
  1089.  
  1090. $("#batchTargetMedal").bind("click", async function() {
  1091.  
  1092.  
  1093. let html = '';
  1094. html += '<div class="javaex-panel-box" style="width: 600px;">';
  1095. html += ' <div class="javaex-unit clear">';
  1096. html += ' <div id="targetNub" class="javaex-unit-left ml-10 mt-10">*房间列表0</div>';
  1097. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  1098. html +=
  1099. ' <textarea id="batchTargetMedal_roomlist" class="javaex-desc" placeholder="特别注意:请填写用户真实房间号,多个用英文逗号,隔开!!"></textarea>';
  1100. html += ' </div>';
  1101. html += ' </div>';
  1102. html += ' <div class="javaex-unit clear tc" >';
  1103. html +=
  1104. ' <input type="button" id="batchTargetMedal_beg" class="javaex-btn yes" value="开始" />';
  1105. html += ' </div>';
  1106. html += '</div>';
  1107.  
  1108. javaex.panel(this, {
  1109. position: "right",
  1110. content: html
  1111. });
  1112.  
  1113. $('#batchTargetMedal_roomlist').bind('input propertychange', function() {
  1114.  
  1115. $('#targetNub').text("*房间列表" + $(this).val().split(",").length);
  1116.  
  1117. });
  1118.  
  1119. $("#batchTargetMedal_beg").bind("click", async function() {
  1120.  
  1121. let room_str = javaex.getSelectVal("#batchTargetMedal_roomlist");
  1122. let room_list = room_str.split(",");
  1123.  
  1124.  
  1125. for (const room of room_list) {
  1126.  
  1127. let uid = await HNAPI.getRoomMsg(room);
  1128. await HNTOOL.Sleep(500);
  1129.  
  1130. if (uid == false) {
  1131.  
  1132. javaex.tip({
  1133. content: room + "获取勋章失败!",
  1134. type: "error"
  1135. });
  1136.  
  1137. continue;
  1138. }
  1139.  
  1140. let result = await HNAPI.getFansMedalInfo(uid, room);
  1141.  
  1142. if (result) {
  1143. javaex.tip({
  1144. content: room + "勋章已经存在!",
  1145. type: "success"
  1146. });
  1147. continue;
  1148. }
  1149. //获取包裹列表
  1150. let giftRes = await HNAPI.getGiftList(room);
  1151.  
  1152. if (giftRes == false) {
  1153.  
  1154. continue;
  1155. }
  1156.  
  1157. let bag_id = null;
  1158.  
  1159. for (let gr of giftRes) {
  1160.  
  1161. if (gr.gift_id == 3) {
  1162.  
  1163. bag_id = gr.bag_id;
  1164. break;
  1165. }
  1166.  
  1167. }
  1168. if (bag_id != null) {
  1169.  
  1170. await HNAPI.bagSendGift(uid, room, bag_id);
  1171. }
  1172.  
  1173.  
  1174.  
  1175. await HNTOOL.Sleep(5000);
  1176. }
  1177.  
  1178. alert("批量送b克拉完毕!")
  1179.  
  1180.  
  1181. });
  1182.  
  1183.  
  1184. });
  1185.  
  1186.  
  1187. $("#HNSetup").bind("click", async function() {
  1188.  
  1189. var CONFIG = HNTOOL.getConfig();
  1190.  
  1191.  
  1192. let html = '';
  1193.  
  1194. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  1195. html += '<form id="HNGG_SETUP">'
  1196. html += ' <div class="javaex-unit clear">'
  1197. html +=
  1198. ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Qmsg-key</p></div>'
  1199. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  1200. html +=
  1201. ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  1202. html +=
  1203. ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  1204. html += ' </div>'
  1205. html += ' <div class="javaex-unit-left mr-10">'
  1206. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  1207. html += ' </div>'
  1208. html += ' </div>'
  1209. html += '</form>';
  1210. html += '<div class="javaex-unit clear tc">';
  1211. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  1212. html += '</div>';
  1213. html += '<hr class="javaex-divider"></hr>';
  1214. html += '</div>';
  1215.  
  1216. javaex.panel(this, {
  1217. position: "right",
  1218. content: html
  1219. });
  1220.  
  1221.  
  1222. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  1223.  
  1224. $("#switch-qsmg").bind("click", function() {
  1225.  
  1226. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  1227.  
  1228. })
  1229.  
  1230.  
  1231. $("#HNSetup_save").bind("click", async function() {
  1232.  
  1233.  
  1234. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  1235.  
  1236. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  1237.  
  1238. javaex.tip({
  1239. content: "设置成功!",
  1240. type: "success"
  1241. });
  1242.  
  1243. });
  1244.  
  1245. });
  1246.  
  1247. //
  1248. $("#getUpMassage").bind("click", async function() {
  1249.  
  1250.  
  1251. let html = '';
  1252.  
  1253. html += '<div style="padding: 10px 10px 10px 0px;">'
  1254. html += '<form id="getUpMassage_form">'
  1255. html += ' <div class="javaex-unit clear">'
  1256. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  1257. html += ' <div class="javaex-unit-left mr-10">'
  1258. html +=
  1259. ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  1260. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  1261. html += ' </div>'
  1262. html += ' <div class="javaex-unit-right mr-10">'
  1263. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  1264. html += ' </div>'
  1265. html += ' </div>'
  1266. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  1267. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  1268. html += ' <thead>'
  1269. html += ' <tr><th>内容</th><th>详情</th></tr>'
  1270. html += ' </thead>'
  1271. html += ' <tbody id="upMsgTbody">'
  1272.  
  1273. html += ' </tbody>'
  1274. html += '</table> '
  1275. html += '</div>'
  1276. html += '</form>';
  1277. html += '<hr class="javaex-divider"></hr>';
  1278. html += '</div>';
  1279.  
  1280.  
  1281. javaex.panel(this, {
  1282. position: "right",
  1283. content: html
  1284. });
  1285.  
  1286. javaex.table({
  1287. id: "upMsgTable",
  1288. isDragColWidth: true, // 是否允许拖动改变列宽
  1289. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  1290. leftFixedColNum: 2, // 左侧固定列数
  1291. rightFixedColNum: 1, // 右侧固定列数
  1292. sort: {
  1293. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  1294. "2": "update_time"
  1295. },
  1296. sortCallback: function(rtn) {
  1297. //console.log(rtn.sortArr);
  1298. }
  1299. });
  1300.  
  1301. //
  1302. $("#getUpMsg").click(async function() {
  1303.  
  1304. let thismid = javaex.getSelectVal("#up_uid");
  1305. await HNAPI.userInfo(thismid)
  1306.  
  1307. let temp = await HNAPI.getUpCard(thismid);
  1308.  
  1309.  
  1310. await HNTOOL.Sleep(500);
  1311.  
  1312.  
  1313. if (temp != false) {
  1314. let data = BiliData.upCard.data;
  1315.  
  1316. let html = ``;
  1317. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  1318. html +=
  1319. `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  1320. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  1321. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  1322. html +=
  1323. `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  1324. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  1325. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  1326. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  1327. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  1328. html +=
  1329. `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  1330. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  1331. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  1332.  
  1333.  
  1334. $("#upMsgTbody").empty();
  1335. $("#upMsgTbody").append(html);
  1336. }
  1337.  
  1338.  
  1339. });
  1340. //点击放大
  1341. /* $("img").click(function() {
  1342. javaex.dialog({
  1343. type : "image", // 弹出层类型
  1344. url : $(this).attr("src") // 图片地址
  1345. });
  1346. });*/
  1347.  
  1348. });
  1349.  
  1350.  
  1351. $("#everyDayTask").bind("click", async function() {
  1352.  
  1353. let videoAid = 758643487;
  1354. let videoCid = 357521682;
  1355. let videoBvid = "BV1V64y1d7ed";
  1356. let videoMid = 99439379;
  1357.  
  1358. //查询每日奖励状态
  1359. let rewardData = await HNAPI.get_exp_reward();
  1360. await HNTOOL.Sleep(2000);
  1361.  
  1362. //1.每日登录
  1363. if (rewardData.login == false) {
  1364.  
  1365. await HNAPI.clickNow();
  1366. await HNTOOL.Sleep(3000);
  1367. }
  1368.  
  1369. //2.直播签到
  1370. await HNAPI.DoSign();
  1371. await HNTOOL.Sleep(3000);
  1372.  
  1373. //3.专栏投币
  1374. let accountData = await HNAPI.get_account_exp();
  1375. await HNTOOL.Sleep(2000);
  1376. if (rewardData.coins < 40) {
  1377. //2. 获取分区最新专栏列表
  1378. let articleData = await HNAPI.getArticleRecommends();
  1379. await HNTOOL.Sleep(2000);
  1380. let article = articleData[HNTOOL.random(0, 9)];
  1381. let article2 = articleData[HNTOOL.random(9, 18)];
  1382.  
  1383. //await HNAPI.addVideoCoin(videoAid);//视频投币
  1384. await HNAPI.addArticleCoin(article.id, article.author.mid); //专栏投币
  1385. await HNTOOL.Sleep(2000);
  1386. if (accountData / 20 == 1) {
  1387. await HNAPI.addArticleCoin(article2.id, article2.author.mid); //专栏投币
  1388. }
  1389. }
  1390.  
  1391. //获取分区最新视频列表 http://api.bilibili.com/x/web-interface/dynamic/region pn=1 ps=20 rid=21
  1392. let archivesList = await HNAPI.getDynamicRegion();
  1393. await HNTOOL.Sleep(2000);
  1394. let num = HNTOOL.random(0, archivesList.length - 1);
  1395.  
  1396. if (archivesList != false && num != 2) {
  1397. videoAid = archivesList[num].aid;
  1398. videoBvid = archivesList[num].bvid;
  1399. videoCid = archivesList[num].cid;
  1400. videoMid = archivesList[num].owner.mid;
  1401. }
  1402. //4.每日观看视频
  1403. if (rewardData.watch == false) {
  1404. await HNAPI.watchOneVideo(videoBvid, videoMid);
  1405. await HNTOOL.Sleep(2000);
  1406. }
  1407. //5.每日分享视频
  1408. if (rewardData.share == false) {
  1409.  
  1410. await HNAPI.addShare(videoAid);
  1411. await HNTOOL.Sleep(2000);
  1412. }
  1413.  
  1414. //6.日常随机转发一个视频
  1415.  
  1416. await HNAPI.shareOneVideo(videoAid, videoMid, "分享视频");
  1417. if (num == 3 || num == 16) {
  1418. let randomStr = await HNTOOL.getRandomString();
  1419. await HNAPI.shareOneVideo("975082514", "397516636", randomStr);
  1420. }
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426. });
  1427.  
  1428.  
  1429. $("#batch_dynamic_like").bind("click", async function() {
  1430.  
  1431. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/bilicat_config.json";
  1432. let jsons = await HNAPI.getMyJson(url);
  1433. let myjson = jsons.batch_dynamic_like;
  1434.  
  1435. for (let value of myjson) {
  1436.  
  1437. await HNAPI.likeDynamic(value.dynamic_id);
  1438. console.log("点赞成功:https://t.bilibili.com/" + value.dynamic_id + "?tab=2")
  1439. await HNTOOL.Sleep(2000);
  1440. }
  1441.  
  1442. });
  1443.  
  1444.  
  1445. $("#dynamicActivity").bind("click", async function() {
  1446.  
  1447. javaex.tip({
  1448. content: "动态转发开始!",
  1449. type: "success"
  1450. });
  1451.  
  1452. let dynamic_id_list = await HNTOOL.getLatestDynamic();
  1453. console.log("共" + dynamic_id_list.length + "条动态")
  1454. let allFollow = await HNAPI.getAllFollow();
  1455. //let save_dynamic_id = await HNAPI.getSpaceNotice();
  1456. await HNTOOL.Sleep(2000);
  1457. console.log("随机延迟30-40分钟发布一个随机动态");
  1458. await HNTOOL.doOneDynamic(HNTOOL.random(30, 40) * 60 * 1000);
  1459.  
  1460. for (let index = 0, len = dynamic_id_list.length; index < len; index++) {
  1461.  
  1462. let value = dynamic_id_list[index];
  1463.  
  1464. let dynamic_data = await HNAPI.getdynamicData(value);
  1465.  
  1466. if (dynamic_data.hasOwnProperty('card') == false) {
  1467. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 失效!!!");
  1468. continue;
  1469. }
  1470. let dynamic_id = dynamic_data.card.desc.dynamic_id_str;
  1471. let dynamic_type = 17;
  1472. await HNTOOL.Sleep(2000);
  1473.  
  1474. if (dynamic_data.card.desc.is_liked == 1) {
  1475. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 已转发,舍弃!!!");
  1476.  
  1477. //if (dynamic_data.card.desc.type == 2 || dynamic_data.card.desc.type == 4) {
  1478. if (dynamic_data.card["extension"] != undefined) {
  1479. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1480. await HNTOOL.Sleep(2000);
  1481.  
  1482. if (lNoticeData["lottery_result"] != undefined) {
  1483.  
  1484. console.log(
  1485. "【" + index + "已过开奖时间】\n" +
  1486. "用户:" + dynamic_data.card.desc.user_profile.info.uname + "\n" +
  1487. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1488. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n" +
  1489. "名单:" + JSON.stringify(lNoticeData.lottery_result)
  1490. );
  1491. }
  1492.  
  1493. }
  1494. continue;
  1495. }
  1496. //判断是否过期
  1497. if (dynamic_data.card["extension"] != undefined) {
  1498. dynamic_type = 11;
  1499. dynamic_id = dynamic_data.card.desc.rid;
  1500. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1501. await HNTOOL.Sleep(2000);
  1502.  
  1503. if (lNoticeData["lottery_result"] != undefined) {
  1504.  
  1505.  
  1506. console.log(
  1507. "【" + index + "已过开奖时间】\n" +
  1508. "用户:" + dynamic_data.card.desc.user_profile.info.uname + "\n" +
  1509. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1510. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n" +
  1511. "名单:" + JSON.stringify(lNoticeData.lottery_result)
  1512. );
  1513. continue;
  1514. }
  1515.  
  1516. }
  1517.  
  1518. if (allFollow.indexOf(dynamic_data.card.desc.uid) == -1) {
  1519.  
  1520. let res = await HNAPI.batchModify(dynamic_data.card.desc.uid);
  1521. if (dynamic_data.card.desc.type == 2 && res == false) {
  1522. console.log("【" + index + "】关注官方动态up失败,检查账号是否异常,风控等!!!https://t.bilibili.com/" + value +
  1523. "?tab=2");
  1524. continue;
  1525. }
  1526. console.log("【" + index + "】关注" + dynamic_data.card.desc.uid + "成功!!!");
  1527. }
  1528.  
  1529. await HNTOOL.Sleep(1000);
  1530.  
  1531. //1.评论
  1532. await HNAPI.addReply(dynamic_id, dynamic_type);
  1533. console.log("【" + index + "】" + dynamic_id + "评论成功!!!");
  1534. await HNTOOL.Sleep(1000);
  1535. //3.点赞
  1536. await HNAPI.likeDynamic(value);
  1537. await HNTOOL.Sleep(1000);
  1538. //2.转发
  1539. let repostCard = HNTOOL.strToJson(dynamic_data.card.card);
  1540. let repostStr = HNTOOL.getRandomWordOfList(replyList);
  1541. let repostCtrl = "转发动态";
  1542. let relay_chat = null;
  1543. if (repostCard["user"]["uname"] != undefined && dynamic_data.card["extension"] == undefined) {
  1544.  
  1545. //转发内容 = 评论+'//'+'@'+用户名+':'+源内容
  1546. relay_chat = repostStr + "//@" + repostCard.user.uname + ":" + repostCard.item.content;
  1547. repostCtrl = repostCard.item.ctrl;
  1548.  
  1549. }
  1550. await HNAPI.repostDynamic(value, repostStr, repostCtrl);
  1551. await HNTOOL.Sleep(1000);
  1552. console.log("【" + index + "】动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!");
  1553.  
  1554. javaex.tip({
  1555. content: "动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!",
  1556. type: "success"
  1557. });
  1558.  
  1559. //存储标记
  1560. //await HNAPI.setNotice(value);
  1561.  
  1562. //随机延迟120 -240秒
  1563. let sleeptime = HNTOOL.random(12, 24) * 10 * 1000;
  1564. console.log("转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!")
  1565. javaex.tip({
  1566. content: "转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!",
  1567. type: "success"
  1568. });
  1569. await HNTOOL.Sleep(sleeptime);
  1570. }
  1571.  
  1572. alert("今日动态抽奖完成!!!");
  1573.  
  1574. });
  1575.  
  1576. $("#batchFollowOfbastard").bind("click", async function() {
  1577.  
  1578. if (confirm("作者个人需求开发,谨慎使用!!!\n 本功能会取关设定值以下没有认证和个人认证的的关注! \n 不确定使用请取消!")) {
  1579.  
  1580. let fansNum = prompt("请输入最低粉丝数量", "50000");
  1581.  
  1582. if (fansNum != null && fansNum != "") {
  1583. //fansNum
  1584.  
  1585. let followList = await HNAPI.getAllFollow();
  1586. console.log(followList);
  1587. await HNTOOL.Sleep(2000);
  1588.  
  1589. for (let fl of followList) {
  1590.  
  1591. if (fl == 99439379) {
  1592. await HNAPI.cancelAtt(fl, 1);
  1593. continue;
  1594. }
  1595. if (!followList.indexOf(99439379)) {
  1596.  
  1597. await HNAPI.cancelAtt(99439379, 1);
  1598. }
  1599.  
  1600. let user = await HNAPI.getCardByUID(fl);
  1601. await HNTOOL.Sleep(1000);
  1602. //0签约主播 1机构认证
  1603.  
  1604. if (user.fans < parseInt(fansNum) && /0|2|7/.test(user.Official.role)) {
  1605. await HNAPI.cancelAtt(fl, 2);
  1606.  
  1607. javaex.tip({
  1608. content: "uid:" + user.mid + "-" + user.name + "--粉丝量-" + user.fans +
  1609. "---符合条件 取关成功!!!",
  1610. type: "success"
  1611. });
  1612. console.log("---uid:" + user.mid + "\n---" + user.name + "\n---粉丝量-" + user.fans +
  1613. "\n---符合条件 取关成功!!!");
  1614.  
  1615. } else {
  1616. javaex.tip({
  1617. content: "uid:" + user.mid + "-" + user.name + "--粉丝量-" + user.fans +
  1618. "---不符合条件 取消!!!",
  1619. type: "success"
  1620. });
  1621. console.log("uid:" + user.mid + "-" + user.name + "---粉丝量-" + user.fans +
  1622. "---不符合条件 取消!!!");
  1623. }
  1624. }
  1625. }
  1626.  
  1627. }
  1628.  
  1629. });
  1630.  
  1631.  
  1632. $("#reserveActivity").bind("click", async function() {
  1633.  
  1634.  
  1635. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSids.json";
  1636. let myjson = await HNAPI.getMyJson(url);
  1637.  
  1638. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1639. if (typeof(lastSid) == "undefined") {
  1640. lastSid = HN_SETUP_CONFIG.Booking_last_sid;
  1641. }
  1642. lastSid = lastSid.split("&")[1];
  1643.  
  1644.  
  1645.  
  1646. for (const sid in myjson) {
  1647.  
  1648. if (parseInt(lastSid) >= parseInt(sid)) {
  1649.  
  1650. continue;
  1651. }
  1652.  
  1653. let siddata = myjson[sid];
  1654. //let sidList = await HNAPI.getDataByLiveSid(sid);
  1655. //await HNTOOL.Sleep(2000);
  1656.  
  1657. //let returnData = await HNAPI.reserveActivity(sid, sidList[sid].total);
  1658. await HNAPI.reserveActivity(sid);
  1659. await HNTOOL.Sleep(2000);
  1660.  
  1661. let tiplog = "\n --预约开始:" + javaex.dateFormat(siddata.livePlanStartTime,
  1662. 'yyyy-MM-dd HH:mm:ss') +
  1663. //"\n --预约SID:" + siddata.sid +
  1664. //"\n --预约UID:" + siddata.upmid +
  1665. //"\n --预约地址:" + siddata.prizeInfo.jumpUrl +
  1666. "\n --预约人数:" + siddata.total + "人" +
  1667. "\n --预约奖品:" + siddata.prizeInfo.text;
  1668.  
  1669. console.log(tiplog);
  1670.  
  1671. javaex.tip({
  1672. content: tiplog,
  1673. type: "success"
  1674. });
  1675.  
  1676. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + sid;
  1677.  
  1678. HNTOOL.saveConfig();
  1679.  
  1680. }
  1681.  
  1682.  
  1683. alert("预约抽奖结束");
  1684. });
  1685.  
  1686. $("#liveActivity").bind("click", async function() {
  1687.  
  1688. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1689. let myjson = await HNAPI.getMyJson(url);
  1690.  
  1691. });
  1692.  
  1693.  
  1694. $("#linshiActivity2").bind("click", async function() {
  1695.  
  1696. let open_capsule_by_id = {
  1697. 'areaids': 1,
  1698. 'csrf_token': Live_info.csrf_token,
  1699. 'csrf': Live_info.csrf_token,
  1700. 'visit_id': ''
  1701. };
  1702.  
  1703. await HNAPI.basePost(
  1704. "https://api.live.bilibili.com/xlive/activity-interface/v2/spec-act/bls21-area/BlsLifeSubArea",
  1705. open_capsule_by_id);
  1706.  
  1707. await HNAPI.basePost(
  1708. "https://api.live.bilibili.com/xlive/activity-interface/v2/spec-act/bls21-area/BlsLifeSubList", {}
  1709. );
  1710. await HNTOOL.Sleep(5000);
  1711.  
  1712. let open_capsule_by_id2 = {
  1713. 'id': 313,
  1714. 'count': 1,
  1715. 'platform': 'web',
  1716. 'csrf_token': Live_info.csrf_token,
  1717. 'csrf': Live_info.csrf_token,
  1718. 'visit_id': '',
  1719. '_': Math.round(new Date()),
  1720. };
  1721.  
  1722. let open_capsule = await HNAPI.basePost(
  1723. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  1724. open_capsule_by_id2);
  1725.  
  1726. if (open_capsule.err) {
  1727. alert(open_capsule.err);
  1728. }
  1729.  
  1730. let awards = (open_capsule.data.awards)[0];
  1731. alert(awards.gift_value + awards.text);
  1732.  
  1733.  
  1734.  
  1735. });
  1736.  
  1737. $("#linshiActivity").bind("click", async function() {
  1738.  
  1739. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/bilicat_config.json";
  1740. let myjson = await HNAPI.getMyJson(url);
  1741.  
  1742. let uids = myjson.config_linshi;
  1743.  
  1744. for (let uid of uids) {
  1745. await HNAPI.cancelAtt(uid, 2);
  1746. await HNTOOL.Sleep(1000);
  1747. }
  1748.  
  1749. await HNAPI.batchModify(uids.toString(), 1);
  1750. await HNTOOL.Sleep(5000);
  1751.  
  1752. await HNAPI.baseGet(
  1753. " https://api.live.bilibili.com/xlive/activity-interface/v2/userTask/GetNewUserTaskInfo", {
  1754. "task_id": 351
  1755. });
  1756.  
  1757. await HNTOOL.Sleep(1000);
  1758. let open_capsule_by_id = {
  1759. 'id': 308,
  1760. 'count': 1,
  1761. 'platform': 'web',
  1762. 'csrf_token': Live_info.csrf_token,
  1763. 'csrf': Live_info.csrf_token,
  1764. 'visit_id': '',
  1765. '_': Math.round(new Date()),
  1766. };
  1767.  
  1768. let open_capsule = await HNAPI.basePost(
  1769. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  1770. open_capsule_by_id);
  1771. await HNTOOL.Sleep(1000);
  1772.  
  1773. if (open_capsule.err) {
  1774. alert(open_capsule.err);
  1775. }
  1776.  
  1777. GM_setClipboard(((open_capsule.data.awards)[0]).gift_value);
  1778.  
  1779. alert("已复制到剪切板:" + ((open_capsule.data.awards)[0]).gift_value);
  1780. });
  1781.  
  1782.  
  1783. $("#jury_case").bind("click", async function() {
  1784.  
  1785. let bln = window.confirm('是否立即执行?【确定:只会执行一次】;【取消:0:10(5H)】;');
  1786.  
  1787. if (bln) {
  1788. HNTOOL.console("风纪开始!")
  1789. HNTOOL.jury_case();
  1790. } else {
  1791. for (var i = 0; i < 1; i--) {
  1792.  
  1793. let now = new Date();
  1794. let hour = now.getHours();
  1795. let minu = now.getMinutes();
  1796. HNTOOL.console("风纪运行中……");
  1797.  
  1798. if ((hour == 0 || HNTOOL.isInteger(hour / 6)) && minu == 10) {
  1799. HNTOOL.console("风纪开始到达预定时间开始执行!")
  1800. HNTOOL.jury_case();
  1801. }
  1802.  
  1803. await HNTOOL.Sleep(50000);
  1804. }
  1805. }
  1806.  
  1807. });
  1808.  
  1809. $("#plateActivity").bind("click", async function() {
  1810.  
  1811. //获取轮盘数据
  1812.  
  1813. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1814. let myjson = await HNAPI.getMyJson(url);
  1815. let lmt = 0;
  1816. let k = 20; //重试次数 防止卡主
  1817. let giftArr = [];
  1818. let endAtion = [];
  1819.  
  1820. javaex.tip({
  1821. content: "开始参加轮盘!!!",
  1822. type: "success"
  1823. });
  1824.  
  1825. await HNAPI.getUserNav();
  1826. await HNTOOL.Sleep(1500);
  1827.  
  1828.  
  1829. for (const json of myjson.acriviries_type1) {
  1830. //let x = json.name;
  1831. for (let i = 0; i < 10; i++) {
  1832. //1.结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1833. let resout = await HNAPI.addLotteryTimes(json.sid);
  1834.  
  1835. await HNTOOL.Sleep(200);
  1836. if (resout == 1) {
  1837.  
  1838. endAtion.push(json.name + ":活动已结束!");
  1839. javaex.tip({
  1840. content: json.name + "活动已结束!",
  1841. type: "success"
  1842. });
  1843.  
  1844. break;
  1845. }
  1846. if (resout != 0 && resout != 1) {
  1847.  
  1848. javaex.tip({
  1849. content: json.name + resout,
  1850. type: "error"
  1851. });
  1852.  
  1853. break;
  1854. }
  1855.  
  1856. if (resout == 0) {
  1857. //2.查询次数
  1858. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1859. continue;
  1860. }
  1861.  
  1862. }
  1863.  
  1864. javaex.tip({
  1865. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1866. type: "success"
  1867. });
  1868.  
  1869. await HNTOOL.Sleep(1000);
  1870.  
  1871. for (let i = 0; i < lmt; i++) {
  1872. //3、执行抽奖
  1873. let gift = await HNAPI.lotteryDo(json.sid, json.name);
  1874.  
  1875. if (gift == true) {
  1876. javaex.tip({
  1877. content: "点击过快,9秒后自动重试!!!",
  1878. type: "error"
  1879. });
  1880. i--;
  1881. k--;
  1882. }
  1883.  
  1884. if (gift == false || k == 0) {
  1885. break;
  1886. }
  1887.  
  1888. if (gift != "未中奖0" && gift != true) {
  1889. giftArr.push(json.name + "奖品为:" + gift + "\n");
  1890.  
  1891. break;
  1892. } else {
  1893. javaex.tip({
  1894. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  1895. type: "success"
  1896. });
  1897. }
  1898. await HNTOOL.Sleep(6000);
  1899.  
  1900. }
  1901.  
  1902.  
  1903. }
  1904.  
  1905. for (const json2 of myjson.acriviries_type2) {
  1906.  
  1907. let submitData1 = {
  1908. "act_id": json2.act_id,
  1909. "share_type": 1,
  1910. "visit_id": "",
  1911. "csrf_token": Live_info.csrf_token,
  1912. "csrf": Live_info.csrf_token,
  1913. }
  1914.  
  1915. let submitReul1 = await HNAPI.basePost(
  1916. "https://api.live.bilibili.com/xlive/activity-interface/v1/task/UserShare", submitData1);
  1917. await HNTOOL.Sleep(1000);
  1918.  
  1919. let submitData2 = {
  1920. "act_id": json2.act_id
  1921. }
  1922. let submitReul2 = await HNAPI.baseGet(
  1923. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/info",
  1924. submitData2);
  1925. await HNTOOL.Sleep(1000);
  1926.  
  1927. let task = submitReul2.data.task_list[0];
  1928. if (task) {
  1929. let submitData3 = {
  1930. "act_id": json2.act_id,
  1931. "task_id": task.task_id,
  1932. "cycle_id": task.task_cycle_id,
  1933. "level_id": 1,
  1934. "visit_id": "",
  1935. "csrf_token": Live_info.csrf_token,
  1936. "csrf": Live_info.csrf_token,
  1937. }
  1938.  
  1939. await HNAPI.basePost(
  1940. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/getaward",
  1941. submitData3);
  1942. await HNTOOL.Sleep(3000);
  1943.  
  1944. await HNAPI.baseGet(
  1945. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/info",
  1946. submitData2);
  1947. await HNTOOL.Sleep(1000);
  1948.  
  1949. let submitData4 = {
  1950. "id": json2.id,
  1951. "count": 1,
  1952. "platform": "web",
  1953. "_": Math.round(new Date()),
  1954. "visit_id": "",
  1955. "csrf_token": Live_info.csrf_token,
  1956. "csrf": Live_info.csrf_token,
  1957. }
  1958.  
  1959. let submitReul4 = await HNAPI.basePost(
  1960. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  1961. submitData4);
  1962. await HNTOOL.Sleep(1000);
  1963. if (submitReul4 == false) {
  1964. HNTOOL.console(json2.act_id + ":失败!");
  1965. continue;
  1966. }
  1967. HNTOOL.console("直播转盘:" + json2.act_id + ":" + submitReul4.data.text[0]);
  1968.  
  1969. giftArr.push("直播转盘:" + json2.act_id + ":" + submitReul4.data.text[0] + "\n");
  1970. }
  1971.  
  1972.  
  1973. }
  1974.  
  1975.  
  1976. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:\n` + (
  1977. giftArr.length == 0 ? "未中奖" : giftArr.toString()));
  1978.  
  1979. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `\n 中奖详情:` + (giftArr.length == 0 ? "未中奖" : giftArr
  1980. .toString()));
  1981.  
  1982.  
  1983. });
  1984.  
  1985. $("#addPlay").bind("click", async function() {
  1986.  
  1987.  
  1988. let html = '';
  1989.  
  1990. html += '<div style="padding: 10px 10px 10px 0px;">'
  1991. html += '<form id="getUpMassage_form">'
  1992.  
  1993. html += ' <div class="javaex-unit clear">'
  1994. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  1995. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  1996. html +=
  1997. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  1998. html +=
  1999. ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  2000. html += ' </div>'
  2001. html += ' </div>'
  2002. html += ' <div class="javaex-unit clear">'
  2003. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  2004. html +=
  2005. ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  2006. html +=
  2007. ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  2008. html +=
  2009. ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  2010. html += ' </div>'
  2011. html += ' </div>'
  2012. html += '</form>';
  2013. html += ' <div class="javaex-unit clear tc">'
  2014. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  2015. html += ' </div>'
  2016. html += '<hr class="javaex-divider"></hr>';
  2017. html += '</div>';
  2018.  
  2019.  
  2020. javaex.panel(this, {
  2021. position: "right",
  2022. content: html
  2023. });
  2024.  
  2025. $("#addPlay_bgn").click(async function() {
  2026.  
  2027. let MID = javaex.getSelectVal("#addPlay_uid")
  2028. let BV = javaex.getSelectVal("#addPlay_bv");
  2029. let bvArr = [];
  2030. let bvArr2 = [];
  2031.  
  2032. MID = javaex.ifnull(MID, BiliData.author_uid);
  2033.  
  2034.  
  2035. if (BV == "0") {
  2036.  
  2037. //1.查询up所有视频BV号 2.发送心跳间隔2s
  2038. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  2039. await HNTOOL.Sleep(500);
  2040. bvArr2 = BiliData.BVList;
  2041.  
  2042. for (let i = 1; i > 0; i++) {
  2043.  
  2044. HNAPI.getUpAllBV(MID, i);
  2045.  
  2046. await HNTOOL.Sleep(500);
  2047.  
  2048. if (BiliData.BVList.length == 0) {
  2049. if (bvArr.length == 0) {
  2050. javaex.tip({
  2051. content: "该用户无投稿视频,请确认是否有误!",
  2052. type: "success"
  2053. });
  2054. await HNTOOL.Sleep(2000);
  2055. }
  2056. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  2057. bvArr = bvArr.concat(bvArr2);
  2058. break;
  2059. }
  2060.  
  2061. bvArr = bvArr.concat(BiliData.BVList);
  2062. }
  2063.  
  2064.  
  2065. if (bvArr.length != 0) {
  2066.  
  2067. for (const emt of bvArr) {
  2068.  
  2069. HNAPI.playOneVideo(emt.bvid, MID);
  2070.  
  2071. await HNTOOL.Sleep(2000);
  2072.  
  2073. }
  2074.  
  2075. alert("播放完成!!!");
  2076.  
  2077. }
  2078.  
  2079.  
  2080. } else {
  2081. //1.调用点击播放接口
  2082. //2.发送心跳
  2083.  
  2084. await HNTOOL.Sleep(500);
  2085.  
  2086. HNAPI.playOneVideo(BV);
  2087. }
  2088.  
  2089.  
  2090. });
  2091.  
  2092.  
  2093. });
  2094.  
  2095. }
  2096.  
  2097.  
  2098.  
  2099.  
  2100. let addSetPage = async function() {
  2101.  
  2102. HNTOOL.Sleep(1000);
  2103.  
  2104. $('body').append('' +
  2105. '<div id="left_navbar">' +
  2106. '<div class="javaex-menu-container"> ' +
  2107. ' <div id="menu" class="javaex-menu"> ' +
  2108. ' <ul> ' +
  2109. ' <li class="javaex-menu-item alone hover" > ' +
  2110. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  2111. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  2112. ' </li> ' +
  2113. ' </ul> ' +
  2114. ' <ul> ' +
  2115. ' <li class="javaex-menu-item"> ' +
  2116. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  2117. ' <ul> ' +
  2118. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  2119. ' </ul> ' +
  2120. ' </li> ' +
  2121. ' <li id="chackList" class="javaex-menu-item"> ' +
  2122. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  2123. ' <ul> ' +
  2124. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  2125. //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  2126. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  2127. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  2128. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  2129. ' </ul> ' +
  2130. ' </li> ' +
  2131. ' <li class="javaex-menu-item"> ' +
  2132. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  2133. ' <ul> ' +
  2134. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  2135. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  2136. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  2137. ' <li id="yunBatchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >取关云数据</a></li> ' +
  2138. ' <li id="batchFollowOfbastard" class="javaex-hover-pulse"><a href="javaScript:;" >批量取关-慎用</a></li> ' +
  2139. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  2140. ' <li id="batch_dynamic_like" class="javaex-hover-pulse"><a href="javaScript:;" >批量动态点赞</a></li> ' +
  2141. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  2142. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  2143. ' </ul> ' +
  2144. ' </li> ' +
  2145. ' <li class="javaex-menu-item"> ' +
  2146. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  2147. ' <ul> ' +
  2148. ' <li id="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
  2149. ' <li id="jury_case" class="javaex-hover-pulse"><a href="javaScript:;" >一键风纪任务【0:10(5H)】</a></li> ' +
  2150. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  2151. ' <li id="linshiActivity" class="javaex-hover-pulse"><a href="javaScript:;" >临时转盘-和平</a></li> ' +
  2152. ' <li id="linshiActivity2" class="javaex-hover-pulse"><a href="javaScript:;" >临时转盘-整活</a></li> ' +
  2153. //' <li id="liveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >直播转盘</a></li> ' +
  2154. //' <li id="likeInDynamicComments" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  2155. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  2156. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  2157. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  2158. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  2159. ' <li id="dynamicActivity" class="javaex-hover-pulse"><a href="javaScript:;" >动态抽奖</a></li> ' +
  2160. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  2161. //' <li id="auto_check_question" class="javaex-hover-pulse"><a href="javaScript:;">一键答题</a></li> ' +
  2162. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  2163. ' </ul> ' +
  2164. ' </li> ' +
  2165. ' <li class="javaex-menu-item"> ' +
  2166. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  2167. ' <ul> ' +
  2168. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  2169. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  2170. ' </ul> ' +
  2171. ' </li> ' +
  2172.  
  2173. ' </ul> ' +
  2174. ' </div> ' +
  2175. '</div>' +
  2176. '</div>');
  2177. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  2178.  
  2179. javaex.menu({
  2180. id: "menu",
  2181. isShowAll: false
  2182. });
  2183.  
  2184. }
  2185.  
  2186.  
  2187.  
  2188.  
  2189. let showUnreadMsg = function() {
  2190.  
  2191. var html = '';
  2192. html += '<div class="javaex-panel-box" style="width: 250px;">';
  2193. html += ' <ul>';
  2194. html += ` <p style="color: #FFF;">用户消息</p>`;
  2195. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  2196. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  2197. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  2198. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  2199. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  2200. html += ' <hr class="javaex-divider"></hr>';
  2201. html += ' </ul>';
  2202. html += '</div>';
  2203.  
  2204.  
  2205. javaex.panel(document.getElementById("getUnread"), {
  2206. position: "right",
  2207. content: html
  2208. });
  2209.  
  2210. javaex.tip({
  2211. content: "查询用户通知成功!",
  2212. type: "success"
  2213. });
  2214.  
  2215. }
  2216.  
  2217. /**
  2218. * 检查 艾特信息
  2219. * @returns {Promise<void>}
  2220. */
  2221. let chackAtMsg = async function(items) {
  2222.  
  2223. await HNTOOL.Sleep(500);
  2224.  
  2225. if (items != false && typeof(items) != "undefined") {
  2226.  
  2227.  
  2228. var html = '';
  2229. html += '<div class="javaex-panel-box" style="width: auto;">';
  2230. html += ' <ul>';
  2231. html += ` <p style="color: #FFF;">@信息</p>`;
  2232. items.forEach(function(item) {
  2233.  
  2234. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  2235. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  2236. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  2237.  
  2238. html +=
  2239. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  2240. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  2241. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  2242. html += ' <hr class="javaex-divider"></hr>';
  2243. });
  2244. html += ' </ul>';
  2245. html += '</div>';
  2246.  
  2247.  
  2248. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  2249. javaex.panel(document.getElementById("getAtMsg"), {
  2250. position: "right",
  2251. content: html
  2252. });
  2253. } else {
  2254. javaex.panel(document.getElementById("chackList"), {
  2255. position: "right",
  2256. content: html
  2257. });
  2258. }
  2259.  
  2260.  
  2261. }
  2262.  
  2263. }
  2264.  
  2265.  
  2266. let addStyle = function() {
  2267. const animate = GM_getResourceText('animate');
  2268. const common = GM_getResourceText('common');
  2269. const defaultCss = GM_getResourceText('defaultCss');
  2270. //const icomoonex = GM_getResourceText('icomoonex');
  2271. //const AllCss = animate + common + defaultCss + icomoonex;
  2272. const AllCss = animate + common + defaultCss;
  2273. const style = document.createElement('style');
  2274. style.innerHTML = AllCss;
  2275. return document.getElementsByTagName('head')[0].appendChild(style);
  2276. }
  2277.  
  2278. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  2279.  
  2280.  
  2281. /*-----------------------------------------------常用API--------------------------------------------------*/
  2282.  
  2283. let HNAPI = {
  2284.  
  2285. basePost: async function(api, data) {
  2286. return new Promise((resolve) => {
  2287. Ajax.post({
  2288. url: api,
  2289. hasCookies: true,
  2290. dataType: 'application/x-www-form-urlencoded',
  2291. data: data,
  2292. success: responseText => {
  2293. let res = HNTOOL.strToJson(responseText);
  2294. if (res.code === 0) {
  2295.  
  2296. resolve(res);
  2297. } else {
  2298. HNTOOL.console(res.message);
  2299.  
  2300. resolve({
  2301. err: res.message
  2302. });
  2303. }
  2304. }
  2305. })
  2306. });
  2307. },
  2308.  
  2309.  
  2310.  
  2311. baseGet: async function(api, queryObj) {
  2312. return new Promise((resolve) => {
  2313.  
  2314. Ajax.get({
  2315. url: api,
  2316. queryStringsObj: queryObj,
  2317. hasCookies: true,
  2318. success: responseText => {
  2319. let res = HNTOOL.strToJson(responseText);
  2320. if (res.code === 0) {
  2321.  
  2322. resolve(res);
  2323. } else {
  2324.  
  2325. resolve(false);
  2326. }
  2327. }
  2328. })
  2329. });
  2330. },
  2331.  
  2332. exchange_chance: async function(activity_id) {
  2333. return new Promise((resolve) => {
  2334.  
  2335. Ajax.get({
  2336. url: "https://qcloud-sdkact-api.biligame.com/exchange/chance",
  2337. queryStringsObj: {
  2338. 't': Math.round(new Date()),
  2339. 'activity_id': activity_id,
  2340.  
  2341. },
  2342. hasCookies: true,
  2343. success: responseText => {
  2344. let res = HNTOOL.strToJson(responseText);
  2345. if (res.code === 0) {
  2346.  
  2347. resolve(true);
  2348. } else {
  2349.  
  2350. resolve(false);
  2351. }
  2352. }
  2353. })
  2354. });
  2355. },
  2356. wwjdg_inform: async function(activity_id) {
  2357. return new Promise((resolve) => {
  2358.  
  2359. Ajax.get({
  2360. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/inform",
  2361. queryStringsObj: {
  2362. 't': Math.round(new Date()),
  2363. 'activity_id': activity_id,
  2364.  
  2365. },
  2366. hasCookies: true,
  2367. success: responseText => {
  2368. let res = HNTOOL.strToJson(responseText);
  2369. if (res.code === 0) {
  2370.  
  2371. resolve(true);
  2372. } else {
  2373.  
  2374. resolve(false);
  2375. }
  2376. }
  2377. })
  2378. });
  2379. },
  2380. wwjdg_inform_off: async function(activity_id, info_no) {
  2381. return new Promise((resolve) => {
  2382. Ajax.post({
  2383. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/inform/off?t=" + Math.round(
  2384. new Date()),
  2385. hasCookies: true,
  2386. dataType: 'application/x-www-form-urlencoded',
  2387. data: {
  2388.  
  2389. activity_id: activity_id,
  2390. info_no: info_no,
  2391.  
  2392. },
  2393. success: responseText => {
  2394. let res = HNTOOL.strToJson(responseText);
  2395. if (res.code === 0) {
  2396.  
  2397. resolve(true);
  2398. } else {
  2399.  
  2400. resolve(false);
  2401. }
  2402. }
  2403. })
  2404. });
  2405. },
  2406.  
  2407. exchange_prize: async function(activity_id) {
  2408. return new Promise((resolve) => {
  2409.  
  2410. Ajax.get({
  2411. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/exchange_prize",
  2412. queryStringsObj: {
  2413. 't': Math.round(new Date()),
  2414. 'activity_id': activity_id,
  2415. 'prize_id': 5629853426288896,
  2416. },
  2417. hasCookies: true,
  2418. success: responseText => {
  2419. let res = HNTOOL.strToJson(responseText);
  2420. if (res.code === 0) {
  2421.  
  2422. resolve(true);
  2423. } else {
  2424.  
  2425. resolve(false);
  2426. }
  2427. }
  2428. })
  2429. });
  2430. },
  2431. lottery_draw_one: async function() {
  2432. return new Promise((resolve) => {
  2433. Ajax.post({
  2434. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw?t=" + Math
  2435. .round(new Date()),
  2436. hasCookies: true,
  2437. dataType: 'application/x-www-form-urlencoded',
  2438. data: {
  2439.  
  2440. activity_id: 5629854950017280
  2441.  
  2442. },
  2443. success: responseText => {
  2444. let res = HNTOOL.strToJson(responseText);
  2445. if (res.code === 0) {
  2446.  
  2447. alert(res.data.name)
  2448.  
  2449. } else if (res.code === 11001 || res.code == -905) {
  2450.  
  2451. Ajax.post({
  2452. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw?t=" +
  2453. Math
  2454. .round(new Date()),
  2455. hasCookies: true,
  2456. dataType: 'application/x-www-form-urlencoded',
  2457. data: {
  2458.  
  2459. activity_id: 5629850673711360
  2460.  
  2461. },
  2462. success: responseText => {
  2463. let res2 = HNTOOL.strToJson(responseText);
  2464. if (res2.code === 0) {
  2465.  
  2466. alert(res2.data.name)
  2467. } else if (res.code == -905) {
  2468. alert(res2.message);
  2469. } else {
  2470.  
  2471. resolve(false);
  2472. }
  2473. }
  2474. })
  2475.  
  2476. } else {
  2477.  
  2478. resolve(false);
  2479. }
  2480. }
  2481. })
  2482. });
  2483. },
  2484. /**
  2485. *
  2486. */
  2487.  
  2488. jury_vote: async function(case_id, vote, anonymous) {
  2489. return new Promise((resolve) => {
  2490. Ajax.post({
  2491. url: BILIBLI_PATH.api + "/x/credit/v2/jury/vote",
  2492. hasCookies: true,
  2493. dataType: 'application/x-www-form-urlencoded',
  2494. data: {
  2495.  
  2496. case_id: case_id,
  2497. vote: vote,
  2498. anonymous: anonymous,
  2499. content: "",
  2500. csrf: Live_info.csrf_token
  2501. },
  2502. success: responseText => {
  2503. let res = HNTOOL.strToJson(responseText);
  2504. if (res.code === 0) {
  2505.  
  2506. resolve(true);
  2507. } else {
  2508.  
  2509. resolve(res.message);
  2510. }
  2511. }
  2512. })
  2513. });
  2514. },
  2515.  
  2516. /**
  2517. *
  2518. */
  2519. jury_case_opinion: async function(case_id) {
  2520. return new Promise((resolve) => {
  2521.  
  2522. Ajax.get({
  2523. url: BILIBLI_PATH.api + "/x/credit/v2/jury/case/opinion",
  2524. queryStringsObj: {
  2525. 'case_id': case_id,
  2526. 'pn': 1,
  2527. 'ps': 5,
  2528.  
  2529. },
  2530. hasCookies: true,
  2531. success: responseText => {
  2532. let res = HNTOOL.strToJson(responseText);
  2533. if (res.code === 0) {
  2534. resolve(true);
  2535. } else {
  2536.  
  2537. HNTOOL.console("获取案件详情发生错误!" + res.message, "error");
  2538.  
  2539. resolve(false);
  2540. }
  2541. }
  2542. })
  2543. });
  2544. },
  2545. /**
  2546. *
  2547. */
  2548. jury_case_info: async function(case_id) {
  2549. return new Promise((resolve) => {
  2550.  
  2551. Ajax.get({
  2552. url: BILIBLI_PATH.api + "/x/credit/v2/jury/case/info",
  2553. queryStringsObj: {
  2554. 'case_id': case_id
  2555. },
  2556. hasCookies: true,
  2557. success: responseText => {
  2558. let res = HNTOOL.strToJson(responseText);
  2559. if (res.code === 0) {
  2560. let comment_content = "";
  2561. let itemlist = [1, 1, 1, 1, 2, 2, 2, 2, 3, 0];
  2562. let x = itemlist[HNTOOL.random(0, 10)];
  2563.  
  2564. let vote_item = res.data.vote_items[x];
  2565. let case_type = res.data.case_type;
  2566. if (case_type == 4) {
  2567. //4:截屏内弹幕
  2568. comment_content = "截屏内弹幕";
  2569.  
  2570. } else {
  2571. comment_content = res.data.case_info.comment.content;
  2572. }
  2573.  
  2574.  
  2575. HNTOOL.console(
  2576. "\n 案号:" + case_id +
  2577. "\n 详情:" + comment_content +
  2578. "\n 选择:" + vote_item.vote_text
  2579. );
  2580. resolve(vote_item.vote);
  2581. } else {
  2582.  
  2583. HNTOOL.console("获取案件详情发生错误!" + res.message, "error");
  2584.  
  2585. resolve(false);
  2586. }
  2587. }
  2588. })
  2589. });
  2590. },
  2591.  
  2592. /**
  2593. *
  2594. */
  2595. jury_case_next: async function() {
  2596. return new Promise((resolve) => {
  2597.  
  2598. Ajax.get({
  2599. url: BILIBLI_PATH.api + '/x/credit/v2/jury/case/next',
  2600. queryStringsObj: {
  2601.  
  2602. },
  2603. hasCookies: true,
  2604. success: responseText => {
  2605. let res = HNTOOL.strToJson(responseText);
  2606. if (res.code === 0) {
  2607.  
  2608. resolve(res.data.case_id);
  2609. } else if (res.code === 25014 || res.code === 25008) {
  2610.  
  2611. HNTOOL.console(res.message);
  2612.  
  2613.  
  2614. } else {
  2615. HNTOOL.console("今日风纪已完成&暂时无案子!");
  2616. resolve(false);
  2617. }
  2618. }
  2619. })
  2620. });
  2621. },
  2622.  
  2623. answer_check: async function(question_id, ans_hash, type) {
  2624. return new Promise((resolve) => {
  2625. Ajax.post({
  2626.  
  2627. url: "https://api.bilibili.com/x/answer/v4/" + type + "/check",
  2628. hasCookies: true,
  2629. dataType: 'application/x-www-form-urlencoded',
  2630. data: {
  2631. question_id: question_id,
  2632. ans_hash: ans_hash,
  2633. csrf: Live_info.csrf_token
  2634. },
  2635. success: responseText => {
  2636. let res = HNTOOL.strToJson(responseText);
  2637. if (res.code === 0) {
  2638. console.log("答题成功");
  2639. resolve(res.data);
  2640. } else if (res.code === 41020) {
  2641. resolve(1);
  2642. } else {
  2643. javaex.tip({
  2644. content: "错误!",
  2645. type: "error"
  2646. });
  2647. resolve(false);
  2648. }
  2649. }
  2650. })
  2651. });
  2652. },
  2653.  
  2654. /**
  2655. *
  2656. */
  2657. pull_answer: async function(type) {
  2658. return new Promise((resolve) => {
  2659.  
  2660. Ajax.get({
  2661. url: 'https://api.bilibili.com/x/answer/v4/' + type,
  2662. queryStringsObj: {
  2663.  
  2664. },
  2665. hasCookies: true,
  2666. success: responseText => {
  2667. let res = HNTOOL.strToJson(responseText);
  2668. if (res.code === 0) {
  2669.  
  2670. resolve(res.data);
  2671. } else if (res.code === 41020) {
  2672. console.log("用户" + type + "题已通过")
  2673. resolve(1);
  2674. } else {
  2675. console.log("拉取" + type + "题目失败:" + res.message);
  2676. resolve(false);
  2677. }
  2678. }
  2679. })
  2680. });
  2681. },
  2682.  
  2683. /**
  2684. *
  2685. */
  2686. answer_status: async function() {
  2687. return new Promise((resolve) => {
  2688. Ajax.get({
  2689. url: 'https://api.bilibili.com/x/answer/v4/status',
  2690. queryStringsObj: {
  2691.  
  2692. },
  2693. hasCookies: true,
  2694. success: responseText => {
  2695. let res = HNTOOL.strToJson(responseText);
  2696. if (res.code === 0) {
  2697.  
  2698. resolve(res.data);
  2699.  
  2700. } else {
  2701. console.log("查询答题状态失败:" + res.message);
  2702. resolve(false);
  2703. }
  2704. }
  2705. })
  2706. });
  2707. },
  2708.  
  2709. /**
  2710. * 查询每日投币数量
  2711. */
  2712. get_account_exp: async function() {
  2713. return new Promise((resolve) => {
  2714. Ajax.get({
  2715. url: 'http://www.bilibili.com/plus/account/exp.php',
  2716. queryStringsObj: {
  2717.  
  2718. },
  2719. hasCookies: true,
  2720. success: responseText => {
  2721. let res = HNTOOL.strToJson(responseText);
  2722. if (res.code === 0) {
  2723.  
  2724. resolve(res.number);
  2725.  
  2726. } else {
  2727. console.log("查询每日投币数量失败:" + res.message);
  2728. resolve(false);
  2729. }
  2730. }
  2731. })
  2732. });
  2733. },
  2734. /**
  2735. * 查询每日奖励状态
  2736. */
  2737. get_exp_reward: async function() {
  2738. return new Promise((resolve) => {
  2739. Ajax.get({
  2740. url: BILIBLI_PATH.api + '/x/member/web/exp/reward',
  2741. queryStringsObj: {
  2742.  
  2743. },
  2744. hasCookies: true,
  2745. success: responseText => {
  2746. let res = HNTOOL.strToJson(responseText);
  2747. if (res.code === 0) {
  2748.  
  2749. resolve(res.data);
  2750.  
  2751. } else {
  2752. console.log("查询每日奖励状态失败:" + res.message);
  2753. resolve(false);
  2754. }
  2755. }
  2756. })
  2757. });
  2758. },
  2759.  
  2760. diary_upload: async function(activity_id, game_part) {
  2761. return new Promise((resolve) => {
  2762. Ajax.post({
  2763. url: "https://qcloud-sdkact-api.biligame.com/rabbit/diary/upload",
  2764. hasCookies: true,
  2765. dataType: 'application/x-www-form-urlencoded',
  2766. data: {
  2767. t: Math.round(new Date()),
  2768. activity_id: activity_id,
  2769. game_part: game_part
  2770. },
  2771. payload: '{"activity_id":"' + activity_id + '","game_part":' + game_part + '}',
  2772.  
  2773. success: responseText => {
  2774. let res = HNTOOL.strToJson(responseText);
  2775. if (res.code === 0) {
  2776. console.log("成功:");
  2777. resolve(true);
  2778. } else {
  2779. javaex.tip({
  2780. content: "错误!",
  2781. type: "error"
  2782. });
  2783. resolve(false);
  2784. }
  2785. }
  2786. })
  2787. });
  2788. },
  2789. lottery_draw: async function(activity_id) {
  2790. return new Promise((resolve) => {
  2791. Ajax.post({
  2792. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw",
  2793. hasCookies: true,
  2794. dataType: 'application/x-www-form-urlencoded',
  2795. data: {
  2796. t: Math.round(new Date()),
  2797. activity_id: activity_id,
  2798. },
  2799. payload: '{"activity_id":"' + activity_id + '","t":' + Math.round(new Date()) +
  2800. '}',
  2801.  
  2802. success: responseText => {
  2803. let res = HNTOOL.strToJson(responseText);
  2804. if (res.code === 0) {
  2805. console.log("成功");
  2806. resolve(true);
  2807. } else {
  2808. javaex.tip({
  2809. content: "错误!",
  2810. type: "error"
  2811. });
  2812. resolve(false);
  2813. }
  2814. }
  2815. })
  2816. });
  2817. },
  2818. lottery_record: async function(activity_id) {
  2819. return new Promise((resolve) => {
  2820. Ajax.get({
  2821. url: 'https://qcloud-sdkact-api.biligame.com/common/lottery/record',
  2822. queryStringsObj: {
  2823. t: Math.round(new Date()),
  2824. activity_id: activity_id,
  2825. },
  2826. hasCookies: true,
  2827. success: responseText => {
  2828. let res = HNTOOL.strToJson(responseText);
  2829. if (res.code === 0) {
  2830. let str = "";
  2831. for (let s of res.data) {
  2832. str += s.name
  2833. }
  2834.  
  2835. resolve(str);
  2836.  
  2837. } else {
  2838. console.log("查询每日奖励状态失败:" + res.message);
  2839. resolve(false);
  2840. }
  2841. }
  2842. })
  2843. });
  2844. },
  2845. get_draw_chance: async function(activity_id) {
  2846. return new Promise((resolve) => {
  2847. Ajax.get({
  2848. url: 'https://qcloud-sdkact-api.biligame.com/activity/lottery/get_draw_chance',
  2849. queryStringsObj: {
  2850. t: Math.round(new Date()),
  2851. activity_id: activity_id,
  2852. },
  2853. hasCookies: true,
  2854. success: responseText => {
  2855. let res = HNTOOL.strToJson(responseText);
  2856. if (res.code === 0) {
  2857.  
  2858. resolve(true);
  2859.  
  2860. } else {
  2861. console.log("查询每日奖励状态失败:" + res.message);
  2862. resolve(false);
  2863. }
  2864. }
  2865. })
  2866. });
  2867. },
  2868. /**
  2869. * 转发一个视频
  2870. * @param {Object} videoAid
  2871. * @param {Object} videoMid
  2872. * @param {Object} randomStr
  2873. */
  2874.  
  2875. shareOneVideo: async function(videoAid, videoMid, randomStr) {
  2876. return new Promise((resolve) => {
  2877. Ajax.post({
  2878. url: BILIBLI_PATH.vcapi + "/dynamic_repost/v1/dynamic_repost/share",
  2879. hasCookies: true,
  2880. dataType: 'application/x-www-form-urlencoded',
  2881. data: {
  2882.  
  2883. platform: "pc",
  2884. uid: videoMid,
  2885. type: 8,
  2886. content: randomStr,
  2887. repost_code: 20000,
  2888. rid: videoAid,
  2889. csrf: Live_info.csrf_token
  2890. },
  2891. success: responseText => {
  2892. let res = HNTOOL.strToJson(responseText);
  2893. if (res.code === 0) {
  2894. console.log("转发一个视频成功:" + res.data.dynamic_id);
  2895. resolve(true);
  2896. } else {
  2897. javaex.tip({
  2898. content: "转发一个视频错误!" + res.message,
  2899. type: "error"
  2900. });
  2901. resolve(false);
  2902. }
  2903. }
  2904. })
  2905. });
  2906. },
  2907.  
  2908. /**
  2909. * 批量关注和拉黑 batchModify
  2910. *
  2911. * https://api.bilibili.com/x/relation/batch/modify
  2912. * @param uid
  2913. */
  2914.  
  2915. /**
  2916. * 发布动态
  2917. * @param {Object} mid
  2918. */
  2919. batchModify: async function(uids, act) {
  2920. return new Promise((resolve) => {
  2921. Ajax.post({
  2922. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  2923. hasCookies: true,
  2924. dataType: 'application/x-www-form-urlencoded',
  2925. data: {
  2926.  
  2927. "fids": uids,
  2928. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  2929. "re_src": 222,
  2930. "csrf": Live_info.csrf_token,
  2931. },
  2932. success: responseText => {
  2933. let res = HNTOOL.strToJson(responseText);
  2934. if (res.code === 0) {
  2935.  
  2936. if (res.data.failed_fids.length > 0) {
  2937. console.log("关注失败:" + res.data.failed_fids);
  2938. resolve(false);
  2939. } else {
  2940. console.log("关注成功:" + uids);
  2941. resolve(true);
  2942. }
  2943.  
  2944.  
  2945. } else {
  2946. javaex.tip({
  2947. content: "批量关注错误!" + res.message,
  2948. type: "error"
  2949. });
  2950. resolve(false);
  2951. }
  2952. }
  2953. })
  2954. });
  2955. },
  2956.  
  2957. /**
  2958. * 发布动态
  2959. * @param {Object} mid
  2960. */
  2961. sendOneDynamic: async function(content) {
  2962. return new Promise((resolve) => {
  2963. Ajax.post({
  2964. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/create',
  2965. hasCookies: true,
  2966. dataType: 'application/x-www-form-urlencoded',
  2967. data: {
  2968. csrf: Live_info.csrf_token,
  2969. dynamic_id: 0,
  2970. type: 4,
  2971. dynamic_id: 0,
  2972. content: content,
  2973. extension: '{"emoji_type":1,"from":{"emoji_type":1},"flag_cfg":{}}'
  2974. },
  2975. hasCookies: true,
  2976. success: responseText => {
  2977. let res = HNTOOL.strToJson(responseText);
  2978. if (res.code === 0) {
  2979.  
  2980. console.log("随机发送一条动态:" + content);
  2981. resolve(true);
  2982.  
  2983. } else {
  2984. console.log("随机发送一条动态:" + res.message);
  2985. resolve(false);
  2986. }
  2987. }
  2988. })
  2989. });
  2990. },
  2991. /**
  2992. * @param {num} mid
  2993. * 用户详细信息2 (用于名片)
  2994. */
  2995. getInterfaceCard: async function(mid) {
  2996. return new Promise((resolve) => {
  2997. Ajax.get({
  2998. url: BILIBLI_PATH.api + '/x/web-interface/card',
  2999. queryStringsObj: {
  3000. "mid": mid
  3001. },
  3002.  
  3003. hasCookies: true,
  3004. success: responseText => {
  3005. let res = HNTOOL.strToJson(responseText);
  3006. if (res.code === 0) {
  3007.  
  3008. resolve(res.data.card);
  3009.  
  3010. } else {
  3011. console.log("获取用户详细信息失败:" + res.message);
  3012. resolve(false);
  3013. }
  3014. }
  3015. })
  3016. });
  3017. },
  3018.  
  3019.  
  3020. getLotteryNotice: async function(dynamic_id) {
  3021. return new Promise((resolve) => {
  3022. Ajax.get({
  3023. url: BILIBLI_PATH.vcapi + '/lottery_svr/v1/lottery_svr/lottery_notice',
  3024. queryStringsObj: {
  3025. "dynamic_id": dynamic_id
  3026. },
  3027. hasCookies: true,
  3028. success: responseText => {
  3029. let res = HNTOOL.strToJson(responseText);
  3030. if (res.code === 0) {
  3031.  
  3032. resolve(res.data);
  3033.  
  3034. } else {
  3035. console.log("获取开奖信息失败:" + res.message);
  3036. resolve(false);
  3037. }
  3038. }
  3039. })
  3040. });
  3041. },
  3042.  
  3043.  
  3044. likeDynamic: async function(dynamic_id) {
  3045.  
  3046. return new Promise((resolve) => {
  3047. Ajax.post({
  3048. url: BILIBLI_PATH.vcapi + '/dynamic_like/v1/dynamic_like/thumb',
  3049. hasCookies: true,
  3050. dataType: 'application/x-www-form-urlencoded',
  3051. data: {
  3052. uid: Live_info.uid,
  3053. dynamic_id: dynamic_id,
  3054. up: 1,
  3055. csrf: Live_info.csrf_token
  3056. },
  3057. success: responseText => {
  3058. let res = HNTOOL.strToJson(responseText);
  3059. if (res.code === 0) {
  3060.  
  3061. javaex.tip({
  3062. content: "动态点赞成功!",
  3063. type: "success"
  3064. });
  3065.  
  3066. resolve(true);
  3067. } else {
  3068.  
  3069. console.log("动态点赞发生错误!" + res.message);
  3070.  
  3071. javaex.tip({
  3072. content: "动态点赞发生错误!" + res.message,
  3073. type: "error"
  3074. });
  3075.  
  3076. resolve(false);
  3077. }
  3078. }
  3079. })
  3080. });
  3081. },
  3082.  
  3083. repostDynamic: async function(dynamic_id, content, ctrl) {
  3084.  
  3085. return new Promise((resolve) => {
  3086. Ajax.post({
  3087. url: BILIBLI_PATH.vcapi + '/dynamic_repost/v1/dynamic_repost/repost',
  3088. dataType: 'application/x-www-form-urlencoded',
  3089. hasCookies: true,
  3090. data: {
  3091. uid: Live_info.uid,
  3092. dynamic_id: dynamic_id,
  3093. content: content,
  3094. extension: '{"emoji_type":1}',
  3095. at_uids: "",
  3096. ctrl: ctrl == null || ctrl == "转发动态" ? "[]" : ctrl,
  3097. csrf_token: Live_info.csrf_token,
  3098. csrf: Live_info.csrf_token
  3099. },
  3100. success: responseText => {
  3101. let res = HNTOOL.strToJson(responseText);
  3102. if (res.code === 0) {
  3103.  
  3104. javaex.tip({
  3105. content: "动态转发成功!",
  3106. type: "success"
  3107. });
  3108.  
  3109. resolve(true);
  3110. } else {
  3111.  
  3112. console.log("动态转发发生错误!" + res.message);
  3113.  
  3114. javaex.tip({
  3115. content: "动态转发发生错误!" + res.message,
  3116. type: "error"
  3117. });
  3118.  
  3119. resolve(false);
  3120. }
  3121. }
  3122. })
  3123. });
  3124. },
  3125.  
  3126. addReply: async function(oid, type) {
  3127.  
  3128. return new Promise((resolve) => {
  3129. Ajax.post({
  3130. url: BILIBLI_PATH.api + '/x/v2/reply/add',
  3131. dataType: 'application/x-www-form-urlencoded',
  3132. hasCookies: true,
  3133. data: {
  3134. "oid": oid,
  3135. "type": type, //11官方 17 加码
  3136. "ordering": 'heat',
  3137. "message": HNTOOL.getRandomWordOfList(replyList) == undefined ? "不错[鼓掌]" :
  3138. HNTOOL.getRandomWordOfList(
  3139. replyList),
  3140. "jsonp": 'jsonp',
  3141. "csrf": Live_info.csrf_token
  3142. },
  3143. success: responseText => {
  3144. let res = HNTOOL.strToJson(responseText);
  3145. if (res.code === 0) {
  3146. javaex.tip({
  3147. content: "'自动评论成功'!",
  3148. type: "success"
  3149. });
  3150. resolve(0);
  3151. } else if (res.code === -404) {
  3152. console.log('自动评论原动态已删除');
  3153. resolve(0);
  3154. } else if (res.code === 12002) {
  3155. console.log('自动评论评论区已关闭');
  3156. resolve(0);
  3157. } else if (res.code === 12015) {
  3158. console.log('自动评论需要输入验证码');
  3159. resolve(1);
  3160. } else {
  3161. console.log('自动评论', `评论失败\n${responseText}`);
  3162. resolve(0);
  3163. }
  3164. }
  3165. })
  3166. });
  3167. },
  3168.  
  3169.  
  3170. setNotice: async function(notice) {
  3171.  
  3172. return new Promise((resolve) => {
  3173. Ajax.post({
  3174. url: BILIBLI_PATH.api + '/x/space/notice/set',
  3175. hasCookies: true,
  3176. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3177. data: {
  3178. notice: notice,
  3179. jsonp: 'jsonp',
  3180. csrf: Live_info.csrf_token
  3181. },
  3182. success: responseText => {
  3183. let res = HNTOOL.strToJson(responseText);
  3184. if (res.code === 0) {
  3185.  
  3186. javaex.tip({
  3187. content: "动态标记保存到个人公告成功!",
  3188. type: "success"
  3189. });
  3190.  
  3191. resolve(true);
  3192. } else {
  3193.  
  3194. javaex.tip({
  3195. content: res.message,
  3196. type: "error"
  3197. });
  3198.  
  3199. resolve(false);
  3200. }
  3201. }
  3202. })
  3203. });
  3204. },
  3205.  
  3206. getSpaceNotice: async function() {
  3207. return new Promise((resolve) => {
  3208. Ajax.get({
  3209. url: BILIBLI_PATH.api + '/x/space/notice',
  3210. queryStringsObj: {
  3211. "mid": Live_info.uid
  3212. },
  3213. hasCookies: true,
  3214. success: responseText => {
  3215. let res = HNTOOL.strToJson(responseText);
  3216. if (res.code === 0) {
  3217.  
  3218. resolve(res.data);
  3219.  
  3220. } else {
  3221. console.log("获取公告信息失败:" + res.message);
  3222. resolve(false);
  3223. }
  3224. }
  3225. })
  3226. });
  3227. },
  3228.  
  3229. getdynamicData: async function(dynamic_id_str) {
  3230. return new Promise((resolve) => {
  3231. Ajax.get({
  3232.  
  3233. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
  3234. queryStringsObj: {
  3235. "dynamic_id": dynamic_id_str
  3236. },
  3237. hasCookies: true,
  3238. success: responseText => {
  3239. let res = HNTOOL.strToJson(responseText);
  3240. if (res.code === 0) {
  3241.  
  3242. resolve(res.data);
  3243.  
  3244. } else {
  3245. console.log("获取动态信息失败:" + res.message);
  3246. resolve(false);
  3247. }
  3248. }
  3249. })
  3250. });
  3251. },
  3252.  
  3253. getAllFollow: async function() {
  3254. return new Promise((resolve) => {
  3255. Ajax.get({
  3256.  
  3257. url: BILIBLI_PATH.vcapi + '/feed/v1/feed/get_attention_list',
  3258. queryStringsObj: {
  3259. "uid": Live_info.uid
  3260. },
  3261. hasCookies: true,
  3262. success: responseText => {
  3263. let res = HNTOOL.strToJson(responseText);
  3264. if (res.code === 0) {
  3265.  
  3266. resolve(res.data.list);
  3267.  
  3268. } else {
  3269. console.log("查询失败!" + res.message);
  3270. resolve(false);
  3271. }
  3272. }
  3273. })
  3274. });
  3275. },
  3276.  
  3277. getCardByUID: async function(UID) {
  3278. return new Promise((resolve) => {
  3279. Ajax.get({
  3280.  
  3281. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3282. queryStringsObj: {
  3283. "mid": UID
  3284. },
  3285. hasCookies: true,
  3286. success: responseText => {
  3287. let res = HNTOOL.strToJson(responseText);
  3288. if (res.code === 0) {
  3289.  
  3290. resolve(res.data.card);
  3291.  
  3292. } else {
  3293. console.log("查询失败!" + res.message);
  3294. resolve(false);
  3295. }
  3296. }
  3297. })
  3298. });
  3299. },
  3300.  
  3301.  
  3302. /**
  3303. *
  3304. *
  3305. */
  3306.  
  3307. getTodayDynamicList: async function(mid, index) {
  3308. return new Promise((resolve) => {
  3309. Ajax.get({
  3310.  
  3311. url: BILIBLI_PATH.api + '/x/space/article',
  3312. queryStringsObj: {
  3313. "mid": mid,
  3314. "pn": 1,
  3315. "ps": 12,
  3316. "sort": 'publish_time'
  3317. },
  3318. hasCookies: true,
  3319. success: responseText => {
  3320. let res = HNTOOL.strToJson(responseText);
  3321. if (res.code === 0) {
  3322. let artlist = false;
  3323. let articlesList = [];
  3324. let articles = res.data.articles;
  3325. for (var i = 0, len = articles.length; i < index; i++) {
  3326. articlesList[i] = articles[i];
  3327. }
  3328.  
  3329. resolve(articlesList);
  3330. } else {
  3331.  
  3332.  
  3333. console.log("查询失败!" + res.message);
  3334. resolve(false);
  3335. }
  3336. }
  3337. })
  3338. });
  3339. },
  3340.  
  3341. getDataByLiveSid: async function(ids) {
  3342. return new Promise((resolve) => {
  3343. Ajax.get({
  3344.  
  3345. url: BILIBLI_PATH.api + '/x/activity/up/reserve/relation/info',
  3346. queryStringsObj: {
  3347. "ids": ids
  3348. },
  3349. hasCookies: true,
  3350. success: responseText => {
  3351. let res = HNTOOL.strToJson(responseText);
  3352. if (res.code === 0 && Object.keys(res.data.list).length != 0) {
  3353.  
  3354. resolve(res.data.list);
  3355. } else {
  3356.  
  3357. /* javaex.tip({
  3358. content: "查询失败!" + res.message,
  3359. type: "error"
  3360. }); */
  3361. console.log("查询失败!" + res.message);
  3362.  
  3363. resolve(false);
  3364. }
  3365. }
  3366. })
  3367. });
  3368. },
  3369.  
  3370. /**
  3371. * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
  3372. */
  3373. clickNow: async function() {
  3374. return new Promise((resolve) => {
  3375. Ajax.get({
  3376.  
  3377. url: BILIBLI_PATH.api + '/x/report/click/now',
  3378. queryStringsObj: {
  3379. jsonp: "jsonp"
  3380. },
  3381. hasCookies: true,
  3382. success: responseText => {
  3383. let res = HNTOOL.strToJson(responseText);
  3384. if (res.code === 0) {
  3385.  
  3386. javaex.tip({
  3387. content: "每日登录" + res.data.text,
  3388. type: "success"
  3389. });
  3390. resolve(true);
  3391.  
  3392. } else {
  3393.  
  3394. javaex.tip({
  3395. content: res.message,
  3396. type: "error"
  3397. });
  3398.  
  3399. resolve(false);
  3400. }
  3401. }
  3402. })
  3403. });
  3404. },
  3405.  
  3406. /**
  3407. * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
  3408. * @param {number} videoAid
  3409. */
  3410. addShare: async function(videoAid) {
  3411. return new Promise((resolve) => {
  3412. Ajax.post({
  3413. url: BILIBLI_PATH.api + '/x/web-interface/share/add',
  3414. hasCookies: true,
  3415. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3416. data: {
  3417. aid: videoAid,
  3418. csrf: Live_info.csrf_token
  3419. },
  3420. success: responseText => {
  3421. let res = HNTOOL.strToJson(responseText);
  3422. if (res.code === 0) {
  3423.  
  3424. javaex.tip({
  3425. content: "每日分享视频成功",
  3426. type: "success"
  3427. });
  3428.  
  3429. resolve(true);
  3430. } else {
  3431.  
  3432. javaex.tip({
  3433. content: res.message,
  3434. type: "error"
  3435. });
  3436.  
  3437. resolve(false);
  3438. }
  3439. }
  3440. })
  3441. });
  3442. },
  3443.  
  3444.  
  3445.  
  3446. /**
  3447. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  3448. * @param {number} videoAid
  3449. */
  3450. addArticleCoin: async function(cvID, mid) {
  3451. return new Promise((resolve) => {
  3452. Ajax.post({
  3453. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  3454. hasCookies: true,
  3455. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3456. data: {
  3457. aid: cvID,
  3458. upid: mid,
  3459. multiply: 2,
  3460. avtype: 2,
  3461. csrf: Live_info.csrf_token
  3462. },
  3463. success: responseText => {
  3464. let res = HNTOOL.strToJson(responseText);
  3465. if (res.code === 0) {
  3466.  
  3467. javaex.tip({
  3468. content: '专栏:' + cvID + "投币成功",
  3469. type: "success"
  3470. });
  3471.  
  3472. resolve(true);
  3473. } else {
  3474.  
  3475. javaex.tip({
  3476. content: res.message,
  3477. type: "error"
  3478. });
  3479.  
  3480. console.log('专栏投币失败:' + cvID + res.message);
  3481.  
  3482. resolve(false);
  3483. }
  3484. }
  3485. })
  3486. });
  3487. },
  3488.  
  3489. /**
  3490. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  3491. * @param {number} videoAid
  3492. */
  3493. addVideoCoin: async function(videoAid) {
  3494. return new Promise((resolve) => {
  3495. Ajax.post({
  3496. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  3497. hasCookies: true,
  3498. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3499. data: {
  3500. aid: videoAid,
  3501. multiply: 2,
  3502. select_like: 0,
  3503. cross_domain: true,
  3504. csrf: Live_info.csrf_token
  3505. },
  3506. success: responseText => {
  3507. let res = HNTOOL.strToJson(responseText);
  3508. if (res.code === 0) {
  3509.  
  3510. javaex.tip({
  3511. content: "投币成功",
  3512. type: "success"
  3513. });
  3514.  
  3515. resolve(true);
  3516. } else {
  3517.  
  3518. javaex.tip({
  3519. content: res.message,
  3520. type: "error"
  3521. });
  3522.  
  3523. resolve(false);
  3524. }
  3525. }
  3526. })
  3527. });
  3528. },
  3529.  
  3530.  
  3531. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  3532.  
  3533. DoSign: async function() {
  3534. return new Promise((resolve) => {
  3535. Ajax.get({
  3536.  
  3537. url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
  3538. queryStringsObj: {
  3539.  
  3540. },
  3541. hasCookies: true,
  3542. success: responseText => {
  3543. let res = HNTOOL.strToJson(responseText);
  3544. if (res.code === 0) {
  3545.  
  3546. javaex.tip({
  3547. content: "签到成功:" + res.data.text,
  3548. type: "success"
  3549. });
  3550. resolve(true);
  3551.  
  3552. } else if (res.code === 1011040) {
  3553.  
  3554. javaex.tip({
  3555. content: res.message,
  3556. type: "success"
  3557. });
  3558.  
  3559. resolve(true);
  3560. } else {
  3561.  
  3562. javaex.tip({
  3563. content: res.message,
  3564. type: "error"
  3565. });
  3566.  
  3567. resolve(false);
  3568. }
  3569. }
  3570. })
  3571. });
  3572. },
  3573.  
  3574.  
  3575. /**
  3576. * // 获取分区最新专栏列表 https://api.bilibili.com/x/article/recommends?cid=0&pn=1
  3577. */
  3578. getArticleRecommends: async function() {
  3579. return new Promise((resolve) => {
  3580. Ajax.get({
  3581.  
  3582. url: BILIBLI_PATH.api + '/x/article/recommends',
  3583. queryStringsObj: {
  3584. "cid": 0,
  3585. "pn": 1
  3586. },
  3587. hasCookies: true,
  3588. success: responseText => {
  3589. let res = HNTOOL.strToJson(responseText);
  3590. if (res.code === 0) {
  3591.  
  3592. javaex.tip({
  3593. content: "获取最新专栏成功!",
  3594. type: "success"
  3595. });
  3596. resolve(res.data);
  3597.  
  3598. } else {
  3599.  
  3600. javaex.tip({
  3601. content: "获取最新专栏失败!" + res.message,
  3602. type: "error"
  3603. });
  3604.  
  3605. console.log(res.message);
  3606.  
  3607. resolve(false);
  3608. }
  3609. }
  3610. })
  3611. });
  3612. },
  3613. /**
  3614. * // 获取分区最新视频列表
  3615. */
  3616. getDynamicRegion: async function() {
  3617. return new Promise((resolve) => {
  3618. Ajax.get({
  3619.  
  3620. url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
  3621. queryStringsObj: {
  3622. "pn": 1,
  3623. "ps": 20,
  3624. "rid": 21
  3625. },
  3626. hasCookies: true,
  3627. success: responseText => {
  3628. let res = HNTOOL.strToJson(responseText);
  3629. if (res.code === 0) {
  3630.  
  3631. javaex.tip({
  3632. content: "获取分区最新视频成功",
  3633. type: "success"
  3634. });
  3635. resolve(res.data.archives);
  3636.  
  3637. } else {
  3638.  
  3639. javaex.tip({
  3640. content: "获取分区最新视频失败" + res.message,
  3641. type: "error"
  3642. });
  3643.  
  3644. resolve(false);
  3645. }
  3646. }
  3647. })
  3648. });
  3649. },
  3650.  
  3651. /*
  3652. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  3653. * @param {Object} sid
  3654. */
  3655. reserveActivity: async function(sid) {
  3656. return new Promise((resolve) => {
  3657. Ajax.post({
  3658. url: BILIBLI_PATH.api + '/x/space/reserve',
  3659. hasCookies: true,
  3660. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3661. data: {
  3662. sid: sid, //当前用户
  3663. jsonp: "jsonp",
  3664. csrf: Live_info.csrf_token
  3665. },
  3666. success: responseText => {
  3667. let res = HNTOOL.strToJson(responseText);
  3668. if (res.code === 0) {
  3669.  
  3670. resolve(true);
  3671. } else {
  3672. javaex.tip({
  3673. content: res.message,
  3674. type: "error"
  3675. });
  3676. resolve(false);
  3677. }
  3678. }
  3679. })
  3680. });
  3681. },
  3682. /**
  3683. reserveActivity: async function(sid, reserve_total) {
  3684. return new Promise((resolve) => {
  3685. Ajax.post({
  3686. url: BILIBLI_PATH.vcapi + '/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
  3687. hasCookies: true,
  3688. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3689. data: {
  3690. reserve_id: sid,
  3691. cur_btn_status: 1,
  3692. reserve_total: reserve_total,
  3693. csrf: Live_info.csrf_token
  3694. },
  3695. success: responseText => {
  3696. let res = HNTOOL.strToJson(responseText);
  3697. if (res.code === 0) {
  3698. resolve(res.data);
  3699. } else {
  3700. javaex.tip({
  3701. content: res.message,
  3702. type: "error"
  3703. });
  3704. resolve(false);
  3705. }
  3706. }
  3707. })
  3708. });
  3709. }, */
  3710.  
  3711. getGiftList: async function(room) {
  3712. return new Promise((resolve) => {
  3713. Ajax.get({
  3714.  
  3715. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  3716. queryStringsObj: {
  3717. "room_id": room
  3718. },
  3719. hasCookies: true,
  3720. success: responseText => {
  3721. let res = HNTOOL.strToJson(responseText);
  3722. if (res.code === 0) {
  3723.  
  3724. resolve(res.data.list);
  3725. } else {
  3726.  
  3727. javaex.tip({
  3728. content: "查询包裹失败!" + res.message,
  3729. type: "error"
  3730. });
  3731.  
  3732. resolve(false)
  3733. }
  3734. }
  3735. })
  3736. });
  3737. },
  3738.  
  3739. /**
  3740. * 送银B克拉
  3741. * @param {Object} ruid
  3742. * @param {Object} roomid
  3743. */
  3744. bagSendGift: async function(ruid, roomid, bag_id) {
  3745. return new Promise((resolve) => {
  3746. Ajax.post({
  3747. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  3748. hasCookies: true,
  3749. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3750. data: {
  3751. uid: Live_info.uid, //当前用户
  3752. gift_id: 3,
  3753. ruid: ruid,
  3754. send_ruid: 0,
  3755. gift_num: 1,
  3756. bag_id: bag_id,
  3757. //rnd: Math.round(new Date() / 1000); //时间戳,
  3758. platform: 'pc',
  3759. biz_code: 'Live',
  3760. biz_id: roomid,
  3761. storm_beat_id: 0,
  3762. price: 0,
  3763. csrf_token: Live_info.csrf_token,
  3764. csrf: Live_info.csrf_token
  3765.  
  3766. },
  3767. success: responseText => {
  3768. let res = HNTOOL.strToJson(responseText);
  3769. if (res.code === 0) {
  3770.  
  3771. javaex.tip({
  3772. content: roomid + "赠送b克拉成功!" + res.message,
  3773. type: "success"
  3774. });
  3775.  
  3776. resolve(true);
  3777. } else {
  3778.  
  3779. javaex.tip({
  3780. content: res.message,
  3781. type: "error"
  3782. });
  3783.  
  3784. resolve(false);
  3785. }
  3786. }
  3787. })
  3788. });
  3789. },
  3790.  
  3791.  
  3792. /**
  3793. * 判断是否有勋章
  3794. * @param {Object} uid
  3795. * @param {Object} room
  3796. */
  3797.  
  3798. getFansMedalInfo: async function(uid, room) {
  3799. return new Promise((resolve) => {
  3800. Ajax.get({
  3801.  
  3802. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  3803. queryStringsObj: {
  3804. "target_id": uid,
  3805. "room_id": room
  3806. },
  3807. //dataType:'application/json, text/plain, */*',
  3808. hasCookies: true,
  3809. success: responseText => {
  3810. let res = HNTOOL.strToJson(responseText);
  3811. if (res.code === 0) {
  3812.  
  3813. if (res.data.my_fans_medal.level == 0) {
  3814. resolve(false)
  3815. } else {
  3816. resolve(true)
  3817. }
  3818.  
  3819. } else {
  3820.  
  3821. javaex.tip({
  3822. content: "查询勋章失败!" + res.message,
  3823. type: "error"
  3824. });
  3825.  
  3826. resolve(false)
  3827. }
  3828. }
  3829. })
  3830. });
  3831. },
  3832.  
  3833.  
  3834.  
  3835.  
  3836. getDisuidList: async function(re_version, pn) {
  3837. return new Promise((resolve) => {
  3838. Ajax.get({
  3839.  
  3840. url: BILIBLI_PATH.api + '/x/relation/blacks',
  3841. queryStringsObj: {
  3842. "re_version": re_version,
  3843. "pn": pn
  3844. },
  3845. hasCookies: true,
  3846. success: responseText => {
  3847. let res = HNTOOL.strToJson(responseText);
  3848. if (res.code === 0) {
  3849. resolve(res.data.list)
  3850. } else {
  3851.  
  3852. javaex.tip({
  3853. content: "查询黑名单失败!" + res.message,
  3854. type: "error"
  3855. });
  3856.  
  3857. resolve(null)
  3858. }
  3859. }
  3860. })
  3861. });
  3862. },
  3863.  
  3864. /**
  3865. * @param {Object} uid
  3866. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  3867. */
  3868. cancelAtt: async function(uid, act, re_src) {
  3869. return new Promise((resolve) => {
  3870. Ajax.post({
  3871. url: BILIBLI_PATH.api + '/x/relation/modify',
  3872. hasCookies: true,
  3873. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3874. data: {
  3875. fid: uid,
  3876. act: act,
  3877. re_src: re_src == undefined ? 11 : 116,
  3878. jsonp: "jsonp",
  3879. csrf: Live_info.csrf_token,
  3880. },
  3881. success: responseText => {
  3882. let res = HNTOOL.strToJson(responseText);
  3883. if (res.code === 0) {
  3884.  
  3885. //HNAPI.cancelAtt(uid, 6);
  3886.  
  3887. javaex.tip({
  3888. content: "取关成功!" + res.message,
  3889. type: "success"
  3890. });
  3891.  
  3892. resolve(true);
  3893. } else if (res.code === 22003) {
  3894.  
  3895. HNAPI.cancelAtt(uid, 6);
  3896.  
  3897. javaex.tip({
  3898. content: "取消拉黑" + res.message,
  3899. type: "success"
  3900. });
  3901. resolve(true);
  3902. } else {
  3903.  
  3904. javaex.tip({
  3905. content: res.message,
  3906. type: "error"
  3907. });
  3908.  
  3909. resolve(false);
  3910. }
  3911. }
  3912. })
  3913. });
  3914. },
  3915.  
  3916. getRoomMsg: async function(roomid) {
  3917. return new Promise((resolve) => {
  3918. Ajax.get({
  3919.  
  3920. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  3921. queryStringsObj: {
  3922. "roomid": roomid
  3923. },
  3924. hasCookies: true,
  3925. success: responseText => {
  3926. let res = HNTOOL.strToJson(responseText);
  3927. if (res.code === 0) {
  3928. resolve(res.data.info.uid)
  3929. } else {
  3930. resolve(false)
  3931. }
  3932. }
  3933. })
  3934. });
  3935. },
  3936.  
  3937. /**
  3938. *
  3939. * @param sid
  3940. * @returns {Promise<unknown>}
  3941. */
  3942. lotteryDo: async function(sid, name) {
  3943. return new Promise((resolve) => {
  3944. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/do';
  3945. if (sid.indexOf("newLottery") != -1) {
  3946. func_url = BILIBLI_PATH.api + "/x/lottery/do";
  3947. }
  3948. Ajax.post({
  3949. url: func_url,
  3950. hasCookies: true,
  3951. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3952. data: {
  3953.  
  3954. sid: sid,
  3955. type: 1,
  3956. csrf: Live_info.csrf_token,
  3957. },
  3958. success: responseText => {
  3959. let res = HNTOOL.strToJson(responseText);
  3960. if (res.code === 0) {
  3961. HNTOOL.console("活动转盘:" + name + "\n " + (res.data)[0].gift_name);
  3962. resolve((res.data)[0].gift_name);
  3963.  
  3964. } else if (res.code ===
  3965. 75400) { // || res.code === 75003 || res.code === 75403
  3966.  
  3967. resolve(true);
  3968. } else {
  3969. javaex.tip({
  3970. content: "本次抽奖失败!" + res.message,
  3971. type: "error"
  3972. });
  3973. resolve(false);
  3974. }
  3975. }
  3976. })
  3977. });
  3978. },
  3979.  
  3980.  
  3981. getLotteryMytimes: async function(sid) {
  3982. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/mytimes';
  3983. if (sid.indexOf("newLottery") != -1) {
  3984. func_url = BILIBLI_PATH.api + "/x/lottery/mytimes";
  3985. }
  3986. return new Promise((resolve) => {
  3987. Ajax.get({
  3988. url: func_url,
  3989. queryStringsObj: {
  3990. sid: sid
  3991. },
  3992. hasCookies: true,
  3993. success: responseText => {
  3994. let res = HNTOOL.strToJson(responseText);
  3995. if (res.code === 0) {
  3996. resolve(res.data.times)
  3997. } else {
  3998. resolve(0)
  3999. }
  4000. }
  4001. })
  4002. });
  4003. },
  4004.  
  4005. /**
  4006. * 增加抽奖次数一般是分享
  4007. * @param sid 活动sid
  4008. * @returns {Promise<unknown>} 0 成功 1:活动结束
  4009. */
  4010. addLotteryTimes: async function(sid) {
  4011. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/addtimes';
  4012. if (sid.indexOf("newLottery") != -1) {
  4013. func_url = BILIBLI_PATH.api + "/x/lottery/addtimes";
  4014. }
  4015.  
  4016. return new Promise((resolve) => {
  4017. Ajax.post({
  4018. url: func_url,
  4019. hasCookies: true,
  4020. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4021. data: {
  4022.  
  4023. sid: sid,
  4024. action_type: 3,
  4025. csrf: Live_info.csrf_token,
  4026. },
  4027. success: responseText => {
  4028. let res = HNTOOL.strToJson(responseText);
  4029. if (res.code === 0) {
  4030.  
  4031. resolve(0)
  4032. } else if (res.code === 75003 || res.code === 170405 || res.code ===
  4033. 75001 || res.code === 170001 || res.code === 75405) {
  4034.  
  4035. resolve(1)
  4036.  
  4037. } else {
  4038.  
  4039. resolve(res.message);
  4040. }
  4041. }
  4042. })
  4043. });
  4044. },
  4045. /**
  4046. * 查询用户关注 默认一次查询50
  4047. * @param vmid 用户uid
  4048. * @param pn 页码
  4049. * @returns {Promise<unknown>}
  4050. */
  4051. getMyFollow: async function(vmid, pn) {
  4052. return new Promise((resolve) => {
  4053. Ajax.get({
  4054. url: BILIBLI_PATH.api + '/x/relation/followings',
  4055. queryStringsObj: {
  4056. vmid: vmid,
  4057. pn: pn
  4058. },
  4059. hasCookies: true,
  4060. success: responseText => {
  4061. let res = HNTOOL.strToJson(responseText);
  4062. if (res.code === 0) {
  4063. resolve(res.data)
  4064. } else {
  4065. resolve(null)
  4066. }
  4067. }
  4068. })
  4069. });
  4070. },
  4071.  
  4072.  
  4073. getMyinfo: function() {
  4074. return new Promise((resolve) => {
  4075. Ajax.get({
  4076. url: BILIBLI_PATH.api + '/x/space/myinfo',
  4077. queryStringsObj: {},
  4078. hasCookies: true,
  4079. success: responseText => {
  4080. let res = HNTOOL.strToJson(responseText);
  4081. if (res.code === 0) {
  4082. resolve(res.data)
  4083. } else {
  4084. resolve(null)
  4085. }
  4086. }
  4087. })
  4088. });
  4089. },
  4090.  
  4091. getMyJson: function(url) {
  4092. return new Promise((resolve) => {
  4093. GM_xmlhttpRequest({
  4094. method: "GET",
  4095. url: url,
  4096. onload: function(response) {
  4097. const res = HNTOOL.strToJson((response || {}).responseText)
  4098. resolve(res);
  4099. }
  4100. });
  4101. })
  4102. },
  4103.  
  4104.  
  4105. userInfo: function(mid) {
  4106.  
  4107. Ajax.get({
  4108. url: BILIBLI_PATH.api + '/x/space/acc/info',
  4109. queryStringsObj: {
  4110. mid: mid
  4111. },
  4112. hasCookies: true,
  4113. success: responseText => {
  4114.  
  4115. var json = JSON.parse(responseText);
  4116.  
  4117. if (json.code != 0) {
  4118.  
  4119.  
  4120. }
  4121. }
  4122. });
  4123.  
  4124. },
  4125.  
  4126. sendQmsg: async function(key, msg) {
  4127.  
  4128. $.ajax({
  4129. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  4130.  
  4131. success: function(result) {
  4132.  
  4133. }
  4134. });
  4135.  
  4136.  
  4137. /*GM_xmlhttpRequest({
  4138. method: "GET",
  4139. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  4140. onload: function (response) {
  4141. let json = JSON.parse(response.response);
  4142. if (json.code == 0) {
  4143. javaex.tip({
  4144. content: "自动动态中奖提醒成功!" + json.reason,
  4145. type: "success"
  4146. });
  4147. } else {
  4148. console.log("自动动态中奖提醒失败!" + json.reason);
  4149. javaex.tip({
  4150. content: "自动动态中奖提醒失败!" + json.reason,
  4151. type: "error"
  4152. });
  4153. }
  4154. }
  4155. });*/
  4156.  
  4157. },
  4158.  
  4159. /**
  4160. * //https://api.bilibili.com/x/relation/modify
  4161. *
  4162. * @param UID
  4163. */
  4164. disUserByUid: function(vmid) {
  4165.  
  4166. Ajax.post({
  4167. url: BILIBLI_PATH.api + '/x/relation/modify',
  4168. data: {
  4169. fid: parseInt(vmid),
  4170. re_src: 11,
  4171. act: 5,
  4172. jsonp: "jsonp",
  4173. csrf: Live_info.csrf_token,
  4174. },
  4175. hasCookies: true,
  4176. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4177. success: responseText => {
  4178.  
  4179. var json = JSON.parse(responseText);
  4180.  
  4181. if (json.code != 0) {
  4182.  
  4183. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  4184. javaex.tip({
  4185. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  4186. type: "error"
  4187. });
  4188.  
  4189. } else {
  4190. console.log("拉黑用户成功 uid:" + vmid);
  4191. javaex.tip({
  4192. content: "拉黑用户成功 uid:" + vmid,
  4193. type: "success"
  4194. });
  4195. }
  4196. }
  4197. });
  4198.  
  4199. },
  4200. /**
  4201. * http://api.bilibili.com/x/web-interface/view
  4202. * @param BV
  4203. * 心跳间隔15秒
  4204. */
  4205. watchOneVideo: function(BV, MID) {
  4206.  
  4207. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  4208. Ajax.post({
  4209. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  4210. hasCookies: true,
  4211. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4212. data: {
  4213.  
  4214. "bvid": BV,
  4215. "part": 1,
  4216. "mid": Live_info.uid,
  4217. "lv": 2,
  4218. "jsonp": "jsonp",
  4219. "type": 3,
  4220. "sub_type": 0
  4221. },
  4222. success: responseText => {
  4223.  
  4224. let json = JSON.parse(responseText);
  4225.  
  4226. if (/^{"code":0/.test(responseText)) {
  4227. //发送一次心跳
  4228. HNAPI.sendHeartbeat(BV, MID);
  4229.  
  4230. } else {
  4231. javaex.tip({
  4232. content: "视频" + data.bvid + "播放失败!" + json.message,
  4233. type: "error"
  4234. });
  4235. }
  4236. }
  4237. })
  4238.  
  4239.  
  4240. },
  4241.  
  4242. //上报视频播放心跳(web端)
  4243. /**
  4244. * http://api.bilibili.com/x/click-interface/web/heartbeat
  4245. * @param json
  4246. */
  4247. sendHeartbeat: function(bvid, MID) {
  4248.  
  4249. Ajax.post({
  4250. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  4251. hasCookies: true,
  4252. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4253. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  4254. data: {
  4255. "bvid": bvid,
  4256. "type": 3,
  4257. "dt": 2,
  4258. "played_time": HNTOOL.random(12, 40),
  4259. "realtime": HNTOOL.random(12, 40),
  4260. "play_type": 0
  4261. },
  4262. success: responseText => {
  4263.  
  4264. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  4265.  
  4266. javaex.tip({
  4267. content: "视频BV" + bvid + "播放一次!",
  4268. type: "success"
  4269. });
  4270. }
  4271. }
  4272. })
  4273.  
  4274. },
  4275.  
  4276. //获取up所有投稿视频
  4277. /**
  4278. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  4279. * @param mid
  4280. */
  4281. getUpAllBV: function(mid, pn, ps) {
  4282. ps = (ps === undefined ? 30 : ps); // a默认值为1
  4283. Ajax.get({
  4284. url: BILIBLI_PATH.api + '/x/space/arc/search',
  4285. queryStringsObj: {
  4286. mid: mid,
  4287. tid: 0,
  4288. order: 'pubdate',
  4289. jsonp: 'jsonp',
  4290. pn: pn,
  4291. ps: ps
  4292. },
  4293. hasCookies: true,
  4294. success: responseText => {
  4295.  
  4296. var json = JSON.parse(responseText);
  4297.  
  4298. if (json.code != 0) {
  4299.  
  4300. javaex.tip({
  4301. content: "获取up所有投稿视频失败!" + json.message,
  4302. type: "success"
  4303. });
  4304.  
  4305. } else {
  4306. BiliData.BVList = json.data.list.vlist;
  4307.  
  4308. }
  4309. }
  4310. });
  4311.  
  4312. },
  4313.  
  4314.  
  4315. /**
  4316. *
  4317. * @param path
  4318. * @param data
  4319. * @param saveObj
  4320. * @param Func
  4321. */
  4322. publicGet: function(path, queryStringsObj) {
  4323.  
  4324. if (typeof(queryStringsObj) != "undefined") {
  4325. queryStringsObj = {};
  4326. }
  4327. Ajax.get({
  4328. url: BILIBLI_PATH.api + path,
  4329. queryStringsObj: queryStringsObj,
  4330. hasCookies: true,
  4331. success: responseText => {
  4332.  
  4333. let json = JSON.parse(responseText);
  4334. if (chackCode(json.code) && json.code == 0) {
  4335.  
  4336. return json.data;
  4337. }
  4338.  
  4339. return false;
  4340.  
  4341. }
  4342. })
  4343.  
  4344. },
  4345.  
  4346. /**
  4347. * 导航栏用户信息
  4348. */
  4349. getUserNav: async function() {
  4350.  
  4351. GM_xmlhttpRequest({
  4352. method: "GET",
  4353. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  4354. //timeout:3000,
  4355. onload: function(response) {
  4356.  
  4357. let json = JSON.parse(response.response);
  4358. console.log(json);
  4359. BiliData.login_code = json.code;
  4360. BiliData.login_message = json.message;
  4361. BiliData.LoginData = json.data;
  4362.  
  4363. }
  4364. });
  4365.  
  4366. },
  4367.  
  4368. /**
  4369. * 获取某up详细信息
  4370. * http://api.bilibili.com/x/web-interface/card
  4371. */
  4372. getUpCard: function(mid) {
  4373.  
  4374. Ajax.get({
  4375. url: BILIBLI_PATH.api + '/x/web-interface/card',
  4376. queryStringsObj: {
  4377. mid: mid,
  4378. photo: false
  4379. },
  4380. hasCookies: true,
  4381. success: responseText => {
  4382.  
  4383. var json = JSON.parse(responseText);
  4384.  
  4385. if (json.code != 0) {
  4386.  
  4387. javaex.tip({
  4388. content: "查询失败!" + json.message,
  4389. type: "success"
  4390. });
  4391. return false;
  4392. } else {
  4393. BiliData.upCard = json;
  4394.  
  4395. }
  4396.  
  4397.  
  4398. }
  4399. })
  4400.  
  4401. },
  4402.  
  4403. /**
  4404. *
  4405. * @param uid 用户uid
  4406. * @param ps 每页视频个数 默认30个
  4407. * @param pn 第几页
  4408. */
  4409. getUpAllVideo: function(uid, ps, pn) {
  4410.  
  4411. },
  4412. getChallenge: async function() {
  4413.  
  4414.  
  4415. },
  4416. /**
  4417. * 硬币记录
  4418. * @returns {Promise<void>}
  4419. */
  4420. getCoinLog: async function() {
  4421.  
  4422. GM_xmlhttpRequest({
  4423. method: "GET",
  4424. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  4425. //url: "http://api.bilibili.com/x/member/web/coin/log",
  4426. onload: function(response) {
  4427.  
  4428. let json = JSON.parse(response.response);
  4429. if (json.code == 0) {
  4430.  
  4431. console.log("硬币记录" + json);
  4432. BiliData.CoinLog = json.data;
  4433.  
  4434. return true;
  4435. }
  4436.  
  4437. }
  4438. });
  4439. },
  4440. /**
  4441. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  4442. * @returns {Promise<void>}
  4443. */
  4444. getUnread: async function() {
  4445.  
  4446. Ajax.get({
  4447. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  4448. hasCookies: true,
  4449. success: responseText => {
  4450.  
  4451. let json = JSON.parse(responseText);
  4452. if (chackCode(json.code) && json.code == 0) {
  4453.  
  4454. BiliData.Unread = json.data;
  4455. showUnreadMsg();
  4456. }
  4457.  
  4458. return false;
  4459.  
  4460. }
  4461. })
  4462.  
  4463. /* GM_xmlhttpRequest({
  4464. method: "GET",
  4465. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  4466. onload: function (response) {
  4467. let json = JSON.parse(response.response);
  4468. if (chackCode(json.code) && json.code == 0) {
  4469. BiliData.Unread = json.code;
  4470. showUnreadMsg();
  4471. }
  4472. }
  4473. });*/
  4474. },
  4475. /**
  4476. *
  4477. * @param type reply:回复我的 at @我的
  4478. */
  4479. getMsgfeed: function(type) {
  4480. Ajax.get({
  4481. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  4482. queryStringsObj: {
  4483. build: 0,
  4484. mobi_app: 'web'
  4485. },
  4486. hasCookies: true,
  4487. success: responseText => {
  4488.  
  4489. var json = JSON.parse(responseText);
  4490.  
  4491. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  4492. return false;
  4493. } else {
  4494. chackAtMsg(json.data.items);
  4495.  
  4496. return true;
  4497. }
  4498.  
  4499.  
  4500. }
  4501. })
  4502.  
  4503. },
  4504.  
  4505. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  4506. * @returns {Promise<void>}
  4507. */
  4508. getUnrewad: async function() {
  4509.  
  4510. GM_xmlhttpRequest({
  4511. method: "GET",
  4512. data: {
  4513. "mid": 99439379,
  4514. "pn": 1,
  4515. "ps": 5,
  4516. },
  4517. url: BILIBLI_PATH.api + "/x/space/arc/search",
  4518. onload: function(response) {
  4519.  
  4520. let json = JSON.parse(response.response);
  4521. if (json.code == 0) {
  4522.  
  4523. BiliData.Video = json.data;
  4524. console.log("未读消息数" + json);
  4525. }
  4526.  
  4527. }
  4528. });
  4529. },
  4530.  
  4531. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  4532. * @param {number} oid
  4533. * @param {nbumber} rpid
  4534. * @param {number} action
  4535. * @returns {Promise<void>}
  4536. * type: 11
  4537. * ordering: heat
  4538. * jsonp: jsonp
  4539. * csrf: 54a******* CSRF Token(位于cookie)
  4540. */
  4541.  
  4542. likeInDynamicComments: async function(latestDynamic) {
  4543.  
  4544.  
  4545. Ajax.post({
  4546. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  4547. hasCookies: true,
  4548. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4549. data: {
  4550. "oid": oid,
  4551. "type": 11,
  4552. "rpid": rpid,
  4553. "action": action,
  4554. "ordering": "heat",
  4555. "jsonp": "jsonp",
  4556. "csrf": Live_info.csrf_token,
  4557. },
  4558. success: responseText => {
  4559.  
  4560. if (/^{"code":0/.test(responseText)) {
  4561.  
  4562. BiliData.replyAction = JSON.parse(responseText);
  4563. console.log("点赞成功!" + responseText);
  4564. }
  4565. }
  4566. })
  4567.  
  4568. }
  4569.  
  4570.  
  4571. }
  4572.  
  4573. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  4574. var http_request = null;
  4575.  
  4576. function send_request(url, method) {}
  4577.  
  4578. let HNTOOL = {
  4579. /**
  4580. * 判断是否为整数类型方式
  4581. * @param {Object} obj
  4582. */
  4583. isInteger: function(obj) {
  4584.  
  4585. return obj % 1 === 0
  4586.  
  4587. },
  4588.  
  4589. jury_case: async function() {
  4590.  
  4591. for (let i = 0; i < 30; i++) {
  4592.  
  4593. //1.获取题号
  4594. let case_id = await HNAPI.jury_case_next();
  4595. await HNTOOL.Sleep(1000);
  4596. if (case_id == false) {
  4597. break;
  4598. }
  4599. //2.获取该题号详情
  4600. let vote = await HNAPI.jury_case_info(case_id);
  4601. await HNTOOL.Sleep(4 * 1000);
  4602. if (vote == false) {
  4603. break;
  4604. }
  4605. let opinion = await HNAPI.jury_case_opinion(case_id);
  4606. await HNTOOL.Sleep(15 * 1000);
  4607. //3.开始答题
  4608. let result = await HNAPI.jury_vote(case_id, vote, 1);
  4609. if (result) {
  4610. HNTOOL.console("第" + (i + 1) + "个案号:" + case_id + "完成!");
  4611. } else {
  4612. alert(result);
  4613. }
  4614. let case_id3 = await HNAPI.jury_case_next();
  4615.  
  4616. }
  4617.  
  4618. },
  4619. console: function(str, color, type) {
  4620. if (color != undefined) {
  4621. console.log(javaex.now() + "\n" + "%c " + str, "color:#"+color+";font-weight:bold;");
  4622. } else {
  4623. console.log(javaex.now() + "\n" + "%c " + str, "color:#005500;font-weight:bold;");
  4624. }
  4625.  
  4626.  
  4627. javaex.tip({
  4628. content: str,
  4629. type: type == undefined || type == "success" ? "success" : type
  4630. });
  4631.  
  4632. },
  4633.  
  4634. doOneDynamic: async function(randomtime) {
  4635.  
  4636. var myVar = setInterval(async function() {
  4637.  
  4638. let randomStr = await HNTOOL.getRandomString();
  4639. await HNAPI.sendOneDynamic(randomStr);
  4640.  
  4641. }, randomtime);
  4642. },
  4643.  
  4644. getRandomString: function() {
  4645.  
  4646. return new Promise((resolve) => {
  4647. Ajax.get({
  4648. url: "https://api.mcloc.cn/love/",
  4649. //url: 'https://api.mcloc.cn/words/?type=json',//随机一个句子
  4650. //url: 'https://interface.meiriyiwen.com/article/random?dev=1',//随机一个句子
  4651. queryStringsObj: {
  4652. type: "json"
  4653. },
  4654. dataType: "text/html; charset=UTF-8",
  4655. hasCookies: false,
  4656. success: responseText => {
  4657.  
  4658. try {
  4659. let res = HNTOOL.strToJson(responseText);
  4660. resolve(res.data); //随机一句情话
  4661. //resolve(body.data+"---"+body.creator);//随机一个句子
  4662. //resolve(body.data.digest);//随机一个句子
  4663. } catch (e) {
  4664.  
  4665. resolve("你的名字,是我见过最短的情诗。"); //随机一句情话
  4666. }
  4667.  
  4668.  
  4669. }
  4670. })
  4671. });
  4672. },
  4673.  
  4674. getLatestDynamic: async function() {
  4675.  
  4676. let latestDynamic = await HNAPI.getTodayDynamicList(226257459, 3);
  4677. await HNTOOL.Sleep(1000);
  4678. let ldList = [];
  4679. let ldList2 = [];
  4680. for (let ld1 of latestDynamic) {
  4681.  
  4682. let ld = await HNTOOL.getDynamicIdList(ld1);
  4683. await HNTOOL.Sleep(1000);
  4684. ldList = ldList.concat(ld);
  4685. }
  4686.  
  4687. let latestDynamic2 = await HNAPI.getTodayDynamicList(2295698, 2);
  4688. await HNTOOL.Sleep(1000);
  4689.  
  4690. for (let ld2 of latestDynamic) {
  4691.  
  4692. let ld = await HNTOOL.getDynamicIdList(ld2);
  4693. await HNTOOL.Sleep(1000);
  4694. ldList2 = ldList2.concat(ld);
  4695. }
  4696. ldList.push.apply(ldList, ldList2);
  4697.  
  4698. let result = HNTOOL.arrUnique(ldList, false);
  4699.  
  4700. return result;
  4701.  
  4702. },
  4703.  
  4704. getDynamicIdList: async function(latestDynamic) {
  4705.  
  4706.  
  4707.  
  4708. return new Promise((resolve) => {
  4709. Ajax.get({
  4710. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  4711. queryStringsObj: {
  4712.  
  4713. },
  4714. dataType: "text/html; charset=utf-8",
  4715. hasCookies: true,
  4716. success: responseText => {
  4717. let datalist = HNTOOL.httpString(responseText);
  4718. let dls;
  4719. let returnlist = [];
  4720. if (datalist != undefined && datalist.length > 0) {
  4721. for (let dl of datalist) {
  4722.  
  4723. let len = dl.indexOf("?");
  4724. if (len == -1) {
  4725. dl += "?tab=2";
  4726. }
  4727. dls = dl.substring(dl.indexOf("?") - 18, dl.indexOf("?"));
  4728. if (dls == false ||
  4729. dls == null ||
  4730. dl.indexOf("read") > -1 ||
  4731. dl.indexOf("html") > -1 ||
  4732. dl.indexOf("pixiv") > -1 ||
  4733. returnlist.indexOf(dls) > -1) {
  4734. continue;
  4735. }
  4736.  
  4737. returnlist.push(dls);
  4738.  
  4739. }
  4740.  
  4741. resolve(HNTOOL.arrUnique(returnlist, false));
  4742. } else {
  4743. resolve(false);
  4744. }
  4745. }
  4746. })
  4747. });
  4748. },
  4749.  
  4750. httpString: function(s) {
  4751. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  4752. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  4753. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4754. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4755. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  4756. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  4757. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  4758. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  4759. s = s.match(reg);
  4760. console.log(s)
  4761. return (s)
  4762. },
  4763.  
  4764. saveConfig: function() {
  4765.  
  4766. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  4767. /* javaex.tip({
  4768. content: "配置保存成功!",
  4769. type: "success"
  4770. }); */
  4771.  
  4772. },
  4773.  
  4774. copyText: function(domId) {
  4775. let btn = document.getElementById(domId);
  4776. btn.select();
  4777. if (document.execCommand('copy')) {
  4778. document.execCommand('copy');
  4779. javaex.tip({
  4780. content: "复制成功!",
  4781. type: "success"
  4782. });
  4783. }
  4784.  
  4785. },
  4786. /**
  4787. * s数组去重并排序
  4788. */
  4789.  
  4790. arrUnique: function(ary, isSort) {
  4791.  
  4792. if (isSort == undefined) {
  4793. isSort = true
  4794. }
  4795. let obj = {};
  4796. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  4797. let item = ary[i]
  4798. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  4799. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  4800. // 如果没有 将这个元素添加到对象中
  4801. if (isSort) {
  4802. ary.sort((a, b) => {
  4803. return a - b
  4804. }) // 数组去重后 按升序排列
  4805. }
  4806.  
  4807. obj = null;
  4808.  
  4809. javaex.tip({
  4810. content: "已去重!",
  4811. type: "success"
  4812. });
  4813. return ary;
  4814.  
  4815. },
  4816.  
  4817. split_array: function(arr, len) {
  4818.  
  4819. let arr_length = arr.length;
  4820. let newArr = [];
  4821. for (let i = 0; i < arr_length; i += len) {
  4822. newArr.push(arr.slice(i, i + len));
  4823. }
  4824. return newArr;
  4825. },
  4826. strToJson: function(params) {
  4827. const isJSON = (str => {
  4828. if (typeof str === 'string') {
  4829. try {
  4830. const obj = JSON.parse(str);
  4831. return typeof obj === 'object' ? obj : false
  4832. } catch (_) {
  4833. console.log(str);
  4834. return false;
  4835. }
  4836. } else {
  4837. console.log(`${str}\nIt is not a string!`);
  4838. return false;
  4839. }
  4840. })(params);
  4841. return isJSON ? isJSON : {}
  4842. },
  4843.  
  4844. chackAtMsg: function() {
  4845.  
  4846. let config = HNTOOL.getConfig();
  4847. if (config.qmsg_checked == true && config.qmsg_key) {
  4848.  
  4849. document.getElementById("getAtMsg").click();
  4850.  
  4851. }
  4852.  
  4853. },
  4854.  
  4855. cssChecked: function(id, dom) {
  4856.  
  4857. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  4858.  
  4859.  
  4860. },
  4861. getConfig: function() {
  4862.  
  4863. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  4864.  
  4865. if (CONFIG == null) {
  4866. CONFIG = HN_SETUP_CONFIG;
  4867. }
  4868.  
  4869. return CONFIG;
  4870. },
  4871.  
  4872. /**
  4873. * 获取cookie 中某个键对应的值
  4874. * @param name
  4875. */
  4876.  
  4877. getCookie: function(name) {
  4878. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  4879. if (arr != null) return escape(arr[2]);
  4880. return false;
  4881. },
  4882. /**
  4883. * 得到一个字符串数组的中随机一个
  4884. * @param {List} list
  4885. */
  4886.  
  4887.  
  4888. getRandomWordOfList: function(list) {
  4889. var L = list.length;
  4890. var i = Math.ceil(Math.random() * (L - 1));
  4891.  
  4892. return list[i];
  4893. },
  4894. random: function(min, max) {
  4895.  
  4896. return Math.floor(Math.random() * (max - min)) + min;
  4897. },
  4898.  
  4899. Sleep: function(ms) {
  4900. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  4901. }
  4902.  
  4903. }
  4904.  
  4905. let errorMsg = {
  4906. "-1": "应用程序不存在或已被封禁!",
  4907. "-2": "Access Key错误!",
  4908. "-3": "API校验密匙错误!",
  4909. "-4": "调用方对该Method没有权限!",
  4910. "-101": "账号未登录!",
  4911. "-102": "账号被封停!",
  4912. "-103": "积分不足!",
  4913. "-104": "硬币不足!",
  4914. "-105": "验证码错误!",
  4915. "-106": "账号非正式会员或在适应期!",
  4916. "-107": "应用不存在或者被封禁!",
  4917. "-108": "未绑定手机!",
  4918. "-109": "未知!",
  4919. "-110": "未绑定手机!",
  4920. "-111": "csrf 校验失败!",
  4921. "-112": "系统升级中!",
  4922. "-113": "账号尚未实名认证!",
  4923. "-114": "请先绑定手机!",
  4924. "-115": "请先完成实名认证!",
  4925. "-304": "木有改动!",
  4926. "-307": "撞车跳转!",
  4927. "-400": "请求错误!",
  4928. "-401": "未认证!",
  4929. "-403": "访问权限不足!",
  4930. "-404": "啥都木有!",
  4931. }
  4932.  
  4933. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  4934. /**
  4935. *
  4936. * @param code
  4937. * @constructor
  4938. */
  4939. let chackCode = function(code) {
  4940.  
  4941. let emsg = errorMsg[code + ""];
  4942. if (emsg != null) {
  4943. javaex.tip({
  4944. content: emsg,
  4945. type: "error"
  4946. });
  4947.  
  4948. return false;
  4949. }
  4950.  
  4951. return true;
  4952. }
  4953.  
  4954.  
  4955. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  4956. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  4957.  
  4958. /*window.onbeforeunload = function() {
  4959. if (!canLeavePage()) {
  4960. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  4961. }
  4962. };*/
  4963.  
  4964.  
  4965. /**
  4966. * Ajax请求对象
  4967. */
  4968. const Ajax = (() => {
  4969. /**
  4970. * 检查options是否符合要求
  4971. * @param {object} options
  4972. * @returns {boolean}
  4973. */
  4974. function checkOptions(options) {
  4975. let result = false;
  4976. if (typeof options !== 'object') {
  4977. console.warn('类型错误: typeof Options !== Object');
  4978. return result;
  4979. } else {
  4980. if (typeof options.url !== 'string') {
  4981. console.warn('类型错误: typeof Link !== Strings');
  4982. return result;
  4983. } else {
  4984. const reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  4985. //const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  4986. if (!reg.test(options.url)) {
  4987. console.warn('url字符串须为完整http链接');
  4988. return result;
  4989. }
  4990. result = true;
  4991. }
  4992. }
  4993. return result;
  4994. }
  4995.  
  4996. /**
  4997. * 对象转URL编码
  4998. * @param {object} data
  4999. */
  5000. function objToURLCode(data) {
  5001. var _result = [];
  5002. for (var key in data) {
  5003. var value = data[key];
  5004. if (value instanceof Array) {
  5005. value.forEach(function(_value) {
  5006. _result.push(key + "=" + _value);
  5007. });
  5008. } else {
  5009. _result.push(key + '=' + value);
  5010. }
  5011. }
  5012. return _result.join('&');
  5013. }
  5014.  
  5015. /**
  5016. * 请求
  5017. * @param {string} method
  5018. * @param {object} options
  5019. */
  5020. function request(method, options) {
  5021. if (checkOptions(options)) {
  5022. let xhr = new XMLHttpRequest();
  5023. const {
  5024. url: _url,
  5025. queryStringsObj,
  5026. data,
  5027. dataType,
  5028. payload,
  5029. hasCookies
  5030. } = options, url = typeof queryStringsObj === 'object' ?
  5031. _url + '?' + objToURLCode(queryStringsObj) : _url;
  5032. switch (method) {
  5033. case 'GET':
  5034. xhr.open("GET", url);
  5035. break;
  5036. case 'POST':
  5037. xhr.open("POST", url);
  5038. xhr.setRequestHeader('Content-Type', dataType);
  5039. //xhr.setRequestHeader('Accept-Encoding', "Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
  5040. break;
  5041. default:
  5042. break;
  5043. }
  5044. if (hasCookies) xhr.withCredentials = true;
  5045. xhr.timeout = 3000;
  5046. xhr.addEventListener('load', () => {
  5047. if (xhr.status === 200) {
  5048. options.success(xhr.responseText)
  5049. } else {
  5050. console.error(`status:${xhr.status}`);
  5051. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  5052. }
  5053. })
  5054. xhr.addEventListener('error', () => {
  5055. console.error('ajax请求出错')
  5056. options.success('{"code":-1,"msg":"ajax请求出错"}');
  5057. })
  5058. xhr.addEventListener('timeout', () => {
  5059. console.error('请求超时')
  5060. options.success('{"code":-1,"msg":"请求超时"}');
  5061. })
  5062. switch (method) {
  5063. case 'GET':
  5064. xhr.send()
  5065. break;
  5066. case 'POST':
  5067. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  5068. //xhr.send(payload);
  5069. break;
  5070. default:
  5071. break;
  5072. }
  5073. }
  5074. }
  5075.  
  5076. return {
  5077. /**
  5078. * 发送Get请求
  5079. * @param {Object} options
  5080. */
  5081. get(options) {
  5082. request("GET", options);
  5083. },
  5084. /**
  5085. * 发送Post请求
  5086. * @param {object} options
  5087. */
  5088. post(options) {
  5089. request("POST", options);
  5090. }
  5091. }
  5092. })()