-哔哩猫-(试用版)

练手

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

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