-哔哩猫-(试用版)

练手

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

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