-哔哩猫-(试用版)

练手

目前為 2021-12-22 提交的版本,檢視 最新版本

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