Greasy Fork 支持简体中文。

-哔哩猫-(试用版)

练手

目前為 2022-03-25 提交的版本,檢視 最新版本

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

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