-哔哩猫-(试用版)

练手

目前为 2022-01-27 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/422731/1012986/-%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.32
  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. let default_sid = null;
  1768. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1769. if (lastSid == null) {
  1770.  
  1771. let myjson = await HNAPI.getMyJson("https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/bilicat_config.json");
  1772. default_sid = myjson.default_sid;
  1773. }else{
  1774. default_sid = lastSid.split("&")[1];
  1775. }
  1776.  
  1777. for(var j = default_sid; j < (parseInt(default_sid) +300000); j++) {
  1778.  
  1779. default_sid_list.push(j);
  1780. }
  1781.  
  1782. let sid_Lists = HNTOOL.split_array(default_sid_list, 1000);
  1783. let cat = 1;
  1784. for (const sid of sid_Lists) {
  1785.  
  1786. let submitData = {
  1787. "ids": sid.toString()
  1788. }
  1789. let sidinfolist = await HNAPI.baseGet(
  1790. "https://api.bilibili.com/x/activity/up/reserve/relation/info",
  1791. submitData);
  1792. await HNTOOL.Sleep(1000);
  1793. if(sidinfolist == false){
  1794. continue;
  1795. }
  1796. let sdl = sidinfolist.data.list;
  1797. if(JSON.stringify(sdl) == "{}"){
  1798. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + (sid[0]-1000);
  1799. HNTOOL.saveConfig();
  1800. alert("预约结束");
  1801. break;
  1802. }
  1803. for (const sidinfo in sdl) {
  1804. let siddata = sdl[sidinfo];
  1805.  
  1806. if( Math.round(new Date() / 1000) < siddata.livePlanStartTime && siddata.type == 2 && siddata.lotteryType != 0 && siddata.reserveRecordCtime == 0 && siddata.state == 100){
  1807.  
  1808. await HNAPI.reserveActivity(sidinfo);
  1809.  
  1810. let tiplog = "\n --预约开始:" + javaex.dateFormat(siddata.livePlanStartTime,'yyyy-MM-dd HH:mm:ss') +
  1811. "\n --预约SID:" + siddata.sid +
  1812. "\n --预约人数:" + siddata.total + "人" +
  1813. "\n --预约奖品:" + siddata.prizeInfo.text;
  1814.  
  1815. console.log(tiplog);
  1816.  
  1817. javaex.tip({
  1818. content: tiplog,
  1819. type: "success"
  1820. });
  1821. await HNTOOL.Sleep(1000);
  1822. }
  1823. }
  1824. javaex.tip({
  1825. content: "查询预约活动中!",
  1826. type: "success"
  1827. });
  1828. }
  1829.  
  1830.  
  1831. });
  1832.  
  1833.  
  1834. /** $("#reserveActivity").bind("click", async function() {
  1835.  
  1836.  
  1837. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSids.json";
  1838. let myjson = await HNAPI.getMyJson(url);
  1839.  
  1840. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1841. if (typeof(lastSid) == "undefined") {
  1842. lastSid = HN_SETUP_CONFIG.Booking_last_sid;
  1843. }
  1844. lastSid = lastSid.split("&")[1];
  1845.  
  1846.  
  1847.  
  1848. for (const sid in myjson) {
  1849.  
  1850. if (parseInt(lastSid) >= parseInt(sid)) {
  1851.  
  1852. continue;
  1853. }
  1854.  
  1855. let siddata = myjson[sid];
  1856. //let sidList = await HNAPI.getDataByLiveSid(sid);
  1857. //await HNTOOL.Sleep(2000);
  1858.  
  1859. //let returnData = await HNAPI.reserveActivity(sid, sidList[sid].total);
  1860. await HNAPI.reserveActivity(sid);
  1861. await HNTOOL.Sleep(2000);
  1862.  
  1863. let tiplog = "\n --预约开始:" + javaex.dateFormat(siddata.livePlanStartTime,
  1864. 'yyyy-MM-dd HH:mm:ss') +
  1865. //"\n --预约SID:" + siddata.sid +
  1866. //"\n --预约UID:" + siddata.upmid +
  1867. //"\n --预约地址:" + siddata.prizeInfo.jumpUrl +
  1868. "\n --预约人数:" + siddata.total + "人" +
  1869. "\n --预约奖品:" + siddata.prizeInfo.text;
  1870.  
  1871. console.log(tiplog);
  1872.  
  1873. javaex.tip({
  1874. content: tiplog,
  1875. type: "success"
  1876. });
  1877.  
  1878. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + sid;
  1879.  
  1880. HNTOOL.saveConfig();
  1881.  
  1882. }
  1883.  
  1884.  
  1885. alert("预约抽奖结束");
  1886. });
  1887.  
  1888. $("#liveActivity").bind("click", async function() {
  1889.  
  1890. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1891. let myjson = await HNAPI.getMyJson(url);
  1892.  
  1893. });
  1894. **/
  1895.  
  1896. /* $("#linshiActivity3").bind("click", async function() {
  1897.  
  1898. let open_capsule_by_id = {
  1899. 'activity_id': '5709481937914112'
  1900. };
  1901.  
  1902. let share = await HNAPI.basePost(
  1903. "https://qcloud-sdkact-api.biligame.com/yuanshen/lottery/share?t=" + Math.round(
  1904. new Date()) + "&activity_id=5709481937914112",
  1905. open_capsule_by_id);
  1906. await HNTOOL.Sleep(1000);
  1907. if (share.success) {
  1908.  
  1909.  
  1910. let open_capsule_by_id2 = {
  1911. 'activity_id': '5709481937914112',
  1912. 'platform': 'web',
  1913. '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'
  1914. };
  1915.  
  1916. let draw = await HNAPI.basePost(
  1917. "https://qcloud-sdkact-api.biligame.com/yuanshen/lottery/draw?t=" + Math.round(
  1918. new Date()) +
  1919. "&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",
  1920. open_capsule_by_id2);
  1921.  
  1922. await HNTOOL.Sleep(2000);
  1923. alert(draw.data.name);
  1924. } else {
  1925. alert("无次数!!!");
  1926. }
  1927.  
  1928.  
  1929.  
  1930. }); */
  1931.  
  1932. /* $("#linshiActivity2").bind("click", async function() {
  1933.  
  1934. let open_capsule_by_id = {
  1935. 'areaids': 1,
  1936. 'csrf_token': Live_info.csrf_token,
  1937. 'csrf': Live_info.csrf_token,
  1938. 'visit_id': ''
  1939. };
  1940.  
  1941. await HNAPI.basePost(
  1942. "https://api.live.bilibili.com/xlive/activity-interface/v2/spec-act/bls21-area/BlsLifeSubArea",
  1943. open_capsule_by_id);
  1944.  
  1945. await HNAPI.basePost(
  1946. "https://api.live.bilibili.com/xlive/activity-interface/v2/spec-act/bls21-area/BlsLifeSubList", {}
  1947. );
  1948. await HNTOOL.Sleep(5000);
  1949.  
  1950. let open_capsule_by_id2 = {
  1951. 'id': 313,
  1952. 'count': 1,
  1953. 'platform': 'web',
  1954. 'csrf_token': Live_info.csrf_token,
  1955. 'csrf': Live_info.csrf_token,
  1956. 'visit_id': '',
  1957. '_': Math.round(new Date()),
  1958. };
  1959.  
  1960. let open_capsule = await HNAPI.basePost(
  1961. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  1962. open_capsule_by_id2);
  1963.  
  1964. if (open_capsule.err) {
  1965. alert(open_capsule.err);
  1966. }
  1967.  
  1968. let awards = (open_capsule.data.awards)[0];
  1969. alert(awards.gift_value + awards.text);
  1970.  
  1971.  
  1972.  
  1973. }); */
  1974.  
  1975. $("#linshiActivity").bind("click", async function() {
  1976.  
  1977. let html = '';
  1978. html += '<div class="javaex-panel-box" style="width: 600px;">';
  1979. html += ' <div class="javaex-unit clear">';
  1980. html += ' </div>';
  1981. html += ' <div class="javaex-unit clear tc" >';
  1982. html += ' <input type="button" id="linshi1" class="javaex-btn yes" value="临时1" />';
  1983. html += ' <input type="button" id="linshi2" class="javaex-btn yes" value="临时2" />';
  1984. html += ' </div>';
  1985. html += '</div>';
  1986.  
  1987. javaex.panel(this, {
  1988. position: "right",
  1989. content: html
  1990. });
  1991.  
  1992. $("#linshi1,#linshi2").bind("click", async function() {
  1993.  
  1994. alert("暂无");
  1995. });
  1996. });
  1997.  
  1998.  
  1999. $("#jury_case").bind("click", async function() {
  2000.  
  2001. let bln = window.confirm('是否立即执行?【确定:只会执行一次】;【取消:0:10(5H)】;');
  2002.  
  2003. if (bln) {
  2004. HNTOOL.console("风纪开始!")
  2005. HNTOOL.jury_case();
  2006. } else {
  2007. for (var i = 0; i < 1; i--) {
  2008.  
  2009. let now = new Date();
  2010. let hour = now.getHours();
  2011. let minu = now.getMinutes();
  2012. HNTOOL.console("风纪运行中……");
  2013.  
  2014. if ((hour == 0 || HNTOOL.isInteger(hour / 6)) && minu == 10) {
  2015. HNTOOL.console("风纪开始到达预定时间开始执行!")
  2016. HNTOOL.jury_case();
  2017. }
  2018.  
  2019. await HNTOOL.Sleep(50000);
  2020. }
  2021. }
  2022.  
  2023. });
  2024.  
  2025. $("#plateActivity").bind("click", async function() {
  2026.  
  2027. //获取轮盘数据
  2028.  
  2029. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  2030. let myjson = await HNAPI.getMyJson(url);
  2031. let lmt = 0;
  2032. let k = 20; //重试次数 防止卡主
  2033. let giftArr = [];
  2034. let endAtion = [];
  2035.  
  2036. javaex.tip({
  2037. content: "开始参加轮盘!!!",
  2038. type: "success"
  2039. });
  2040.  
  2041. await HNAPI.getUserNav();
  2042. await HNTOOL.Sleep(1500);
  2043.  
  2044.  
  2045. for (const json of myjson.acriviries_type1) {
  2046. //let x = json.name;
  2047. for (let i = 0; i < 10; i++) {
  2048. //1.结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  2049. let resout = await HNAPI.addLotteryTimes(json.sid);
  2050.  
  2051. await HNTOOL.Sleep(200);
  2052. if (resout == 1) {
  2053.  
  2054. endAtion.push(json.name + ":活动已结束!");
  2055. javaex.tip({
  2056. content: json.name + "活动已结束!",
  2057. type: "success"
  2058. });
  2059.  
  2060. break;
  2061. }
  2062. if (resout != 0 && resout != 1) {
  2063.  
  2064. javaex.tip({
  2065. content: json.name + resout,
  2066. type: "error"
  2067. });
  2068.  
  2069. break;
  2070. }
  2071.  
  2072. if (resout == 0) {
  2073. //2.查询次数
  2074. lmt = await HNAPI.getLotteryMytimes(json.sid);
  2075. continue;
  2076. }
  2077.  
  2078. }
  2079.  
  2080. javaex.tip({
  2081. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  2082. type: "success"
  2083. });
  2084.  
  2085. await HNTOOL.Sleep(1000);
  2086.  
  2087. for (let i = 0; i < lmt; i++) {
  2088. //3、执行抽奖
  2089. let gift = await HNAPI.lotteryDo(json.sid, json.name);
  2090.  
  2091. if (gift == true) {
  2092. javaex.tip({
  2093. content: "点击过快,9秒后自动重试!!!",
  2094. type: "error"
  2095. });
  2096. i--;
  2097. k--;
  2098. }
  2099.  
  2100. if (gift == false || k == 0) {
  2101. break;
  2102. }
  2103.  
  2104. if (gift != "未中奖0" && gift != true) {
  2105. giftArr.push(json.name + "奖品为:" + gift + "\n");
  2106.  
  2107. break;
  2108. } else {
  2109. javaex.tip({
  2110. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  2111. type: "success"
  2112. });
  2113. }
  2114. await HNTOOL.Sleep(6000);
  2115.  
  2116. }
  2117.  
  2118.  
  2119. }
  2120.  
  2121. for (const json2 of myjson.acriviries_type2) {
  2122.  
  2123. let submitData1 = {
  2124. "act_id": json2.act_id,
  2125. "share_type": 1,
  2126. "visit_id": "",
  2127. "csrf_token": Live_info.csrf_token,
  2128. "csrf": Live_info.csrf_token,
  2129. }
  2130.  
  2131. let submitReul1 = await HNAPI.basePost(
  2132. "https://api.live.bilibili.com/xlive/activity-interface/v1/task/UserShare", submitData1);
  2133. await HNTOOL.Sleep(1000);
  2134.  
  2135. let submitData2 = {
  2136. "act_id": json2.act_id
  2137. }
  2138. let submitReul2 = await HNAPI.baseGet(
  2139. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/info",
  2140. submitData2);
  2141. await HNTOOL.Sleep(1000);
  2142.  
  2143. let task = submitReul2.data.task_list[0];
  2144. if (task) {
  2145. let submitData3 = {
  2146. "act_id": json2.act_id,
  2147. "task_id": task.task_id,
  2148. "cycle_id": task.task_cycle_id,
  2149. "level_id": 1,
  2150. "visit_id": "",
  2151. "csrf_token": Live_info.csrf_token,
  2152. "csrf": Live_info.csrf_token,
  2153. }
  2154.  
  2155. await HNAPI.basePost(
  2156. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/getaward",
  2157. submitData3);
  2158. await HNTOOL.Sleep(3000);
  2159.  
  2160. await HNAPI.baseGet(
  2161. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/info",
  2162. submitData2);
  2163. await HNTOOL.Sleep(1000);
  2164.  
  2165. let submitData4 = {
  2166. "id": json2.id,
  2167. "count": 1,
  2168. "platform": "web",
  2169. "_": Math.round(new Date()),
  2170. "visit_id": "",
  2171. "csrf_token": Live_info.csrf_token,
  2172. "csrf": Live_info.csrf_token,
  2173. }
  2174.  
  2175. let submitReul4 = await HNAPI.basePost(
  2176. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  2177. submitData4);
  2178. await HNTOOL.Sleep(1000);
  2179. if (submitReul4 == false) {
  2180. HNTOOL.console(json2.act_id + ":失败!");
  2181. continue;
  2182. }
  2183. if (submitReul4.err != undefined) {
  2184.  
  2185. HNTOOL.console("直播转盘:" + json2.act_id + ":" + submitReul4.err);
  2186. continue;
  2187. }
  2188. HNTOOL.console("直播转盘:" + json2.act_id + ":" + submitReul4.data.text[0]);
  2189.  
  2190. giftArr.push("直播转盘:" + json2.act_id + ":" + submitReul4.data.text[0] + "\n");
  2191. }
  2192.  
  2193.  
  2194. }
  2195.  
  2196.  
  2197. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:\n` + (
  2198. giftArr.length == 0 ? "未中奖" : giftArr.toString()));
  2199.  
  2200. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `\n 中奖详情:` + (giftArr.length == 0 ? "未中奖" : giftArr
  2201. .toString()));
  2202.  
  2203.  
  2204. });
  2205.  
  2206. $("#addPlay").bind("click", async function() {
  2207.  
  2208.  
  2209. let html = '';
  2210.  
  2211. html += '<div style="padding: 10px 10px 10px 0px;">'
  2212. html += '<form id="getUpMassage_form">'
  2213.  
  2214. html += ' <div class="javaex-unit clear">'
  2215. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  2216. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  2217. html +=
  2218. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  2219. html +=
  2220. ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  2221. html += ' </div>'
  2222. html += ' </div>'
  2223. html += ' <div class="javaex-unit clear">'
  2224. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  2225. html +=
  2226. ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  2227. html +=
  2228. ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  2229. html +=
  2230. ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  2231. html += ' </div>'
  2232. html += ' </div>'
  2233. html += '</form>';
  2234. html += ' <div class="javaex-unit clear tc">'
  2235. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  2236. html += ' </div>'
  2237. html += '<hr class="javaex-divider"></hr>';
  2238. html += '</div>';
  2239.  
  2240.  
  2241. javaex.panel(this, {
  2242. position: "right",
  2243. content: html
  2244. });
  2245.  
  2246. $("#addPlay_bgn").click(async function() {
  2247.  
  2248. let MID = javaex.getSelectVal("#addPlay_uid")
  2249. let BV = javaex.getSelectVal("#addPlay_bv");
  2250. let bvArr = [];
  2251. let bvArr2 = [];
  2252.  
  2253. MID = javaex.ifnull(MID, BiliData.author_uid);
  2254.  
  2255.  
  2256. if (BV == "0") {
  2257.  
  2258. //1.查询up所有视频BV号 2.发送心跳间隔2s
  2259. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  2260. await HNTOOL.Sleep(500);
  2261. bvArr2 = BiliData.BVList;
  2262.  
  2263. for (let i = 1; i > 0; i++) {
  2264.  
  2265. HNAPI.getUpAllBV(MID, i);
  2266.  
  2267. await HNTOOL.Sleep(500);
  2268.  
  2269. if (BiliData.BVList.length == 0) {
  2270. if (bvArr.length == 0) {
  2271. javaex.tip({
  2272. content: "该用户无投稿视频,请确认是否有误!",
  2273. type: "success"
  2274. });
  2275. await HNTOOL.Sleep(2000);
  2276. }
  2277. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  2278. bvArr = bvArr.concat(bvArr2);
  2279. break;
  2280. }
  2281.  
  2282. bvArr = bvArr.concat(BiliData.BVList);
  2283. }
  2284.  
  2285.  
  2286. if (bvArr.length != 0) {
  2287.  
  2288. for (const emt of bvArr) {
  2289.  
  2290. HNAPI.playOneVideo(emt.bvid, MID);
  2291.  
  2292. await HNTOOL.Sleep(2000);
  2293.  
  2294. }
  2295.  
  2296. alert("播放完成!!!");
  2297.  
  2298. }
  2299.  
  2300.  
  2301. } else {
  2302. //1.调用点击播放接口
  2303. //2.发送心跳
  2304.  
  2305. await HNTOOL.Sleep(500);
  2306.  
  2307. HNAPI.playOneVideo(BV);
  2308. }
  2309.  
  2310.  
  2311. });
  2312.  
  2313.  
  2314. });
  2315.  
  2316. }
  2317.  
  2318.  
  2319.  
  2320.  
  2321. let addSetPage = async function() {
  2322.  
  2323. HNTOOL.Sleep(1000);
  2324.  
  2325. $('body').append('' +
  2326. '<div id="left_navbar">' +
  2327. '<div class="javaex-menu-container"> ' +
  2328. ' <div id="menu" class="javaex-menu"> ' +
  2329. ' <ul> ' +
  2330. ' <li class="javaex-menu-item alone hover" > ' +
  2331. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  2332. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  2333. ' </li> ' +
  2334. ' </ul> ' +
  2335. ' <ul> ' +
  2336. ' <li class="javaex-menu-item"> ' +
  2337. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  2338. ' <ul> ' +
  2339. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  2340. ' </ul> ' +
  2341. ' </li> ' +
  2342. ' <li id="chackList" class="javaex-menu-item"> ' +
  2343. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  2344. ' <ul> ' +
  2345. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  2346. //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  2347. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  2348. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  2349. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  2350. ' </ul> ' +
  2351. ' </li> ' +
  2352. ' <li class="javaex-menu-item"> ' +
  2353. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  2354. ' <ul> ' +
  2355. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  2356. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  2357. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  2358. ' <li id="yunBatchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >取关云数据</a></li> ' +
  2359. ' <li id="batchFollowOfbastard" class="javaex-hover-pulse"><a href="javaScript:;" >批量取关-慎用</a></li> ' +
  2360. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  2361. ' <li id="batch_dynamic_like" class="javaex-hover-pulse"><a href="javaScript:;" >批量动态点赞</a></li> ' +
  2362. ' </ul> ' +
  2363. ' </li> ' +
  2364. ' <li class="javaex-menu-item"> ' +
  2365. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  2366. ' <ul> ' +
  2367. ' <li id="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
  2368. ' <li id="jury_case" class="javaex-hover-pulse"><a href="javaScript:;" >一键风纪任务【0:10(5H)】</a></li> ' +
  2369. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  2370. ' <li id="linshiActivity" class="javaex-hover-pulse"><a href="javaScript:;" >临时转盘</a></li> ' +
  2371. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  2372. ' <li id="dynamicActivity" class="javaex-hover-pulse"><a href="javaScript:;" >动态抽奖</a></li> ' +
  2373. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  2374. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  2375. ' </ul> ' +
  2376. ' </li> ' +
  2377. ' <li class="javaex-menu-item"> ' +
  2378. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  2379. ' <ul> ' +
  2380. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  2381. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  2382. ' </ul> ' +
  2383. ' </li> ' +
  2384.  
  2385. ' </ul> ' +
  2386. ' </div> ' +
  2387. '</div>' +
  2388. '</div>');
  2389. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  2390.  
  2391. javaex.menu({
  2392. id: "menu",
  2393. isShowAll: false
  2394. });
  2395.  
  2396. }
  2397.  
  2398.  
  2399.  
  2400.  
  2401. let showUnreadMsg = function() {
  2402.  
  2403. var html = '';
  2404. html += '<div class="javaex-panel-box" style="width: 250px;">';
  2405. html += ' <ul>';
  2406. html += ` <p style="color: #FFF;">用户消息</p>`;
  2407. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  2408. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  2409. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  2410. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  2411. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  2412. html += ' <hr class="javaex-divider"></hr>';
  2413. html += ' </ul>';
  2414. html += '</div>';
  2415.  
  2416.  
  2417. javaex.panel(document.getElementById("getUnread"), {
  2418. position: "right",
  2419. content: html
  2420. });
  2421.  
  2422. javaex.tip({
  2423. content: "查询用户通知成功!",
  2424. type: "success"
  2425. });
  2426.  
  2427. }
  2428.  
  2429. /**
  2430. * 检查 艾特信息
  2431. * @returns {Promise<void>}
  2432. */
  2433. let chackAtMsg = async function(items) {
  2434.  
  2435. await HNTOOL.Sleep(500);
  2436.  
  2437. if (items != false && typeof(items) != "undefined") {
  2438.  
  2439.  
  2440. var html = '';
  2441. html += '<div class="javaex-panel-box" style="width: auto;">';
  2442. html += ' <ul>';
  2443. html += ` <p style="color: #FFF;">@信息</p>`;
  2444. items.forEach(function(item) {
  2445.  
  2446. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  2447. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  2448. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  2449.  
  2450. html +=
  2451. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  2452. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  2453. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  2454. html += ' <hr class="javaex-divider"></hr>';
  2455. });
  2456. html += ' </ul>';
  2457. html += '</div>';
  2458.  
  2459.  
  2460. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  2461. javaex.panel(document.getElementById("getAtMsg"), {
  2462. position: "right",
  2463. content: html
  2464. });
  2465. } else {
  2466. javaex.panel(document.getElementById("chackList"), {
  2467. position: "right",
  2468. content: html
  2469. });
  2470. }
  2471.  
  2472.  
  2473. }
  2474.  
  2475. }
  2476.  
  2477.  
  2478. let addStyle = function() {
  2479. const animate = GM_getResourceText('animate');
  2480. const common = GM_getResourceText('common');
  2481. const defaultCss = GM_getResourceText('defaultCss');
  2482. //const icomoonex = GM_getResourceText('icomoonex');
  2483. //const AllCss = animate + common + defaultCss + icomoonex;
  2484. const AllCss = animate + common + defaultCss;
  2485. const style = document.createElement('style');
  2486. style.innerHTML = AllCss;
  2487. return document.getElementsByTagName('head')[0].appendChild(style);
  2488. }
  2489.  
  2490. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  2491.  
  2492.  
  2493. /*-----------------------------------------------常用API--------------------------------------------------*/
  2494.  
  2495. let HNAPI = {
  2496.  
  2497. basePost: async function(api, data) {
  2498. return new Promise((resolve) => {
  2499. Ajax.post({
  2500. url: api,
  2501. hasCookies: true,
  2502. dataType: 'application/x-www-form-urlencoded',
  2503. data: data,
  2504. success: responseText => {
  2505. let res = HNTOOL.strToJson(responseText);
  2506. if (res.code === 0) {
  2507.  
  2508. resolve(res);
  2509. } else {
  2510. HNTOOL.console(res.message);
  2511.  
  2512. resolve({
  2513. err: res.message
  2514. });
  2515. }
  2516. }
  2517. })
  2518. });
  2519. },
  2520.  
  2521.  
  2522.  
  2523. baseGet: async function(api, queryObj) {
  2524. return new Promise((resolve) => {
  2525.  
  2526. Ajax.get({
  2527. url: api,
  2528. queryStringsObj: queryObj,
  2529. hasCookies: true,
  2530. success: responseText => {
  2531. let res = HNTOOL.strToJson(responseText);
  2532. if (res.code === 0) {
  2533.  
  2534. resolve(res);
  2535. } else {
  2536.  
  2537. resolve(false);
  2538. }
  2539. }
  2540. })
  2541. });
  2542. },
  2543.  
  2544. exchange_chance: async function(activity_id) {
  2545. return new Promise((resolve) => {
  2546.  
  2547. Ajax.get({
  2548. url: "https://qcloud-sdkact-api.biligame.com/exchange/chance",
  2549. queryStringsObj: {
  2550. 't': Math.round(new Date()),
  2551. 'activity_id': activity_id,
  2552.  
  2553. },
  2554. hasCookies: true,
  2555. success: responseText => {
  2556. let res = HNTOOL.strToJson(responseText);
  2557. if (res.code === 0) {
  2558.  
  2559. resolve(true);
  2560. } else {
  2561.  
  2562. resolve(false);
  2563. }
  2564. }
  2565. })
  2566. });
  2567. },
  2568. wwjdg_inform: async function(activity_id) {
  2569. return new Promise((resolve) => {
  2570.  
  2571. Ajax.get({
  2572. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/inform",
  2573. queryStringsObj: {
  2574. 't': Math.round(new Date()),
  2575. 'activity_id': activity_id,
  2576.  
  2577. },
  2578. hasCookies: true,
  2579. success: responseText => {
  2580. let res = HNTOOL.strToJson(responseText);
  2581. if (res.code === 0) {
  2582.  
  2583. resolve(true);
  2584. } else {
  2585.  
  2586. resolve(false);
  2587. }
  2588. }
  2589. })
  2590. });
  2591. },
  2592. wwjdg_inform_off: async function(activity_id, info_no) {
  2593. return new Promise((resolve) => {
  2594. Ajax.post({
  2595. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/inform/off?t=" + Math.round(
  2596. new Date()),
  2597. hasCookies: true,
  2598. dataType: 'application/x-www-form-urlencoded',
  2599. data: {
  2600.  
  2601. activity_id: activity_id,
  2602. info_no: info_no,
  2603.  
  2604. },
  2605. success: responseText => {
  2606. let res = HNTOOL.strToJson(responseText);
  2607. if (res.code === 0) {
  2608.  
  2609. resolve(true);
  2610. } else {
  2611.  
  2612. resolve(false);
  2613. }
  2614. }
  2615. })
  2616. });
  2617. },
  2618.  
  2619. exchange_prize: async function(activity_id) {
  2620. return new Promise((resolve) => {
  2621.  
  2622. Ajax.get({
  2623. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/exchange_prize",
  2624. queryStringsObj: {
  2625. 't': Math.round(new Date()),
  2626. 'activity_id': activity_id,
  2627. 'prize_id': 5629853426288896,
  2628. },
  2629. hasCookies: true,
  2630. success: responseText => {
  2631. let res = HNTOOL.strToJson(responseText);
  2632. if (res.code === 0) {
  2633.  
  2634. resolve(true);
  2635. } else {
  2636.  
  2637. resolve(false);
  2638. }
  2639. }
  2640. })
  2641. });
  2642. },
  2643. lottery_draw_one: async function() {
  2644. return new Promise((resolve) => {
  2645. Ajax.post({
  2646. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw?t=" + Math
  2647. .round(new Date()),
  2648. hasCookies: true,
  2649. dataType: 'application/x-www-form-urlencoded',
  2650. data: {
  2651.  
  2652. activity_id: 5629854950017280
  2653.  
  2654. },
  2655. success: responseText => {
  2656. let res = HNTOOL.strToJson(responseText);
  2657. if (res.code === 0) {
  2658.  
  2659. alert(res.data.name)
  2660.  
  2661. } else if (res.code === 11001 || res.code == -905) {
  2662.  
  2663. Ajax.post({
  2664. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw?t=" +
  2665. Math
  2666. .round(new Date()),
  2667. hasCookies: true,
  2668. dataType: 'application/x-www-form-urlencoded',
  2669. data: {
  2670.  
  2671. activity_id: 5629850673711360
  2672.  
  2673. },
  2674. success: responseText => {
  2675. let res2 = HNTOOL.strToJson(responseText);
  2676. if (res2.code === 0) {
  2677.  
  2678. alert(res2.data.name)
  2679. } else if (res.code == -905) {
  2680. alert(res2.message);
  2681. } else {
  2682.  
  2683. resolve(false);
  2684. }
  2685. }
  2686. })
  2687.  
  2688. } else {
  2689.  
  2690. resolve(false);
  2691. }
  2692. }
  2693. })
  2694. });
  2695. },
  2696. /**
  2697. *
  2698. */
  2699.  
  2700. jury_vote: async function(case_id, vote, anonymous) {
  2701. return new Promise((resolve) => {
  2702. Ajax.post({
  2703. url: BILIBLI_PATH.api + "/x/credit/v2/jury/vote",
  2704. hasCookies: true,
  2705. dataType: 'application/x-www-form-urlencoded',
  2706. data: {
  2707.  
  2708. case_id: case_id,
  2709. vote: vote,
  2710. anonymous: anonymous,
  2711. content: "",
  2712. csrf: Live_info.csrf_token
  2713. },
  2714. success: responseText => {
  2715. let res = HNTOOL.strToJson(responseText);
  2716. if (res.code === 0) {
  2717.  
  2718. resolve(true);
  2719. } else {
  2720.  
  2721. resolve(res.message);
  2722. }
  2723. }
  2724. })
  2725. });
  2726. },
  2727.  
  2728. /**
  2729. *
  2730. */
  2731. jury_case_opinion: async function(case_id) {
  2732. return new Promise((resolve) => {
  2733.  
  2734. Ajax.get({
  2735. url: BILIBLI_PATH.api + "/x/credit/v2/jury/case/opinion",
  2736. queryStringsObj: {
  2737. 'case_id': case_id,
  2738. 'pn': 1,
  2739. 'ps': 5,
  2740.  
  2741. },
  2742. hasCookies: true,
  2743. success: responseText => {
  2744. let res = HNTOOL.strToJson(responseText);
  2745. if (res.code === 0) {
  2746. resolve(true);
  2747. } else {
  2748.  
  2749. HNTOOL.console("获取案件详情发生错误!" + res.message, "error");
  2750.  
  2751. resolve(false);
  2752. }
  2753. }
  2754. })
  2755. });
  2756. },
  2757. /**
  2758. *
  2759. */
  2760. jury_case_info: async function(case_id) {
  2761. return new Promise((resolve) => {
  2762.  
  2763. Ajax.get({
  2764. url: BILIBLI_PATH.api + "/x/credit/v2/jury/case/info",
  2765. queryStringsObj: {
  2766. 'case_id': case_id
  2767. },
  2768. hasCookies: true,
  2769. success: responseText => {
  2770. let res = HNTOOL.strToJson(responseText);
  2771. if (res.code === 0) {
  2772. let comment_content = "";
  2773. let itemlist = [1, 1, 1, 1, 2, 2, 2, 2, 3, 0];
  2774. let x = itemlist[HNTOOL.random(0, 10)];
  2775.  
  2776. let vote_item = res.data.vote_items[x];
  2777. let case_type = res.data.case_type;
  2778. if (case_type == 4) {
  2779. //4:截屏内弹幕
  2780. comment_content = "截屏内弹幕";
  2781.  
  2782. } else {
  2783. comment_content = res.data.case_info.comment.content;
  2784. }
  2785.  
  2786.  
  2787. HNTOOL.console(
  2788. "\n 案号:" + case_id +
  2789. "\n 详情:" + comment_content +
  2790. "\n 选择:" + vote_item.vote_text
  2791. );
  2792. resolve(vote_item.vote);
  2793. } else {
  2794.  
  2795. HNTOOL.console("获取案件详情发生错误!" + res.message, "error");
  2796.  
  2797. resolve(false);
  2798. }
  2799. }
  2800. })
  2801. });
  2802. },
  2803.  
  2804. /**
  2805. *
  2806. */
  2807. jury_case_next: async function() {
  2808. return new Promise((resolve) => {
  2809.  
  2810. Ajax.get({
  2811. url: BILIBLI_PATH.api + '/x/credit/v2/jury/case/next',
  2812. queryStringsObj: {
  2813.  
  2814. },
  2815. hasCookies: true,
  2816. success: responseText => {
  2817. let res = HNTOOL.strToJson(responseText);
  2818. if (res.code === 0) {
  2819.  
  2820. resolve(res.data.case_id);
  2821. } else if (res.code === 25014 || res.code === 25008) {
  2822.  
  2823. HNTOOL.console(res.message);
  2824.  
  2825.  
  2826. } else {
  2827. HNTOOL.console("今日风纪已完成&暂时无案子!");
  2828. resolve(false);
  2829. }
  2830. }
  2831. })
  2832. });
  2833. },
  2834.  
  2835. answer_check: async function(question_id, ans_hash, type) {
  2836. return new Promise((resolve) => {
  2837. Ajax.post({
  2838.  
  2839. url: "https://api.bilibili.com/x/answer/v4/" + type + "/check",
  2840. hasCookies: true,
  2841. dataType: 'application/x-www-form-urlencoded',
  2842. data: {
  2843. question_id: question_id,
  2844. ans_hash: ans_hash,
  2845. csrf: Live_info.csrf_token
  2846. },
  2847. success: responseText => {
  2848. let res = HNTOOL.strToJson(responseText);
  2849. if (res.code === 0) {
  2850. console.log("答题成功");
  2851. resolve(res.data);
  2852. } else if (res.code === 41020) {
  2853. resolve(1);
  2854. } else {
  2855. javaex.tip({
  2856. content: "错误!",
  2857. type: "error"
  2858. });
  2859. resolve(false);
  2860. }
  2861. }
  2862. })
  2863. });
  2864. },
  2865.  
  2866. /**
  2867. *
  2868. */
  2869. pull_answer: async function(type) {
  2870. return new Promise((resolve) => {
  2871.  
  2872. Ajax.get({
  2873. url: 'https://api.bilibili.com/x/answer/v4/' + type,
  2874. queryStringsObj: {
  2875.  
  2876. },
  2877. hasCookies: true,
  2878. success: responseText => {
  2879. let res = HNTOOL.strToJson(responseText);
  2880. if (res.code === 0) {
  2881.  
  2882. resolve(res.data);
  2883. } else if (res.code === 41020) {
  2884. console.log("用户" + type + "题已通过")
  2885. resolve(1);
  2886. } else {
  2887. console.log("拉取" + type + "题目失败:" + res.message);
  2888. resolve(false);
  2889. }
  2890. }
  2891. })
  2892. });
  2893. },
  2894.  
  2895. /**
  2896. *
  2897. */
  2898. answer_status: async function() {
  2899. return new Promise((resolve) => {
  2900. Ajax.get({
  2901. url: 'https://api.bilibili.com/x/answer/v4/status',
  2902. queryStringsObj: {
  2903.  
  2904. },
  2905. hasCookies: true,
  2906. success: responseText => {
  2907. let res = HNTOOL.strToJson(responseText);
  2908. if (res.code === 0) {
  2909.  
  2910. resolve(res.data);
  2911.  
  2912. } else {
  2913. console.log("查询答题状态失败:" + res.message);
  2914. resolve(false);
  2915. }
  2916. }
  2917. })
  2918. });
  2919. },
  2920.  
  2921. /**
  2922. * 查询每日投币数量
  2923. */
  2924. get_account_exp: async function() {
  2925. return new Promise((resolve) => {
  2926. Ajax.get({
  2927. url: 'http://www.bilibili.com/plus/account/exp.php',
  2928. queryStringsObj: {
  2929.  
  2930. },
  2931. hasCookies: true,
  2932. success: responseText => {
  2933. let res = HNTOOL.strToJson(responseText);
  2934. if (res.code === 0) {
  2935.  
  2936. resolve(res.number);
  2937.  
  2938. } else {
  2939. console.log("查询每日投币数量失败:" + res.message);
  2940. resolve(false);
  2941. }
  2942. }
  2943. })
  2944. });
  2945. },
  2946. /**
  2947. * 查询每日奖励状态
  2948. */
  2949. get_exp_reward: async function() {
  2950. return new Promise((resolve) => {
  2951. Ajax.get({
  2952. url: BILIBLI_PATH.api + '/x/member/web/exp/reward',
  2953. queryStringsObj: {
  2954.  
  2955. },
  2956. hasCookies: true,
  2957. success: responseText => {
  2958. let res = HNTOOL.strToJson(responseText);
  2959. if (res.code === 0) {
  2960.  
  2961. resolve(res.data);
  2962.  
  2963. } else {
  2964. console.log("查询每日奖励状态失败:" + res.message);
  2965. resolve(false);
  2966. }
  2967. }
  2968. })
  2969. });
  2970. },
  2971.  
  2972. diary_upload: async function(activity_id, game_part) {
  2973. return new Promise((resolve) => {
  2974. Ajax.post({
  2975. url: "https://qcloud-sdkact-api.biligame.com/rabbit/diary/upload",
  2976. hasCookies: true,
  2977. dataType: 'application/x-www-form-urlencoded',
  2978. data: {
  2979. t: Math.round(new Date()),
  2980. activity_id: activity_id,
  2981. game_part: game_part
  2982. },
  2983. payload: '{"activity_id":"' + activity_id + '","game_part":' + game_part + '}',
  2984.  
  2985. success: responseText => {
  2986. let res = HNTOOL.strToJson(responseText);
  2987. if (res.code === 0) {
  2988. console.log("成功:");
  2989. resolve(true);
  2990. } else {
  2991. javaex.tip({
  2992. content: "错误!",
  2993. type: "error"
  2994. });
  2995. resolve(false);
  2996. }
  2997. }
  2998. })
  2999. });
  3000. },
  3001. lottery_draw: async function(activity_id) {
  3002. return new Promise((resolve) => {
  3003. Ajax.post({
  3004. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw",
  3005. hasCookies: true,
  3006. dataType: 'application/x-www-form-urlencoded',
  3007. data: {
  3008. t: Math.round(new Date()),
  3009. activity_id: activity_id,
  3010. },
  3011. payload: '{"activity_id":"' + activity_id + '","t":' + Math.round(new Date()) +
  3012. '}',
  3013.  
  3014. success: responseText => {
  3015. let res = HNTOOL.strToJson(responseText);
  3016. if (res.code === 0) {
  3017. console.log("成功");
  3018. resolve(true);
  3019. } else {
  3020. javaex.tip({
  3021. content: "错误!",
  3022. type: "error"
  3023. });
  3024. resolve(false);
  3025. }
  3026. }
  3027. })
  3028. });
  3029. },
  3030. lottery_record: async function(activity_id) {
  3031. return new Promise((resolve) => {
  3032. Ajax.get({
  3033. url: 'https://qcloud-sdkact-api.biligame.com/common/lottery/record',
  3034. queryStringsObj: {
  3035. t: Math.round(new Date()),
  3036. activity_id: activity_id,
  3037. },
  3038. hasCookies: true,
  3039. success: responseText => {
  3040. let res = HNTOOL.strToJson(responseText);
  3041. if (res.code === 0) {
  3042. let str = "";
  3043. for (let s of res.data) {
  3044. str += s.name
  3045. }
  3046.  
  3047. resolve(str);
  3048.  
  3049. } else {
  3050. console.log("查询每日奖励状态失败:" + res.message);
  3051. resolve(false);
  3052. }
  3053. }
  3054. })
  3055. });
  3056. },
  3057. get_draw_chance: async function(activity_id) {
  3058. return new Promise((resolve) => {
  3059. Ajax.get({
  3060. url: 'https://qcloud-sdkact-api.biligame.com/activity/lottery/get_draw_chance',
  3061. queryStringsObj: {
  3062. t: Math.round(new Date()),
  3063. activity_id: activity_id,
  3064. },
  3065. hasCookies: true,
  3066. success: responseText => {
  3067. let res = HNTOOL.strToJson(responseText);
  3068. if (res.code === 0) {
  3069.  
  3070. resolve(true);
  3071.  
  3072. } else {
  3073. console.log("查询每日奖励状态失败:" + res.message);
  3074. resolve(false);
  3075. }
  3076. }
  3077. })
  3078. });
  3079. },
  3080. /**
  3081. * 转发一个视频
  3082. * @param {Object} videoAid
  3083. * @param {Object} videoMid
  3084. * @param {Object} randomStr
  3085. */
  3086.  
  3087. shareOneVideo: async function(videoAid, videoMid, randomStr) {
  3088. return new Promise((resolve) => {
  3089. Ajax.post({
  3090. url: BILIBLI_PATH.vcapi + "/dynamic_repost/v1/dynamic_repost/share",
  3091. hasCookies: true,
  3092. dataType: 'application/x-www-form-urlencoded',
  3093. data: {
  3094.  
  3095. platform: "pc",
  3096. uid: videoMid,
  3097. type: 8,
  3098. content: randomStr,
  3099. repost_code: 20000,
  3100. rid: videoAid,
  3101. csrf: Live_info.csrf_token
  3102. },
  3103. success: responseText => {
  3104. let res = HNTOOL.strToJson(responseText);
  3105. if (res.code === 0) {
  3106. console.log("转发一个视频成功:" + res.data.dynamic_id);
  3107. resolve(true);
  3108. } else {
  3109. javaex.tip({
  3110. content: "转发一个视频错误!" + res.message,
  3111. type: "error"
  3112. });
  3113. resolve(false);
  3114. }
  3115. }
  3116. })
  3117. });
  3118. },
  3119.  
  3120. /**
  3121. * 批量关注和拉黑 batchModify
  3122. *
  3123. * https://api.bilibili.com/x/relation/batch/modify
  3124. * @param uid
  3125. */
  3126.  
  3127. /**
  3128. * 发布动态
  3129. * @param {Object} mid
  3130. */
  3131. batchModify: async function(uids, act) {
  3132. return new Promise((resolve) => {
  3133. Ajax.post({
  3134. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  3135. hasCookies: true,
  3136. dataType: 'application/x-www-form-urlencoded',
  3137. data: {
  3138.  
  3139. "fids": uids,
  3140. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  3141. "re_src": 222,
  3142. "csrf": Live_info.csrf_token,
  3143. },
  3144. success: responseText => {
  3145. let res = HNTOOL.strToJson(responseText);
  3146. if (res.code === 0) {
  3147.  
  3148. if (res.data.failed_fids.length > 0) {
  3149. console.log("关注失败:" + res.data.failed_fids);
  3150. resolve(false);
  3151. } else {
  3152. console.log("关注成功:" + uids);
  3153. resolve(true);
  3154. }
  3155.  
  3156.  
  3157. } else {
  3158. javaex.tip({
  3159. content: "批量关注错误!" + res.message,
  3160. type: "error"
  3161. });
  3162. resolve(2);
  3163. }
  3164. }
  3165. })
  3166. });
  3167. },
  3168.  
  3169. /**
  3170. * 发布动态
  3171. * @param {Object} mid
  3172. */
  3173. sendOneDynamic: async function(content) {
  3174. return new Promise((resolve) => {
  3175. Ajax.post({
  3176. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/create',
  3177. hasCookies: true,
  3178. dataType: 'application/x-www-form-urlencoded',
  3179. data: {
  3180. csrf: Live_info.csrf_token,
  3181. dynamic_id: 0,
  3182. type: 4,
  3183. dynamic_id: 0,
  3184. content: content,
  3185. extension: '{"emoji_type":1,"from":{"emoji_type":1},"flag_cfg":{}}'
  3186. },
  3187. hasCookies: true,
  3188. success: responseText => {
  3189. let res = HNTOOL.strToJson(responseText);
  3190. if (res.code === 0) {
  3191.  
  3192. console.log("随机发送一条动态:" + content);
  3193. resolve(true);
  3194.  
  3195. } else {
  3196. console.log("随机发送一条动态:" + res.message);
  3197. resolve(false);
  3198. }
  3199. }
  3200. })
  3201. });
  3202. },
  3203. /**
  3204. * @param {num} mid
  3205. * 用户详细信息2 (用于名片)
  3206. */
  3207. getInterfaceCard: async function(mid) {
  3208. return new Promise((resolve) => {
  3209. Ajax.get({
  3210. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3211. queryStringsObj: {
  3212. "mid": mid
  3213. },
  3214.  
  3215. hasCookies: true,
  3216. success: responseText => {
  3217. let res = HNTOOL.strToJson(responseText);
  3218. if (res.code === 0) {
  3219.  
  3220. resolve(res.data.card);
  3221.  
  3222. } else {
  3223. console.log("获取用户详细信息失败:" + res.message);
  3224. resolve(false);
  3225. }
  3226. }
  3227. })
  3228. });
  3229. },
  3230.  
  3231.  
  3232. getLotteryNotice: async function(dynamic_id) {
  3233. return new Promise((resolve) => {
  3234. Ajax.get({
  3235. url: BILIBLI_PATH.vcapi + '/lottery_svr/v1/lottery_svr/lottery_notice',
  3236. queryStringsObj: {
  3237. "dynamic_id": dynamic_id
  3238. },
  3239. hasCookies: true,
  3240. success: responseText => {
  3241. let res = HNTOOL.strToJson(responseText);
  3242. if (res.code === 0) {
  3243.  
  3244. resolve(res.data);
  3245.  
  3246. } else {
  3247. console.log("获取开奖信息失败:" + res.message);
  3248. resolve(false);
  3249. }
  3250. }
  3251. })
  3252. });
  3253. },
  3254.  
  3255.  
  3256. likeDynamic: async function(dynamic_id) {
  3257.  
  3258. return new Promise((resolve) => {
  3259. Ajax.post({
  3260. url: BILIBLI_PATH.vcapi + '/dynamic_like/v1/dynamic_like/thumb',
  3261. hasCookies: true,
  3262. dataType: 'application/x-www-form-urlencoded',
  3263. data: {
  3264. uid: Live_info.uid,
  3265. dynamic_id: dynamic_id,
  3266. up: 1,
  3267. csrf: Live_info.csrf_token,
  3268. csrf_token: Live_info.csrf_token,
  3269. },
  3270. success: responseText => {
  3271. let res = HNTOOL.strToJson(responseText);
  3272. if (res.code === 0) {
  3273.  
  3274. javaex.tip({
  3275. content: "动态点赞成功!",
  3276. type: "success"
  3277. });
  3278.  
  3279. resolve(true);
  3280. } else {
  3281.  
  3282. console.log("动态点赞发生错误!" + res.message);
  3283.  
  3284. javaex.tip({
  3285. content: "动态点赞发生错误!" + res.message,
  3286. type: "error"
  3287. });
  3288.  
  3289. resolve(false);
  3290. }
  3291. }
  3292. })
  3293. });
  3294. },
  3295.  
  3296. repostDynamic: async function(dynamic_id, content, ctrl) {
  3297.  
  3298. return new Promise((resolve) => {
  3299. Ajax.post({
  3300. url: BILIBLI_PATH.vcapi + '/dynamic_repost/v1/dynamic_repost/repost',
  3301. dataType: 'application/x-www-form-urlencoded',
  3302. hasCookies: true,
  3303. data: {
  3304. uid: Live_info.uid,
  3305. dynamic_id: dynamic_id,
  3306. content: content,
  3307. extension: '{"emoji_type":1}',
  3308. at_uids: "",
  3309. ctrl: ctrl == null || ctrl == "转发动态" ? "[]" : ctrl,
  3310. csrf_token: Live_info.csrf_token,
  3311. csrf: Live_info.csrf_token
  3312. },
  3313. success: responseText => {
  3314. let res = HNTOOL.strToJson(responseText);
  3315. if (res.code === 0) {
  3316.  
  3317. javaex.tip({
  3318. content: "动态转发成功!",
  3319. type: "success"
  3320. });
  3321.  
  3322. resolve(true);
  3323. } else {
  3324.  
  3325. console.log("动态转发发生错误!" + res.message);
  3326.  
  3327. javaex.tip({
  3328. content: "动态转发发生错误!" + res.message,
  3329. type: "error"
  3330. });
  3331.  
  3332. resolve(false);
  3333. }
  3334. }
  3335. })
  3336. });
  3337. },
  3338.  
  3339. addReply: async function(oid, type) {
  3340.  
  3341. return new Promise((resolve) => {
  3342. Ajax.post({
  3343. url: BILIBLI_PATH.api + '/x/v2/reply/add',
  3344. dataType: 'application/x-www-form-urlencoded',
  3345. hasCookies: true,
  3346. data: {
  3347. "oid": oid,
  3348. "type": type, //11官方 17 加码
  3349. //"ordering": 'heat',
  3350. "message": HNTOOL.getRandomWordOfList(replyList) == undefined ? "不错[鼓掌]" :
  3351. HNTOOL.getRandomWordOfList(
  3352. replyList),
  3353. //"jsonp": 'jsonp',
  3354. //"plat": 1,
  3355. "csrf": Live_info.csrf_token
  3356. },
  3357. success: responseText => {
  3358. let res = HNTOOL.strToJson(responseText);
  3359. if (res.code === 0) {
  3360. javaex.tip({
  3361. content: "'自动评论成功'!",
  3362. type: "success"
  3363. });
  3364. resolve(0);
  3365. } else if (res.code === -404) {
  3366. console.log('自动评论原动态已删除');
  3367. resolve(0);
  3368. } else if (res.code === 12002) {
  3369. console.log('自动评论评论区已关闭');
  3370. resolve(0);
  3371. } else if (res.code === 12015) {
  3372. console.log('自动评论需要输入验证码');
  3373. resolve(1);
  3374. } else {
  3375. console.log('自动评论', `评论失败\n${responseText}`);
  3376. resolve(0);
  3377. }
  3378. }
  3379. })
  3380. });
  3381. },
  3382.  
  3383.  
  3384. setNotice: async function(notice) {
  3385.  
  3386. return new Promise((resolve) => {
  3387. Ajax.post({
  3388. url: BILIBLI_PATH.api + '/x/space/notice/set',
  3389. hasCookies: true,
  3390. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3391. data: {
  3392. notice: notice,
  3393. jsonp: 'jsonp',
  3394. csrf: Live_info.csrf_token
  3395. },
  3396. success: responseText => {
  3397. let res = HNTOOL.strToJson(responseText);
  3398. if (res.code === 0) {
  3399.  
  3400. javaex.tip({
  3401. content: "动态标记保存到个人公告成功!",
  3402. type: "success"
  3403. });
  3404.  
  3405. resolve(true);
  3406. } else {
  3407.  
  3408. javaex.tip({
  3409. content: res.message,
  3410. type: "error"
  3411. });
  3412.  
  3413. resolve(false);
  3414. }
  3415. }
  3416. })
  3417. });
  3418. },
  3419.  
  3420. getSpaceNotice: async function() {
  3421. return new Promise((resolve) => {
  3422. Ajax.get({
  3423. url: BILIBLI_PATH.api + '/x/space/notice',
  3424. queryStringsObj: {
  3425. "mid": Live_info.uid
  3426. },
  3427. hasCookies: true,
  3428. success: responseText => {
  3429. let res = HNTOOL.strToJson(responseText);
  3430. if (res.code === 0) {
  3431.  
  3432. resolve(res.data);
  3433.  
  3434. } else {
  3435. console.log("获取公告信息失败:" + res.message);
  3436. resolve(false);
  3437. }
  3438. }
  3439. })
  3440. });
  3441. },
  3442.  
  3443. getdynamicData: async function(dynamic_id_str) {
  3444. return new Promise((resolve) => {
  3445. Ajax.get({
  3446.  
  3447. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
  3448. queryStringsObj: {
  3449. "dynamic_id": dynamic_id_str
  3450. },
  3451. hasCookies: true,
  3452. success: responseText => {
  3453. let res = HNTOOL.strToJson(responseText);
  3454. if (res.code === 0) {
  3455.  
  3456. resolve(res.data);
  3457.  
  3458. } else {
  3459. console.log("获取动态信息失败:" + res.message);
  3460. resolve(false);
  3461. }
  3462. }
  3463. })
  3464. });
  3465. },
  3466.  
  3467. getAllFollow: async function() {
  3468. return new Promise((resolve) => {
  3469. Ajax.get({
  3470.  
  3471. url: BILIBLI_PATH.vcapi + '/feed/v1/feed/get_attention_list',
  3472. queryStringsObj: {
  3473. "uid": Live_info.uid
  3474. },
  3475. hasCookies: true,
  3476. success: responseText => {
  3477. let res = HNTOOL.strToJson(responseText);
  3478. if (res.code === 0) {
  3479.  
  3480. resolve(res.data.list);
  3481.  
  3482. } else {
  3483. console.log("查询失败!" + res.message);
  3484. resolve(false);
  3485. }
  3486. }
  3487. })
  3488. });
  3489. },
  3490.  
  3491. getCardByUID: async function(UID) {
  3492. return new Promise((resolve) => {
  3493. Ajax.get({
  3494.  
  3495. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3496. queryStringsObj: {
  3497. "mid": UID
  3498. },
  3499. hasCookies: true,
  3500. success: responseText => {
  3501. let res = HNTOOL.strToJson(responseText);
  3502. if (res.code === 0) {
  3503.  
  3504. resolve(res.data.card);
  3505.  
  3506. } else {
  3507. console.log("查询失败!" + res.message);
  3508. resolve(false);
  3509. }
  3510. }
  3511. })
  3512. });
  3513. },
  3514.  
  3515.  
  3516. /**
  3517. *
  3518. *
  3519. */
  3520.  
  3521. getTodayDynamicList: async function(mid, index) {
  3522. return new Promise((resolve) => {
  3523. Ajax.get({
  3524.  
  3525. url: BILIBLI_PATH.api + '/x/space/article',
  3526. queryStringsObj: {
  3527. "mid": mid,
  3528. "pn": 1,
  3529. "ps": 12,
  3530. "sort": 'publish_time'
  3531. },
  3532. hasCookies: true,
  3533. success: responseText => {
  3534. let res = HNTOOL.strToJson(responseText);
  3535. if (res.code === 0) {
  3536. let artlist = false;
  3537. let articlesList = [];
  3538. let articles = res.data.articles;
  3539. for (var i = 0, len = articles.length; i < index; i++) {
  3540. articlesList[i] = articles[i];
  3541. }
  3542.  
  3543. resolve(articlesList);
  3544. } else {
  3545.  
  3546.  
  3547. console.log("查询失败!" + res.message);
  3548. resolve(false);
  3549. }
  3550. }
  3551. })
  3552. });
  3553. },
  3554.  
  3555. getDataByLiveSid: async function(ids) {
  3556. return new Promise((resolve) => {
  3557. Ajax.get({
  3558.  
  3559. url: BILIBLI_PATH.api + '/x/activity/up/reserve/relation/info',
  3560. queryStringsObj: {
  3561. "ids": ids
  3562. },
  3563. hasCookies: true,
  3564. success: responseText => {
  3565. let res = HNTOOL.strToJson(responseText);
  3566. if (res.code === 0 && Object.keys(res.data.list).length != 0) {
  3567.  
  3568. resolve(res.data.list);
  3569. } else {
  3570.  
  3571. /* javaex.tip({
  3572. content: "查询失败!" + res.message,
  3573. type: "error"
  3574. }); */
  3575. console.log("查询失败!" + res.message);
  3576.  
  3577. resolve(false);
  3578. }
  3579. }
  3580. })
  3581. });
  3582. },
  3583.  
  3584. /**
  3585. * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
  3586. */
  3587. clickNow: async function() {
  3588. return new Promise((resolve) => {
  3589. Ajax.get({
  3590.  
  3591. url: BILIBLI_PATH.api + '/x/report/click/now',
  3592. queryStringsObj: {
  3593. jsonp: "jsonp"
  3594. },
  3595. hasCookies: true,
  3596. success: responseText => {
  3597. let res = HNTOOL.strToJson(responseText);
  3598. if (res.code === 0) {
  3599.  
  3600. javaex.tip({
  3601. content: "每日登录" + res.data.text,
  3602. type: "success"
  3603. });
  3604. resolve(true);
  3605.  
  3606. } else {
  3607.  
  3608. javaex.tip({
  3609. content: res.message,
  3610. type: "error"
  3611. });
  3612.  
  3613. resolve(false);
  3614. }
  3615. }
  3616. })
  3617. });
  3618. },
  3619.  
  3620. /**
  3621. * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
  3622. * @param {number} videoAid
  3623. */
  3624. addShare: async function(videoAid) {
  3625. return new Promise((resolve) => {
  3626. Ajax.post({
  3627. url: BILIBLI_PATH.api + '/x/web-interface/share/add',
  3628. hasCookies: true,
  3629. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3630. data: {
  3631. aid: videoAid,
  3632. csrf: Live_info.csrf_token
  3633. },
  3634. success: responseText => {
  3635. let res = HNTOOL.strToJson(responseText);
  3636. if (res.code === 0) {
  3637.  
  3638. javaex.tip({
  3639. content: "每日分享视频成功",
  3640. type: "success"
  3641. });
  3642.  
  3643. resolve(true);
  3644. } else {
  3645.  
  3646. javaex.tip({
  3647. content: res.message,
  3648. type: "error"
  3649. });
  3650.  
  3651. resolve(false);
  3652. }
  3653. }
  3654. })
  3655. });
  3656. },
  3657.  
  3658.  
  3659.  
  3660. /**
  3661. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  3662. * @param {number} videoAid
  3663. */
  3664. addArticleCoin: async function(cvID, mid) {
  3665. return new Promise((resolve) => {
  3666. Ajax.post({
  3667. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  3668. hasCookies: true,
  3669. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3670. data: {
  3671. aid: cvID,
  3672. upid: mid,
  3673. multiply: 2,
  3674. avtype: 2,
  3675. csrf: Live_info.csrf_token
  3676. },
  3677. success: responseText => {
  3678. let res = HNTOOL.strToJson(responseText);
  3679. if (res.code === 0) {
  3680.  
  3681. javaex.tip({
  3682. content: '专栏:' + cvID + "投币成功",
  3683. type: "success"
  3684. });
  3685.  
  3686. resolve(true);
  3687. } else {
  3688.  
  3689. javaex.tip({
  3690. content: res.message,
  3691. type: "error"
  3692. });
  3693.  
  3694. console.log('专栏投币失败:' + cvID + res.message);
  3695.  
  3696. resolve(false);
  3697. }
  3698. }
  3699. })
  3700. });
  3701. },
  3702.  
  3703. /**
  3704. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  3705. * @param {number} videoAid
  3706. */
  3707. addVideoCoin: async function(videoAid) {
  3708. return new Promise((resolve) => {
  3709. Ajax.post({
  3710. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  3711. hasCookies: true,
  3712. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3713. data: {
  3714. aid: videoAid,
  3715. multiply: 2,
  3716. select_like: 0,
  3717. cross_domain: true,
  3718. csrf: Live_info.csrf_token
  3719. },
  3720. success: responseText => {
  3721. let res = HNTOOL.strToJson(responseText);
  3722. if (res.code === 0) {
  3723.  
  3724. javaex.tip({
  3725. content: "投币成功",
  3726. type: "success"
  3727. });
  3728.  
  3729. resolve(true);
  3730. } else {
  3731.  
  3732. javaex.tip({
  3733. content: res.message,
  3734. type: "error"
  3735. });
  3736.  
  3737. resolve(false);
  3738. }
  3739. }
  3740. })
  3741. });
  3742. },
  3743.  
  3744.  
  3745. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  3746.  
  3747. DoSign: async function() {
  3748. return new Promise((resolve) => {
  3749. Ajax.get({
  3750.  
  3751. url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
  3752. queryStringsObj: {
  3753.  
  3754. },
  3755. hasCookies: true,
  3756. success: responseText => {
  3757. let res = HNTOOL.strToJson(responseText);
  3758. if (res.code === 0) {
  3759.  
  3760. javaex.tip({
  3761. content: "签到成功:" + res.data.text,
  3762. type: "success"
  3763. });
  3764. resolve(true);
  3765.  
  3766. } else if (res.code === 1011040) {
  3767.  
  3768. javaex.tip({
  3769. content: res.message,
  3770. type: "success"
  3771. });
  3772.  
  3773. resolve(true);
  3774. } else {
  3775.  
  3776. javaex.tip({
  3777. content: res.message,
  3778. type: "error"
  3779. });
  3780.  
  3781. resolve(false);
  3782. }
  3783. }
  3784. })
  3785. });
  3786. },
  3787.  
  3788.  
  3789. /**
  3790. * // 获取分区最新专栏列表 https://api.bilibili.com/x/article/recommends?cid=0&pn=1
  3791. */
  3792. getArticleRecommends: async function() {
  3793. return new Promise((resolve) => {
  3794. Ajax.get({
  3795.  
  3796. url: BILIBLI_PATH.api + '/x/article/recommends',
  3797. queryStringsObj: {
  3798. "cid": 0,
  3799. "pn": 1
  3800. },
  3801. hasCookies: true,
  3802. success: responseText => {
  3803. let res = HNTOOL.strToJson(responseText);
  3804. if (res.code === 0) {
  3805.  
  3806. javaex.tip({
  3807. content: "获取最新专栏成功!",
  3808. type: "success"
  3809. });
  3810. resolve(res.data);
  3811.  
  3812. } else {
  3813.  
  3814. javaex.tip({
  3815. content: "获取最新专栏失败!" + res.message,
  3816. type: "error"
  3817. });
  3818.  
  3819. console.log(res.message);
  3820.  
  3821. resolve(false);
  3822. }
  3823. }
  3824. })
  3825. });
  3826. },
  3827. /**
  3828. * // 获取分区最新视频列表
  3829. */
  3830. getDynamicRegion: async function() {
  3831. return new Promise((resolve) => {
  3832. Ajax.get({
  3833.  
  3834. url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
  3835. queryStringsObj: {
  3836. "pn": 1,
  3837. "ps": 20,
  3838. "rid": 21
  3839. },
  3840. hasCookies: true,
  3841. success: responseText => {
  3842. let res = HNTOOL.strToJson(responseText);
  3843. if (res.code === 0) {
  3844.  
  3845. javaex.tip({
  3846. content: "获取分区最新视频成功",
  3847. type: "success"
  3848. });
  3849. resolve(res.data.archives);
  3850.  
  3851. } else {
  3852.  
  3853. javaex.tip({
  3854. content: "获取分区最新视频失败" + res.message,
  3855. type: "error"
  3856. });
  3857.  
  3858. resolve(false);
  3859. }
  3860. }
  3861. })
  3862. });
  3863. },
  3864.  
  3865. /*
  3866. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  3867. * @param {Object} sid
  3868. */
  3869. reserveActivity: async function(sid) {
  3870. return new Promise((resolve) => {
  3871. Ajax.post({
  3872. url: BILIBLI_PATH.api + '/x/space/reserve',
  3873. hasCookies: true,
  3874. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3875. data: {
  3876. sid: sid, //当前用户
  3877. jsonp: "jsonp",
  3878. csrf: Live_info.csrf_token
  3879. },
  3880. success: responseText => {
  3881. let res = HNTOOL.strToJson(responseText);
  3882. if (res.code === 0) {
  3883.  
  3884. resolve(true);
  3885. } else {
  3886. javaex.tip({
  3887. content: res.message,
  3888. type: "error"
  3889. });
  3890. resolve(false);
  3891. }
  3892. }
  3893. })
  3894. });
  3895. },
  3896. /**
  3897. reserveActivity: async function(sid, reserve_total) {
  3898. return new Promise((resolve) => {
  3899. Ajax.post({
  3900. url: BILIBLI_PATH.vcapi + '/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
  3901. hasCookies: true,
  3902. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3903. data: {
  3904. reserve_id: sid,
  3905. cur_btn_status: 1,
  3906. reserve_total: reserve_total,
  3907. csrf: Live_info.csrf_token
  3908. },
  3909. success: responseText => {
  3910. let res = HNTOOL.strToJson(responseText);
  3911. if (res.code === 0) {
  3912.  
  3913. resolve(res.data);
  3914. } else {
  3915.  
  3916. javaex.tip({
  3917. content: res.message,
  3918. type: "error"
  3919. });
  3920.  
  3921. resolve(false);
  3922. }
  3923. }
  3924. })
  3925. });
  3926. }, */
  3927.  
  3928. getGiftList: async function(room) {
  3929. return new Promise((resolve) => {
  3930. Ajax.get({
  3931.  
  3932. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  3933. queryStringsObj: {
  3934. "room_id": room
  3935. },
  3936. hasCookies: true,
  3937. success: responseText => {
  3938. let res = HNTOOL.strToJson(responseText);
  3939. if (res.code === 0) {
  3940.  
  3941. resolve(res.data.list);
  3942. } else {
  3943.  
  3944. javaex.tip({
  3945. content: "查询包裹失败!" + res.message,
  3946. type: "error"
  3947. });
  3948.  
  3949. resolve(false)
  3950. }
  3951. }
  3952. })
  3953. });
  3954. },
  3955.  
  3956. /**
  3957. * 送银B克拉
  3958. * @param {Object} ruid
  3959. * @param {Object} roomid
  3960. */
  3961. bagSendGift: async function(ruid, roomid, bag_id) {
  3962. return new Promise((resolve) => {
  3963. Ajax.post({
  3964. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  3965. hasCookies: true,
  3966. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3967. data: {
  3968. uid: Live_info.uid, //当前用户
  3969. gift_id: 3,
  3970. ruid: ruid,
  3971. send_ruid: 0,
  3972. gift_num: 1,
  3973. bag_id: bag_id,
  3974. //rnd: Math.round(new Date() / 1000); //时间戳,
  3975. platform: 'pc',
  3976. biz_code: 'Live',
  3977. biz_id: roomid,
  3978. storm_beat_id: 0,
  3979. price: 0,
  3980. csrf_token: Live_info.csrf_token,
  3981. csrf: Live_info.csrf_token
  3982.  
  3983. },
  3984. success: responseText => {
  3985. let res = HNTOOL.strToJson(responseText);
  3986. if (res.code === 0) {
  3987.  
  3988. javaex.tip({
  3989. content: roomid + "赠送b克拉成功!" + res.message,
  3990. type: "success"
  3991. });
  3992.  
  3993. resolve(true);
  3994. } else {
  3995.  
  3996. javaex.tip({
  3997. content: res.message,
  3998. type: "error"
  3999. });
  4000.  
  4001. resolve(false);
  4002. }
  4003. }
  4004. })
  4005. });
  4006. },
  4007.  
  4008.  
  4009. /**
  4010. * 判断是否有勋章
  4011. * @param {Object} uid
  4012. * @param {Object} room
  4013. */
  4014.  
  4015. getFansMedalInfo: async function(uid, room) {
  4016. return new Promise((resolve) => {
  4017. Ajax.get({
  4018.  
  4019. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  4020. queryStringsObj: {
  4021. "target_id": uid,
  4022. "room_id": room
  4023. },
  4024. //dataType:'application/json, text/plain, */*',
  4025. hasCookies: true,
  4026. success: responseText => {
  4027. let res = HNTOOL.strToJson(responseText);
  4028. if (res.code === 0) {
  4029.  
  4030. if (res.data.my_fans_medal.level == 0) {
  4031. resolve(false)
  4032. } else {
  4033. resolve(true)
  4034. }
  4035.  
  4036. } else {
  4037.  
  4038. javaex.tip({
  4039. content: "查询勋章失败!" + res.message,
  4040. type: "error"
  4041. });
  4042.  
  4043. resolve(false)
  4044. }
  4045. }
  4046. })
  4047. });
  4048. },
  4049.  
  4050.  
  4051.  
  4052.  
  4053. getDisuidList: async function(re_version, pn) {
  4054. return new Promise((resolve) => {
  4055. Ajax.get({
  4056.  
  4057. url: BILIBLI_PATH.api + '/x/relation/blacks',
  4058. queryStringsObj: {
  4059. "re_version": re_version,
  4060. "pn": pn
  4061. },
  4062. hasCookies: true,
  4063. success: responseText => {
  4064. let res = HNTOOL.strToJson(responseText);
  4065. if (res.code === 0) {
  4066. resolve(res.data.list)
  4067. } else {
  4068.  
  4069. javaex.tip({
  4070. content: "查询黑名单失败!" + res.message,
  4071. type: "error"
  4072. });
  4073.  
  4074. resolve(null)
  4075. }
  4076. }
  4077. })
  4078. });
  4079. },
  4080.  
  4081. /**
  4082. * @param {Object} uid
  4083. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  4084. */
  4085. cancelAtt: async function(uid, act, re_src) {
  4086. return new Promise((resolve) => {
  4087. Ajax.post({
  4088. url: BILIBLI_PATH.api + '/x/relation/modify',
  4089. hasCookies: true,
  4090. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4091. data: {
  4092. fid: uid,
  4093. act: act,
  4094. re_src: re_src == undefined ? 11 : 116,
  4095. jsonp: "jsonp",
  4096. csrf: Live_info.csrf_token,
  4097. },
  4098. success: responseText => {
  4099. let res = HNTOOL.strToJson(responseText);
  4100. if (res.code === 0) {
  4101.  
  4102. //HNAPI.cancelAtt(uid, 6);
  4103.  
  4104. javaex.tip({
  4105. content: "取关成功!" + res.message,
  4106. type: "success"
  4107. });
  4108.  
  4109. resolve(true);
  4110. } else if (res.code === 22003) {
  4111.  
  4112. HNAPI.cancelAtt(uid, 6);
  4113.  
  4114. javaex.tip({
  4115. content: "取消拉黑" + res.message,
  4116. type: "success"
  4117. });
  4118. resolve(true);
  4119. } else {
  4120.  
  4121. javaex.tip({
  4122. content: res.message,
  4123. type: "error"
  4124. });
  4125.  
  4126. resolve(false);
  4127. }
  4128. }
  4129. })
  4130. });
  4131. },
  4132.  
  4133. getRoomMsg: async function(roomid) {
  4134. return new Promise((resolve) => {
  4135. Ajax.get({
  4136.  
  4137. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  4138. queryStringsObj: {
  4139. "roomid": roomid
  4140. },
  4141. hasCookies: true,
  4142. success: responseText => {
  4143. let res = HNTOOL.strToJson(responseText);
  4144. if (res.code === 0) {
  4145. resolve(res.data.info.uid)
  4146. } else {
  4147. resolve(false)
  4148. }
  4149. }
  4150. })
  4151. });
  4152. },
  4153.  
  4154. /**
  4155. *
  4156. * @param sid
  4157. * @returns {Promise<unknown>}
  4158. */
  4159. lotteryDo: async function(sid, name) {
  4160. return new Promise((resolve) => {
  4161. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/do';
  4162. if (sid.indexOf("newLottery") != -1) {
  4163. func_url = BILIBLI_PATH.api + "/x/lottery/do";
  4164. }
  4165. Ajax.post({
  4166. url: func_url,
  4167. hasCookies: true,
  4168. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4169. data: {
  4170.  
  4171. sid: sid,
  4172. type: 1,
  4173. csrf: Live_info.csrf_token,
  4174. },
  4175. success: responseText => {
  4176. let res = HNTOOL.strToJson(responseText);
  4177. if (res.code === 0) {
  4178. HNTOOL.console("活动转盘:" + name + "\n " + (res.data)[0].gift_name);
  4179. resolve((res.data)[0].gift_name);
  4180.  
  4181. } else if (res.code ===
  4182. 75400) { // || res.code === 75003 || res.code === 75403
  4183.  
  4184. resolve(true);
  4185. } else {
  4186. javaex.tip({
  4187. content: "本次抽奖失败!" + res.message,
  4188. type: "error"
  4189. });
  4190. resolve(false);
  4191. }
  4192. }
  4193. })
  4194. });
  4195. },
  4196.  
  4197.  
  4198. getLotteryMytimes: async function(sid) {
  4199. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/mytimes';
  4200. if (sid.indexOf("newLottery") != -1) {
  4201. func_url = BILIBLI_PATH.api + "/x/lottery/mytimes";
  4202. }
  4203. return new Promise((resolve) => {
  4204. Ajax.get({
  4205. url: func_url,
  4206. queryStringsObj: {
  4207. sid: sid
  4208. },
  4209. hasCookies: true,
  4210. success: responseText => {
  4211. let res = HNTOOL.strToJson(responseText);
  4212. if (res.code === 0) {
  4213. resolve(res.data.times)
  4214. } else {
  4215. resolve(0)
  4216. }
  4217. }
  4218. })
  4219. });
  4220. },
  4221.  
  4222. /**
  4223. * 增加抽奖次数一般是分享
  4224. * @param sid 活动sid
  4225. * @returns {Promise<unknown>} 0 成功 1:活动结束
  4226. */
  4227. addLotteryTimes: async function(sid) {
  4228. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/addtimes';
  4229. if (sid.indexOf("newLottery") != -1) {
  4230. func_url = BILIBLI_PATH.api + "/x/lottery/addtimes";
  4231. }
  4232.  
  4233. return new Promise((resolve) => {
  4234. Ajax.post({
  4235. url: func_url,
  4236. hasCookies: true,
  4237. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4238. data: {
  4239.  
  4240. sid: sid,
  4241. action_type: 3,
  4242. csrf: Live_info.csrf_token,
  4243. },
  4244. success: responseText => {
  4245. let res = HNTOOL.strToJson(responseText);
  4246. if (res.code === 0) {
  4247.  
  4248. resolve(0)
  4249. } else if (res.code === 75003 || res.code === 170405 || res.code ===
  4250. 75001 || res.code === 170001 || res.code === 75405) {
  4251.  
  4252. resolve(1)
  4253.  
  4254. } else {
  4255.  
  4256. resolve(res.message);
  4257. }
  4258. }
  4259. })
  4260. });
  4261. },
  4262. /**
  4263. * 查询用户关注 默认一次查询50
  4264. * @param vmid 用户uid
  4265. * @param pn 页码
  4266. * @returns {Promise<unknown>}
  4267. */
  4268. getMyFollow: async function(vmid, pn) {
  4269. return new Promise((resolve) => {
  4270. Ajax.get({
  4271. url: BILIBLI_PATH.api + '/x/relation/followings',
  4272. queryStringsObj: {
  4273. vmid: vmid,
  4274. pn: pn
  4275. },
  4276. hasCookies: true,
  4277. success: responseText => {
  4278. let res = HNTOOL.strToJson(responseText);
  4279. if (res.code === 0) {
  4280. resolve(res.data)
  4281. } else {
  4282. resolve(null)
  4283. }
  4284. }
  4285. })
  4286. });
  4287. },
  4288.  
  4289.  
  4290. getMyinfo: function() {
  4291. return new Promise((resolve) => {
  4292. Ajax.get({
  4293. url: BILIBLI_PATH.api + '/x/space/myinfo',
  4294. queryStringsObj: {},
  4295. hasCookies: true,
  4296. success: responseText => {
  4297. let res = HNTOOL.strToJson(responseText);
  4298. if (res.code === 0) {
  4299. resolve(res.data)
  4300. } else {
  4301. resolve(null)
  4302. }
  4303. }
  4304. })
  4305. });
  4306. },
  4307.  
  4308. getMyJson: function(url) {
  4309. return new Promise((resolve) => {
  4310. GM_xmlhttpRequest({
  4311. method: "GET",
  4312. url: url,
  4313. onload: function(response) {
  4314. const res = HNTOOL.strToJson((response || {}).responseText)
  4315. resolve(res);
  4316. }
  4317. });
  4318. })
  4319. },
  4320.  
  4321.  
  4322. userInfo: function(mid) {
  4323.  
  4324. Ajax.get({
  4325. url: BILIBLI_PATH.api + '/x/space/acc/info',
  4326. queryStringsObj: {
  4327. mid: mid
  4328. },
  4329. hasCookies: true,
  4330. success: responseText => {
  4331.  
  4332. var json = JSON.parse(responseText);
  4333.  
  4334. if (json.code != 0) {
  4335.  
  4336.  
  4337. }
  4338. }
  4339. });
  4340.  
  4341. },
  4342.  
  4343. sendQmsg: async function(key, msg) {
  4344.  
  4345. $.ajax({
  4346. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  4347.  
  4348. success: function(result) {
  4349.  
  4350. }
  4351. });
  4352.  
  4353.  
  4354. /*GM_xmlhttpRequest({
  4355. method: "GET",
  4356. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  4357. onload: function (response) {
  4358.  
  4359. let json = JSON.parse(response.response);
  4360. if (json.code == 0) {
  4361.  
  4362. javaex.tip({
  4363. content: "自动动态中奖提醒成功!" + json.reason,
  4364. type: "success"
  4365. });
  4366. } else {
  4367. console.log("自动动态中奖提醒失败!" + json.reason);
  4368. javaex.tip({
  4369. content: "自动动态中奖提醒失败!" + json.reason,
  4370. type: "error"
  4371. });
  4372. }
  4373.  
  4374. }
  4375. });*/
  4376.  
  4377. },
  4378.  
  4379. /**
  4380. * //https://api.bilibili.com/x/relation/modify
  4381. *
  4382. * @param UID
  4383. */
  4384. disUserByUid: function(vmid) {
  4385.  
  4386. Ajax.post({
  4387. url: BILIBLI_PATH.api + '/x/relation/modify',
  4388. data: {
  4389. fid: parseInt(vmid),
  4390. re_src: 11,
  4391. act: 5,
  4392. jsonp: "jsonp",
  4393. csrf: Live_info.csrf_token,
  4394. },
  4395. hasCookies: true,
  4396. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4397. success: responseText => {
  4398.  
  4399. var json = JSON.parse(responseText);
  4400.  
  4401. if (json.code != 0) {
  4402.  
  4403. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  4404. javaex.tip({
  4405. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  4406. type: "error"
  4407. });
  4408.  
  4409. } else {
  4410. console.log("拉黑用户成功 uid:" + vmid);
  4411. javaex.tip({
  4412. content: "拉黑用户成功 uid:" + vmid,
  4413. type: "success"
  4414. });
  4415. }
  4416. }
  4417. });
  4418.  
  4419. },
  4420. /**
  4421. * http://api.bilibili.com/x/web-interface/view
  4422. * @param BV
  4423. * 心跳间隔15秒
  4424. */
  4425. watchOneVideo: function(BV, MID) {
  4426.  
  4427. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  4428. Ajax.post({
  4429. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  4430. hasCookies: true,
  4431. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4432. data: {
  4433.  
  4434. "bvid": BV,
  4435. "part": 1,
  4436. "mid": Live_info.uid,
  4437. "lv": 2,
  4438. "jsonp": "jsonp",
  4439. "type": 3,
  4440. "sub_type": 0
  4441. },
  4442. success: responseText => {
  4443.  
  4444. let json = JSON.parse(responseText);
  4445.  
  4446. if (/^{"code":0/.test(responseText)) {
  4447. //发送一次心跳
  4448. HNAPI.sendHeartbeat(BV, MID);
  4449.  
  4450. } else {
  4451. javaex.tip({
  4452. content: "视频" + data.bvid + "播放失败!" + json.message,
  4453. type: "error"
  4454. });
  4455. }
  4456. }
  4457. })
  4458.  
  4459.  
  4460. },
  4461.  
  4462. //上报视频播放心跳(web端)
  4463. /**
  4464. * http://api.bilibili.com/x/click-interface/web/heartbeat
  4465. * @param json
  4466. */
  4467. sendHeartbeat: function(bvid, MID) {
  4468.  
  4469. Ajax.post({
  4470. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  4471. hasCookies: true,
  4472. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4473. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  4474. data: {
  4475. "bvid": bvid,
  4476. "type": 3,
  4477. "dt": 2,
  4478. "played_time": HNTOOL.random(12, 40),
  4479. "realtime": HNTOOL.random(12, 40),
  4480. "play_type": 0
  4481. },
  4482. success: responseText => {
  4483.  
  4484. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  4485.  
  4486. javaex.tip({
  4487. content: "视频BV" + bvid + "播放一次!",
  4488. type: "success"
  4489. });
  4490. }
  4491. }
  4492. })
  4493.  
  4494. },
  4495.  
  4496. //获取up所有投稿视频
  4497. /**
  4498. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  4499. * @param mid
  4500. */
  4501. getUpAllBV: function(mid, pn, ps) {
  4502. ps = (ps === undefined ? 30 : ps); // a默认值为1
  4503. Ajax.get({
  4504. url: BILIBLI_PATH.api + '/x/space/arc/search',
  4505. queryStringsObj: {
  4506. mid: mid,
  4507. tid: 0,
  4508. order: 'pubdate',
  4509. jsonp: 'jsonp',
  4510. pn: pn,
  4511. ps: ps
  4512. },
  4513. hasCookies: true,
  4514. success: responseText => {
  4515.  
  4516. var json = JSON.parse(responseText);
  4517.  
  4518. if (json.code != 0) {
  4519.  
  4520. javaex.tip({
  4521. content: "获取up所有投稿视频失败!" + json.message,
  4522. type: "success"
  4523. });
  4524.  
  4525. } else {
  4526. BiliData.BVList = json.data.list.vlist;
  4527.  
  4528. }
  4529. }
  4530. });
  4531.  
  4532. },
  4533.  
  4534.  
  4535. /**
  4536. *
  4537. * @param path
  4538. * @param data
  4539. * @param saveObj
  4540. * @param Func
  4541. */
  4542. publicGet: function(path, queryStringsObj) {
  4543.  
  4544. if (typeof(queryStringsObj) != "undefined") {
  4545. queryStringsObj = {};
  4546. }
  4547. Ajax.get({
  4548. url: BILIBLI_PATH.api + path,
  4549. queryStringsObj: queryStringsObj,
  4550. hasCookies: true,
  4551. success: responseText => {
  4552.  
  4553. let json = JSON.parse(responseText);
  4554. if (chackCode(json.code) && json.code == 0) {
  4555.  
  4556. return json.data;
  4557. }
  4558.  
  4559. return false;
  4560.  
  4561. }
  4562. })
  4563.  
  4564. },
  4565.  
  4566. /**
  4567. * 导航栏用户信息
  4568. */
  4569. getUserNav: async function() {
  4570.  
  4571. GM_xmlhttpRequest({
  4572. method: "GET",
  4573. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  4574. //timeout:3000,
  4575. onload: function(response) {
  4576.  
  4577. let json = JSON.parse(response.response);
  4578. console.log(json);
  4579. BiliData.login_code = json.code;
  4580. BiliData.login_message = json.message;
  4581. BiliData.LoginData = json.data;
  4582.  
  4583. }
  4584. });
  4585.  
  4586. },
  4587.  
  4588. /**
  4589. * 获取某up详细信息
  4590. * http://api.bilibili.com/x/web-interface/card
  4591. */
  4592. getUpCard: function(mid) {
  4593.  
  4594. Ajax.get({
  4595. url: BILIBLI_PATH.api + '/x/web-interface/card',
  4596. queryStringsObj: {
  4597. mid: mid,
  4598. photo: false
  4599. },
  4600. hasCookies: true,
  4601. success: responseText => {
  4602.  
  4603. var json = JSON.parse(responseText);
  4604.  
  4605. if (json.code != 0) {
  4606.  
  4607. javaex.tip({
  4608. content: "查询失败!" + json.message,
  4609. type: "success"
  4610. });
  4611. return false;
  4612. } else {
  4613. BiliData.upCard = json;
  4614.  
  4615. }
  4616.  
  4617.  
  4618. }
  4619. })
  4620.  
  4621. },
  4622.  
  4623. /**
  4624. *
  4625. * @param uid 用户uid
  4626. * @param ps 每页视频个数 默认30个
  4627. * @param pn 第几页
  4628. */
  4629. getUpAllVideo: function(uid, ps, pn) {
  4630.  
  4631. },
  4632. getChallenge: async function() {
  4633.  
  4634.  
  4635. },
  4636. /**
  4637. * 硬币记录
  4638. * @returns {Promise<void>}
  4639. */
  4640. getCoinLog: async function() {
  4641.  
  4642. GM_xmlhttpRequest({
  4643. method: "GET",
  4644. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  4645. //url: "http://api.bilibili.com/x/member/web/coin/log",
  4646. onload: function(response) {
  4647.  
  4648. let json = JSON.parse(response.response);
  4649. if (json.code == 0) {
  4650.  
  4651. console.log("硬币记录" + json);
  4652. BiliData.CoinLog = json.data;
  4653.  
  4654. return true;
  4655. }
  4656.  
  4657. }
  4658. });
  4659. },
  4660. /**
  4661. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  4662. * @returns {Promise<void>}
  4663. */
  4664. getUnread: async function() {
  4665.  
  4666. Ajax.get({
  4667. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  4668. hasCookies: true,
  4669. success: responseText => {
  4670.  
  4671. let json = JSON.parse(responseText);
  4672. if (chackCode(json.code) && json.code == 0) {
  4673.  
  4674. BiliData.Unread = json.data;
  4675. showUnreadMsg();
  4676. }
  4677.  
  4678. return false;
  4679.  
  4680. }
  4681. })
  4682.  
  4683. /* GM_xmlhttpRequest({
  4684. method: "GET",
  4685. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  4686. onload: function (response) {
  4687.  
  4688. let json = JSON.parse(response.response);
  4689.  
  4690. if (chackCode(json.code) && json.code == 0) {
  4691.  
  4692. BiliData.Unread = json.code;
  4693. showUnreadMsg();
  4694.  
  4695. }
  4696.  
  4697. }
  4698. });*/
  4699. },
  4700. /**
  4701. *
  4702. * @param type reply:回复我的 at @我的
  4703. */
  4704. getMsgfeed: function(type) {
  4705. Ajax.get({
  4706. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  4707. queryStringsObj: {
  4708. build: 0,
  4709. mobi_app: 'web'
  4710. },
  4711. hasCookies: true,
  4712. success: responseText => {
  4713.  
  4714. var json = JSON.parse(responseText);
  4715.  
  4716. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  4717. return false;
  4718. } else {
  4719. chackAtMsg(json.data.items);
  4720.  
  4721. return true;
  4722. }
  4723.  
  4724.  
  4725. }
  4726. })
  4727.  
  4728. },
  4729.  
  4730. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  4731. * @returns {Promise<void>}
  4732. */
  4733. getUnrewad: async function() {
  4734.  
  4735. GM_xmlhttpRequest({
  4736. method: "GET",
  4737. data: {
  4738. "mid": 99439379,
  4739. "pn": 1,
  4740. "ps": 5,
  4741. },
  4742. url: BILIBLI_PATH.api + "/x/space/arc/search",
  4743. onload: function(response) {
  4744.  
  4745. let json = JSON.parse(response.response);
  4746. if (json.code == 0) {
  4747.  
  4748. BiliData.Video = json.data;
  4749. console.log("未读消息数" + json);
  4750. }
  4751.  
  4752. }
  4753. });
  4754. },
  4755.  
  4756. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  4757. * @param {number} oid
  4758. * @param {nbumber} rpid
  4759. * @param {number} action
  4760. * @returns {Promise<void>}
  4761. * type: 11
  4762. * ordering: heat
  4763. * jsonp: jsonp
  4764. * csrf: 54a******* CSRF Token(位于cookie)
  4765. */
  4766.  
  4767. likeInDynamicComments: async function(latestDynamic) {
  4768.  
  4769.  
  4770. Ajax.post({
  4771. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  4772. hasCookies: true,
  4773. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4774. data: {
  4775. "oid": oid,
  4776. "type": 11,
  4777. "rpid": rpid,
  4778. "action": action,
  4779. "ordering": "heat",
  4780. "jsonp": "jsonp",
  4781. "csrf": Live_info.csrf_token,
  4782. },
  4783. success: responseText => {
  4784.  
  4785. if (/^{"code":0/.test(responseText)) {
  4786.  
  4787. BiliData.replyAction = JSON.parse(responseText);
  4788. console.log("点赞成功!" + responseText);
  4789. }
  4790. }
  4791. })
  4792.  
  4793. }
  4794.  
  4795.  
  4796. }
  4797.  
  4798. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  4799. var http_request = null;
  4800.  
  4801. function send_request(url, method) {}
  4802.  
  4803. let HNTOOL = {
  4804.  
  4805. getvisit_id: function(name = NAME) {
  4806.  
  4807. let str = "xxxxxxxxxxxx".replace(/[x]/g, (function(name) {
  4808. let randomInt = 16 * Math.random() | 0;
  4809. return ("x" === name ? randomInt : 3 & randomInt | 8).toString(16).toLowerCase();
  4810. }))
  4811. return str
  4812.  
  4813. },
  4814. /**
  4815. * 判断是否为整数类型方式
  4816. * @param {Object} obj
  4817. */
  4818. isInteger: function(obj) {
  4819.  
  4820. return obj % 1 === 0
  4821.  
  4822. },
  4823.  
  4824. jury_case: async function() {
  4825.  
  4826. for (let i = 0; i < 30; i++) {
  4827.  
  4828. //1.获取题号
  4829. let case_id = await HNAPI.jury_case_next();
  4830. await HNTOOL.Sleep(1000);
  4831. if (case_id == false) {
  4832. break;
  4833. }
  4834. //2.获取该题号详情
  4835. let vote = await HNAPI.jury_case_info(case_id);
  4836. await HNTOOL.Sleep(4 * 1000);
  4837. if (vote == false) {
  4838. break;
  4839. }
  4840. let opinion = await HNAPI.jury_case_opinion(case_id);
  4841. await HNTOOL.Sleep(15 * 1000);
  4842. //3.开始答题
  4843. let result = await HNAPI.jury_vote(case_id, vote, 1);
  4844. if (result) {
  4845. HNTOOL.console("第" + (i + 1) + "个案号:" + case_id + "完成!");
  4846. } else {
  4847. alert(result);
  4848. }
  4849. let case_id3 = await HNAPI.jury_case_next();
  4850.  
  4851. }
  4852.  
  4853. },
  4854. console: function(str, color, type) {
  4855. if (color != undefined) {
  4856. console.log(javaex.now() + "\n" + "%c " + str, "color:#" + color + ";font-weight:bold;");
  4857. } else {
  4858. console.log(javaex.now() + "\n" + "%c " + str, "color:#005500;font-weight:bold;");
  4859. }
  4860.  
  4861.  
  4862. javaex.tip({
  4863. content: str,
  4864. type: type == undefined || type == "success" ? "success" : type
  4865. });
  4866.  
  4867. },
  4868.  
  4869. doOneDynamic: async function(randomtime) {
  4870.  
  4871. var myVar = setInterval(async function() {
  4872.  
  4873. let randomStr = await HNTOOL.getRandomString();
  4874. await HNAPI.sendOneDynamic(randomStr);
  4875.  
  4876. }, randomtime);
  4877. },
  4878.  
  4879. getRandomString: function() {
  4880.  
  4881. return new Promise((resolve) => {
  4882. Ajax.get({
  4883. url: "https://api.mcloc.cn/love/",
  4884. //url: 'https://api.mcloc.cn/words/?type=json',//随机一个句子
  4885. //url: 'https://interface.meiriyiwen.com/article/random?dev=1',//随机一个句子
  4886. queryStringsObj: {
  4887. type: "json"
  4888. },
  4889. dataType: "text/html; charset=UTF-8",
  4890. hasCookies: false,
  4891. success: responseText => {
  4892.  
  4893. try {
  4894. let res = HNTOOL.strToJson(responseText);
  4895. resolve(res.data); //随机一句情话
  4896. //resolve(body.data+"---"+body.creator);//随机一个句子
  4897. //resolve(body.data.digest);//随机一个句子
  4898. } catch (e) {
  4899.  
  4900. resolve("你的名字,是我见过最短的情诗。"); //随机一句情话
  4901. }
  4902.  
  4903.  
  4904. }
  4905. })
  4906. });
  4907. },
  4908.  
  4909. getLatestDynamic: async function() {
  4910. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/bilicat_config.json";
  4911. let myjson = await HNAPI.getMyJson(url);
  4912.  
  4913. let default_data = myjson.Dynamic_article_uids;
  4914.  
  4915. let latestDynamic = await HNAPI.getTodayDynamicList(default_data[0], 3);
  4916. await HNTOOL.Sleep(1000);
  4917. let ldList = [];
  4918. let ldList2 = [];
  4919. for (let ld1 of latestDynamic) {
  4920.  
  4921. let ld = await HNTOOL.getDynamicIdList(ld1);
  4922. await HNTOOL.Sleep(1000);
  4923. ldList = ldList.concat(ld);
  4924. }
  4925.  
  4926. let latestDynamic2 = await HNAPI.getTodayDynamicList(default_data[1], 2);
  4927. await HNTOOL.Sleep(1000);
  4928.  
  4929. for (let ld2 of latestDynamic) {
  4930.  
  4931. let ld = await HNTOOL.getDynamicIdList(ld2);
  4932. await HNTOOL.Sleep(1000);
  4933. ldList2 = ldList2.concat(ld);
  4934. }
  4935. ldList.push.apply(ldList, ldList2);
  4936.  
  4937. let result = HNTOOL.arrUnique(ldList, false);
  4938.  
  4939. return result;
  4940.  
  4941. },
  4942.  
  4943. getDynamicIdList: async function(latestDynamic) {
  4944.  
  4945.  
  4946.  
  4947. return new Promise((resolve) => {
  4948. Ajax.get({
  4949. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  4950. queryStringsObj: {
  4951.  
  4952. },
  4953. dataType: "text/html; charset=utf-8",
  4954. hasCookies: true,
  4955. success: responseText => {
  4956. let datalist = HNTOOL.httpString(responseText);
  4957. let dls;
  4958. let returnlist = [];
  4959. if (datalist != undefined && datalist.length > 0) {
  4960. for (let dl of datalist) {
  4961.  
  4962. let len = dl.indexOf("?");
  4963. if (len == -1) {
  4964. dl += "?tab=2";
  4965. }
  4966. dls = dl.substring(dl.indexOf("?") - 18, dl.indexOf("?"));
  4967. if (dls == false ||
  4968. dls == null ||
  4969. dl.indexOf("read") > -1 ||
  4970. dl.indexOf("html") > -1 ||
  4971. dl.indexOf("pixiv") > -1 ||
  4972. returnlist.indexOf(dls) > -1) {
  4973. continue;
  4974. }
  4975.  
  4976. returnlist.push(dls);
  4977.  
  4978. }
  4979.  
  4980. resolve(HNTOOL.arrUnique(returnlist, false));
  4981. } else {
  4982. resolve(false);
  4983. }
  4984. }
  4985. })
  4986. });
  4987. },
  4988.  
  4989. httpString: function(s) {
  4990. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  4991. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  4992. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4993. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4994. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  4995. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  4996. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  4997. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  4998. s = s.match(reg);
  4999. console.log(s)
  5000. return (s)
  5001. },
  5002.  
  5003. saveConfig: function() {
  5004.  
  5005. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  5006. /* javaex.tip({
  5007. content: "配置保存成功!",
  5008. type: "success"
  5009. }); */
  5010.  
  5011. },
  5012.  
  5013. copyText: function(domId) {
  5014. let btn = document.getElementById(domId);
  5015. btn.select();
  5016. if (document.execCommand('copy')) {
  5017. document.execCommand('copy');
  5018. javaex.tip({
  5019. content: "复制成功!",
  5020. type: "success"
  5021. });
  5022. }
  5023.  
  5024. },
  5025. /**
  5026. * s数组去重并排序
  5027. */
  5028.  
  5029. arrUnique: function(ary, isSort) {
  5030.  
  5031. if (isSort == undefined) {
  5032. isSort = true
  5033. }
  5034. let obj = {};
  5035. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  5036. let item = ary[i]
  5037. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  5038. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  5039. // 如果没有 将这个元素添加到对象中
  5040. if (isSort) {
  5041. ary.sort((a, b) => {
  5042. return a - b
  5043. }) // 数组去重后 按升序排列
  5044. }
  5045.  
  5046. obj = null;
  5047.  
  5048. javaex.tip({
  5049. content: "已去重!",
  5050. type: "success"
  5051. });
  5052. return ary;
  5053.  
  5054. },
  5055.  
  5056. split_array: function(arr, len) {
  5057.  
  5058. let arr_length = arr.length;
  5059. let newArr = [];
  5060. for (let i = 0; i < arr_length; i += len) {
  5061. newArr.push(arr.slice(i, i + len));
  5062. }
  5063. return newArr;
  5064. },
  5065. strToJson: function(params) {
  5066. const isJSON = (str => {
  5067. if (typeof str === 'string') {
  5068. try {
  5069. const obj = JSON.parse(str);
  5070. return typeof obj === 'object' ? obj : false
  5071. } catch (_) {
  5072. console.log(str);
  5073. return false;
  5074. }
  5075. } else {
  5076. console.log(`${str}\nIt is not a string!`);
  5077. return false;
  5078. }
  5079. })(params);
  5080. return isJSON ? isJSON : {}
  5081. },
  5082.  
  5083. chackAtMsg: function() {
  5084.  
  5085. let config = HNTOOL.getConfig();
  5086. if (config.qmsg_checked == true && config.qmsg_key) {
  5087.  
  5088. document.getElementById("getAtMsg").click();
  5089.  
  5090. }
  5091.  
  5092. },
  5093.  
  5094. cssChecked: function(id, dom) {
  5095.  
  5096. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  5097.  
  5098.  
  5099. },
  5100. getConfig: function() {
  5101.  
  5102. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  5103.  
  5104. if (CONFIG == null) {
  5105. CONFIG = HN_SETUP_CONFIG;
  5106. }
  5107.  
  5108. return CONFIG;
  5109. },
  5110.  
  5111. /**
  5112. * 获取cookie 中某个键对应的值
  5113. * @param name
  5114. */
  5115.  
  5116. getCookie: function(name) {
  5117. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  5118. if (arr != null) return escape(arr[2]);
  5119. return false;
  5120. },
  5121. /**
  5122. * 得到一个字符串数组的中随机一个
  5123. * @param {List} list
  5124. */
  5125.  
  5126.  
  5127. getRandomWordOfList: function(list) {
  5128. var L = list.length;
  5129. var i = Math.ceil(Math.random() * (L - 1));
  5130.  
  5131. return list[i];
  5132. },
  5133. random: function(min, max) {
  5134.  
  5135. return Math.floor(Math.random() * (max - min)) + min;
  5136. },
  5137.  
  5138. Sleep: function(ms) {
  5139. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  5140. }
  5141.  
  5142. }
  5143.  
  5144. let errorMsg = {
  5145. "-1": "应用程序不存在或已被封禁!",
  5146. "-2": "Access Key错误!",
  5147. "-3": "API校验密匙错误!",
  5148. "-4": "调用方对该Method没有权限!",
  5149. "-101": "账号未登录!",
  5150. "-102": "账号被封停!",
  5151. "-103": "积分不足!",
  5152. "-104": "硬币不足!",
  5153. "-105": "验证码错误!",
  5154. "-106": "账号非正式会员或在适应期!",
  5155. "-107": "应用不存在或者被封禁!",
  5156. "-108": "未绑定手机!",
  5157. "-109": "未知!",
  5158. "-110": "未绑定手机!",
  5159. "-111": "csrf 校验失败!",
  5160. "-112": "系统升级中!",
  5161. "-113": "账号尚未实名认证!",
  5162. "-114": "请先绑定手机!",
  5163. "-115": "请先完成实名认证!",
  5164. "-304": "木有改动!",
  5165. "-307": "撞车跳转!",
  5166. "-400": "请求错误!",
  5167. "-401": "未认证!",
  5168. "-403": "访问权限不足!",
  5169. "-404": "啥都木有!",
  5170. }
  5171.  
  5172. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  5173. /**
  5174. *
  5175. * @param code
  5176. * @constructor
  5177. */
  5178. let chackCode = function(code) {
  5179.  
  5180. let emsg = errorMsg[code + ""];
  5181. if (emsg != null) {
  5182. javaex.tip({
  5183. content: emsg,
  5184. type: "error"
  5185. });
  5186.  
  5187. return false;
  5188. }
  5189.  
  5190. return true;
  5191. }
  5192.  
  5193.  
  5194. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  5195. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  5196.  
  5197. /*window.onbeforeunload = function() {
  5198. if (!canLeavePage()) {
  5199. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  5200. }
  5201. };*/
  5202.  
  5203.  
  5204. /**
  5205. * Ajax请求对象
  5206. */
  5207. const Ajax = (() => {
  5208. /**
  5209. * 检查options是否符合要求
  5210. * @param {object} options
  5211. * @returns {boolean}
  5212. */
  5213. function checkOptions(options) {
  5214. let result = false;
  5215. if (typeof options !== 'object') {
  5216. console.warn('类型错误: typeof Options !== Object');
  5217. return result;
  5218. } else {
  5219. if (typeof options.url !== 'string') {
  5220. console.warn('类型错误: typeof Link !== Strings');
  5221. return result;
  5222. } else {
  5223. const reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  5224. //const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  5225. if (!reg.test(options.url)) {
  5226. console.warn('url字符串须为完整http链接');
  5227. return result;
  5228. }
  5229. result = true;
  5230. }
  5231. }
  5232. return result;
  5233. }
  5234.  
  5235. /**
  5236. * 对象转URL编码
  5237. * @param {object} data
  5238. */
  5239. function objToURLCode(data) {
  5240. var _result = [];
  5241. for (var key in data) {
  5242. var value = data[key];
  5243. if (value instanceof Array) {
  5244. value.forEach(function(_value) {
  5245. _result.push(key + "=" + _value);
  5246. });
  5247. } else {
  5248. _result.push(key + '=' + value);
  5249. }
  5250. }
  5251. return _result.join('&');
  5252. }
  5253.  
  5254. /**
  5255. * 请求
  5256. * @param {string} method
  5257. * @param {object} options
  5258. */
  5259. function request(method, options) {
  5260. if (checkOptions(options)) {
  5261. let xhr = new XMLHttpRequest();
  5262. const {
  5263. url: _url,
  5264. queryStringsObj,
  5265. data,
  5266. dataType,
  5267. payload,
  5268. hasCookies
  5269. } = options, url = typeof queryStringsObj === 'object' ?
  5270. _url + '?' + objToURLCode(queryStringsObj) : _url;
  5271. switch (method) {
  5272. case 'GET':
  5273. xhr.open("GET", url);
  5274. break;
  5275. case 'POST':
  5276. xhr.open("POST", url);
  5277. xhr.setRequestHeader('Content-Type', dataType);
  5278. //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");
  5279. break;
  5280. default:
  5281. break;
  5282. }
  5283. if (hasCookies) xhr.withCredentials = true;
  5284. xhr.timeout = 3000;
  5285. xhr.addEventListener('load', () => {
  5286. if (xhr.status === 200) {
  5287. options.success(xhr.responseText)
  5288. } else {
  5289. console.error(`status:${xhr.status}`);
  5290. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  5291. }
  5292. })
  5293. xhr.addEventListener('error', () => {
  5294. console.error('ajax请求出错')
  5295. options.success('{"code":-1,"msg":"ajax请求出错"}');
  5296. })
  5297. xhr.addEventListener('timeout', () => {
  5298. console.error('请求超时')
  5299. options.success('{"code":-1,"msg":"请求超时"}');
  5300. })
  5301. switch (method) {
  5302. case 'GET':
  5303. xhr.send()
  5304. break;
  5305. case 'POST':
  5306. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  5307. //xhr.send(payload);
  5308. break;
  5309. default:
  5310. break;
  5311. }
  5312. }
  5313. }
  5314.  
  5315. return {
  5316. /**
  5317. * 发送Get请求
  5318. * @param {Object} options
  5319. */
  5320. get(options) {
  5321. request("GET", options);
  5322. },
  5323. /**
  5324. * 发送Post请求
  5325. * @param {object} options
  5326. */
  5327. post(options) {
  5328. request("POST", options);
  5329. }
  5330. }
  5331. })()
  5332.