Greasy Fork 还支持 简体中文。

-哔哩猫-(发行版)

练手

目前為 2022-05-13 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/422731/1049833/-%E5%93%94%E5%93%A9%E7%8C%AB-%EF%BC%88%E5%8F%91%E8%A1%8C%E7%89%88%EF%BC%89.js

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