-哔哩猫-(试用版)

练手

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

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