-哔哩猫-(试用版)

练手

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

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