-哔哩猫-(试用版)

练手

当前为 2022-01-26 提交的版本,查看 最新版本

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