-哔哩猫-(发行版)

练手

当前为 2022-03-25 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/422731/1032202/-%E5%93%94%E5%93%A9%E7%8C%AB-%EF%BC%88%E5%8F%91%E8%A1%8C%E7%89%88%EF%BC%89.js

  1. // ==UserScript==
  2. // @name -哔哩猫-(发行版)
  3. // @description 练手
  4. // @namespace http://tampermonkey.net/
  5. // @version 2.5.47
  6. // @iconURL https://gitcode.net/qq_42688926/bilicat/-/raw/master/pic/PC_LOGO.gif
  7. // @author 荒年(QQ:2019676120)
  8. // @match *://space.bilibili.com/*
  9. // @match *://www.bilibili.com/v/newbie/*
  10. // @match *://www.bilibili.com/judgement/*
  11. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
  12. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex.min.js
  13. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex-formVerify.js
  14. // @resource animate https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@main/javaex/pc/css/animate.css
  15. // @resource common https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@main/javaex/pc/css/common.css
  16. // @resource defaultCss https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@main/javaex/pc/css/skin/default.css
  17. // @grant unsafeWindow
  18. // @grant GM_getValue
  19. // @grant GM_setValue
  20. // @grant GM_xmlhttpRequest
  21. // @grant GM_getResourceText
  22. // @grant GM_setClipboard
  23. // @grant GM_openInTab
  24. // @grant GM_addStyle
  25. // @run-at document-idle
  26. // @license MIT License
  27. // @connect github.com
  28. // @connect gitee.com
  29. // @connect gitcode.net
  30. // @connect api.bilibili.com
  31. // @connect qmsg.zendee.cn
  32. // @connect biliapi.net
  33. // @connect qcloud-sdkact-api.biligame.com
  34. // @connect passport.bilibili.com
  35. // @connect api.live.bilibili.com
  36. // @connect mcloc.cn
  37. // @namespace http://tampermonkey.net/
  38. // ==/UserScript==
  39.  
  40.  
  41.  
  42.  
  43. GM_addStyle(
  44. `
  45.  
  46. #switch-qsmg:before {
  47. content: "开关";
  48. letter-spacing: 16px;
  49. top: 4px;
  50. left: 10px;
  51. }
  52. #left_navbar{
  53. z-index: 1000;
  54. position: absolute;
  55. top: 100px;
  56. left: 5px;
  57. }
  58. button[hnBtn="btn_open"] {
  59. z-index: 1001;
  60. z-index: 1000px;
  61. position: absolute;
  62. top: 58px;
  63. left: 220px;
  64. }
  65. .javaex-panel.javaex-panel-right.javaex-animated-zoom-in {
  66. top: 60px;
  67. }
  68. .javaex-menu-container {
  69. border: 1px solid #eee;
  70. }
  71. .javaex-panel-box p {
  72. text-align: center;
  73. background: #fb7299;
  74. }
  75. .fontbold{
  76. color: #00a1d6;
  77. font-weight: bold;
  78. cursor: pointer;
  79. }
  80. .hideLogo {
  81. position: absolute;
  82. top: 88px;
  83. left: 10px;
  84. width: 50px;
  85. height: 57px;
  86. z-index: 9999;
  87. cursor: pointer;
  88. background-color: #fb7299;
  89. border-radius: 30px;
  90. }
  91. #auto_check_question {
  92. position: absolute;
  93. border-radius: 20%;
  94. font-size: 24px;
  95. text-align: center;
  96. border: 2px solid red;
  97. top: 91%;
  98. right: 44%;
  99. width: 81px;
  100. color: #fff;
  101. cursor: pointer;
  102. z-index: 999;
  103. }
  104. `
  105. );
  106.  
  107.  
  108. let HN_SETUP_CONFIG = {
  109.  
  110. qmsg_key: null, //后期改为kull 存储到本地
  111. qmsg_checked: false,
  112. Booking_last_sid: null,
  113. }
  114.  
  115. let replyList = ["哇⊙ω⊙", "仙女震惊", "都关注这么久了给个吧", "大佬,看下孩子吧,这次一定", "会有我吗?黑幕一手",
  116. "酋长在线拉低中奖率", "好耶(✪▽✪)", "好运", "希望欧一次", "永不缺席", " 永不中奖", " 永不放弃!", "万一呢", "在", "冲吖~", "来了",
  117. "芜湖,都想要,抽中那个都不亏阿", "从未中,从未停", "来力", "秋", "懂我意思吧", "今天去吃面", "从不缺席",
  118. "站友保佑抽到", "可以", "恰", "不会吧", "233", "好耶", "rush", "来了!!!", "来来", "ok", "冲", "凑热闹", "我要我要", "我还能中!", "让我中!!!",
  119. "是我的", "我是天选之子?", "给我中一次吧!", "坚持不懈,迎难而上", "开拓创新!", "我来抽个奖", "中中中中中", "我我我", "搞笑 这不得转", "我下手了",
  120. "看这里就想中一次", "不可能", "我不挑,都可以", "俺要当分母", "万一呢"
  121. ];
  122.  
  123. let HN_YUN_URL = {
  124. "tx_room": "https://gitcode.net/qq_42688926/bilicat/-/raw/master/TX/tx_room.json",
  125. "notice": "https://gitee.com/shanmite/lottery-notice/raw/master/notice.json",
  126. "bilicat_config": "https://gitcode.net/qq_42688926/bilicat/raw/master/hnconfig/bilicat_config.json",
  127. }
  128.  
  129. let NAME;
  130. let BILICAT_CONFIG;
  131. let Live_info = {
  132. room_id: undefined,
  133. uid: undefined,
  134. blocked: undefined,
  135. csrf_token: undefined,
  136. SESSDATA: undefined,
  137. visit_id: undefined,
  138. rnd: undefined,
  139. ruid: undefined,
  140. uname: undefined,
  141. user_level: undefined,
  142. ruid: undefined,
  143. };
  144.  
  145. let BILIBLI_PATH = {
  146.  
  147. "live": "https://api.live.bilibili.com",
  148. "vcapi": "https://api.vc.bilibili.com",
  149. "passport": "https://passport.bilibili.com",
  150. "api": "https://api.bilibili.com",
  151. "video": "https://www.bilibili.com/video/",
  152. "single_unread": "http://api.vc.bilibili.com/",
  153.  
  154. }
  155.  
  156. let BILIBILI_URL = {
  157. // 导航栏用户信息
  158. "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
  159. }
  160.  
  161. let BiliData = {
  162.  
  163. this_uid: window.location.href.split("/")[3], //当前页面uid
  164. author_uid: 99439379,
  165. login_code: null,
  166. login_message: "",
  167. LoginData: {},
  168. CoinLog: {},
  169. Unread: null,
  170. Video: {},
  171. replyAction: {},
  172. upCard: {},
  173. BVList: [],
  174. }
  175.  
  176. window.onload = async function() {
  177.  
  178. BILICAT_CONFIG = await HNAPI.getMyJson(HN_YUN_URL.bilicat_config);
  179. //界面显示
  180. init();
  181.  
  182.  
  183.  
  184. addHideLogo();
  185.  
  186.  
  187. /* var myVar = setInterval(function() {
  188. console.log("yunxing");
  189. AA ();
  190.  
  191. }, 1000);
  192.  
  193.  
  194. function AA (){
  195. if ((new Date()).getMinutes() == 47) {
  196.  
  197. console.log("stop");
  198. clearInterval(myVar);
  199. }
  200. } */
  201.  
  202.  
  203. }
  204.  
  205. function addHideLogo() {
  206.  
  207. let isHide = true;
  208.  
  209. let logolist = BILICAT_CONFIG.LOGO;
  210. $("#left_navbar").after(
  211. '<div id="hideLogo" class="hideLogo"> <img src="' + logolist[HNTOOL.random(0, logolist.length)] +
  212. '" alt="点击显示隐藏" width="100%" height="100%"></div>'
  213. );
  214. if (isHide) {
  215. $("#left_navbar").hide();
  216. isHide = false;
  217. } else {
  218. isHide = true;
  219. }
  220. $("#hideLogo").bind("click", async function() {
  221.  
  222. if (isHide) {
  223. $("#left_navbar").hide();
  224. isHide = false;
  225. } else {
  226. $("#left_navbar").show();
  227. isHide = true;
  228. }
  229. });
  230.  
  231. let newbie = window.location.href.indexOf("newbie") > -1;
  232. if (newbie) {
  233. $("#hideLogo").hide();
  234. //document.querySelector(".tv-type-text").innerHTML += '<span id="auto_check_question">答题</span>';
  235. $("#basic-1").after('<span id="auto_check_question">答题</span>');
  236. $("#basic-2").after('<span id="auto_check_question">答题</span>');
  237.  
  238. $("#optional-qa").after('<span id="auto_check_question">答题</span>');
  239.  
  240. }
  241.  
  242. /**
  243. * 一键答题
  244. */
  245.  
  246. $("#auto_check_question").bind("click", async function() {
  247.  
  248. for (let i = 0; i < 60; i++) {
  249.  
  250. //1.查询状态
  251. let status = await HNAPI.answer_status();
  252. await HNTOOL.Sleep(500);
  253.  
  254. if (status.progress == 100) {
  255.  
  256. let archivesList = await HNAPI.getDynamicRegion();
  257. await HNTOOL.Sleep(2000);
  258. let num = HNTOOL.random(0, archivesList.length - 1);
  259.  
  260. if (archivesList != false && num != 2) {
  261. videoAid = archivesList[num].aid;
  262. videoBvid = archivesList[num].bvid;
  263. videoCid = archivesList[num].cid;
  264. videoMid = archivesList[num].owner.mid;
  265. }
  266. await HNAPI.shareOneVideo(videoAid, videoMid, "分享视频");
  267. if (num == 3 || num == 16) {
  268. let randomStr = await HNTOOL.getRandomString();
  269. await HNAPI.shareOneVideo("975082514", "397516636", randomStr);
  270. }
  271. window.close();
  272. /* let submitData = {
  273. "re_src": 0,
  274. "csrf": Live_info.csrf_token,
  275. }
  276.  
  277.  
  278. let submitReul = await HNAPI.basePost("https://api.bilibili.com/x/answer/v4/submit",
  279. submitData);
  280. window.location.reload(); */
  281.  
  282. }
  283.  
  284. if (status.status != 3 && status.result == "failed") {
  285. // 基础题
  286. if (status.stage == "base") {
  287. //拉取题目
  288. let base = await HNAPI.pull_answer("base");
  289. if (base == 1) {
  290. continue;
  291. }
  292. if (base == false) {
  293. alert("基础题答题错误:答题过快或错误太多||用户答题记录不存在");
  294. break;
  295. }
  296. let question = base.question;
  297. for (let j = 0, len = question.options.length; j < len; j++) {
  298.  
  299. //1.答题
  300. let check = await HNAPI.answer_check(question.id, question.options[j].hash,
  301. "base");
  302. if (check == 1) {
  303. continue;
  304. }
  305. await HNTOOL.Sleep(1000);
  306. if (check.passed == true) {
  307. console.log("开始基础题第" + question.number + "题!---当前得分:" + status.score);
  308. javaex.tip({
  309. content: "开始基础题第" + question.number + "题!---当前得分:" + status.score,
  310. type: "success"
  311. });
  312. break;
  313. }
  314. }
  315.  
  316.  
  317. //附加题
  318. } else if (status.stage == "extra") {
  319.  
  320. //拉取题目
  321. let extra = await HNAPI.pull_answer("extra");
  322. if (extra == 1) {
  323. continue;
  324. }
  325. if (extra == false) {
  326. alert("违规发言题答题错误:答题过快或错误太多||用户答题记录不存在");
  327. break;
  328. }
  329. let question = extra.question;
  330. let check = await HNAPI.answer_check(question.id, question.options[0].hash, "extra");
  331. await HNTOOL.Sleep(1000);
  332. if (check == 1) {
  333. continue;
  334. }
  335. if (check.passed == true) {
  336. console.log("开始违规发言题第" + question.number + "题!---当前得分:" + status.score);
  337. javaex.tip({
  338. content: "开始违规发言题第" + question.number + "题!---当前得分:" + status.score,
  339. type: "success"
  340. });
  341. if (question.number == 50) {
  342. window.location.reload();
  343. }
  344. }
  345.  
  346. } else if (status.stage == "pro") {
  347.  
  348. //拉取题目
  349. let pro = await HNAPI.pull_answer("pro");
  350. if (pro == 1) {
  351. continue;
  352. }
  353. if (pro == false) {
  354. alert("自选题答题错误:答题过快或错误太多||用户答题记录不存在");
  355. break;
  356. }
  357. let question = pro.question;
  358. let num = HNTOOL.random(0, question.options.length);
  359. let check = await HNAPI.answer_check(question.id, question.options[num].hash, "pro");
  360. await HNTOOL.Sleep(1000);
  361. if (check == 1) {
  362. continue;
  363. }
  364. if (check.passed == true) {
  365. console.log("开始自选题第" + question.number + "题!---当前得分:" + status.score);
  366. javaex.tip({
  367. content: "开始自选题第" + question.number + "题!---当前得分:" + status.score,
  368. type: "success"
  369. });
  370.  
  371. }
  372.  
  373. } else {
  374. break;
  375. }
  376.  
  377. }
  378.  
  379. }
  380.  
  381. });
  382.  
  383.  
  384. }
  385.  
  386.  
  387. function init() {
  388.  
  389. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  390. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  391. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  392. NAME = Live_info.uid;
  393.  
  394. //HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&54988";
  395.  
  396.  
  397. addStyle();
  398. addSetPage();
  399.  
  400. HNTOOL.chackAtMsg();
  401.  
  402. $("#getCoinLog").bind("click", async function() {
  403.  
  404.  
  405. if (HNAPI.getCoinLog()) {
  406.  
  407. await HNTOOL.Sleep(500);
  408. let html = '';
  409. html += '<div class="javaex-panel-box" style="width: 250px;">';
  410. html += ' <ul>';
  411. html += ` <p style="color: #FFF;">硬币使用记录</p>`;
  412.  
  413. BiliData.CoinLog.list.forEach(function(item) {
  414.  
  415. let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
  416. if (BV.indexOf("BV") != -1) {
  417. html +=
  418. `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
  419. }
  420. html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
  421.  
  422.  
  423. });
  424. html += ' <hr class="javaex-divider"></hr>';
  425. html += ' </ul>';
  426. html += '</div>';
  427.  
  428. javaex.panel(this, {
  429. position: "right",
  430. //offsetTop: "104",
  431. content: html
  432. });
  433. javaex.tip({
  434. content: "获取用户成功!",
  435. type: "success"
  436. });
  437.  
  438. } else {
  439. javaex.tip({
  440. content: "获取硬币记录失败,请稍后重试!",
  441. type: "error"
  442. });
  443. }
  444.  
  445.  
  446. });
  447.  
  448. $("#getUnread").bind("click", async function() {
  449.  
  450. javaex.tip({
  451. content: "获取中,请稍候...",
  452. type: "submit"
  453. });
  454. HNAPI.getUnread();
  455.  
  456.  
  457. });
  458.  
  459.  
  460. $("#likeInDynamicComments").bind("click", async function() {
  461.  
  462. let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get(
  463. "likeInDynamic_PRID");
  464. let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get(
  465. "likeInDynamic_OID");
  466.  
  467. let html = '';
  468.  
  469. html += '<div style="padding: 10px 10px 10px 0px;">'
  470. html += '<form id="likeInDynamic_form">'
  471. html += ' <div class="javaex-unit clear">'
  472. html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
  473. html += ' <div class="javaex-unit-right">'
  474. html +=
  475. ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
  476. html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
  477. html += ' </div>'
  478. html += ' </div>'
  479. html += ' <div class="javaex-unit clear">'
  480. html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
  481. html += ' <div class="javaex-unit-right">'
  482. html +=
  483. ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
  484. html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
  485. html += ' </div>'
  486. html += ' </div>'
  487. html += ' <div class="javaex-unit clear tc">'
  488. html +=
  489. ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
  490. html +=
  491. ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
  492. html += ' </div>'
  493. html += '</form>';
  494. html += '<hr class="javaex-divider"></hr>';
  495. html += '</div>';
  496.  
  497.  
  498. javaex.panel(this, {
  499. position: "right",
  500. content: html
  501. });
  502.  
  503.  
  504. // 监听点击保存按钮事件
  505. $("#likeInDynamic_yes").click(async function() {
  506. // 表单验证函数
  507. if (javaexVerify()) {
  508.  
  509. HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex
  510. .getSelectVal(
  511. "#likeInDynamic_PRID"), 1);
  512. await HNTOOL.Sleep(1000);
  513.  
  514. if (BiliData.replyAction.code == 0) {
  515.  
  516. LocalData.set("likeInDynamic_PRID", javaex.getSelectVal(
  517. "#likeInDynamic_PRID"));
  518. LocalData.set("likeInDynamic_OID", javaex.getSelectVal(
  519. "#likeInDynamic_OID"));
  520.  
  521. javaex.tip({
  522. content: "评论区点赞成功!",
  523. type: "success"
  524. });
  525. } else {
  526. javaex.tip({
  527. content: "评论区点赞失败!",
  528. type: "error"
  529. });
  530. }
  531. if (BiliData.replyAction.code == 65006) {
  532. javaex.tip({
  533. content: "请勿重复点赞!",
  534. type: "error"
  535. });
  536. }
  537. }
  538. });
  539.  
  540. // 监听点击返回按钮事件
  541. $("#likeInDynamic_no").click(async function() {
  542.  
  543. if (javaexVerify()) {
  544.  
  545. HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +
  546. javaex.getLocalStorage(
  547. "#likeInDynamic_PRID"), 0);
  548. await HNTOOL.Sleep(500);
  549.  
  550. if (BiliData.replyAction.code == 0) {
  551.  
  552. javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal(
  553. "#likeInDynamic_PRID"));
  554. javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal(
  555. "#likeInDynamic_OID"));
  556.  
  557. javaex.tip({
  558. content: "评论区取消点赞成功!",
  559. type: "success"
  560. });
  561. } else {
  562. javaex.tip({
  563. content: "评论区取消点赞失败!",
  564. type: "error"
  565. });
  566. }
  567. if (BiliData.replyAction.code == 65006) {
  568. javaex.tip({
  569. content: "请勿重复取消点赞!",
  570. type: "error"
  571. });
  572. }
  573. }
  574. });
  575.  
  576. });
  577.  
  578. $("#biliUserMsg").bind("click", async function() {
  579.  
  580.  
  581. //刷新信息
  582. HNAPI.getUserNav();
  583. await HNTOOL.Sleep(500);
  584.  
  585. let isLogin = "未登录";
  586. let vipType = "无";
  587. //判断是否成功
  588. if (BiliData.login_code == 0) {
  589.  
  590.  
  591. if (BiliData.LoginData.isLogin) {
  592. isLogin = "已登录";
  593. }
  594.  
  595. if (BiliData.LoginData.vipType == 1) {
  596. vipType = "月度大会员";
  597. } else if (BiliData.LoginData.vipType == 2) {
  598. vipType = "年度大会员";
  599. }
  600.  
  601. let html = '';
  602. html += '<div class="javaex-panel-box" style="width: 250px;">';
  603. html += ' <ul>';
  604. html += ` <p style="color: #FFF;">用户信息</p>`;
  605. html +=
  606. ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
  607. html += ` <li>用户状态:${isLogin} </li> `;
  608. html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
  609. html +=
  610. ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
  611. html += ` <li>UID${BiliData.LoginData.mid} </li> `;
  612. html +=
  613. ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
  614. html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
  615. html += ` <li>会员:${vipType} </li> `;
  616. html += ' <hr class="javaex-divider"></hr>';
  617. html += ' </ul>';
  618. html += '</div>';
  619.  
  620.  
  621. javaex.panel(this, {
  622. position: "right",
  623. content: html
  624. });
  625.  
  626. javaex.tip({
  627. content: "获取用户成功!",
  628. type: "success"
  629. });
  630.  
  631. } else {
  632. javaex.tip({
  633. content: "获取用户信息失败!",
  634. type: "error"
  635. });
  636. }
  637.  
  638.  
  639. });
  640.  
  641. $("#getAtMsg").bind("click", async function() {
  642.  
  643. if (HNAPI.getMsgfeed("at") && typeof(HNAPI.getMsgfeed("at")) != "undefined") {
  644.  
  645. javaex.tip({
  646. content: "可能中奖了!!!",
  647. type: "success"
  648. });
  649. }
  650. });
  651.  
  652.  
  653. $("#disUser").bind("click", async function() {
  654.  
  655. let html = '';
  656. html += '<div class="javaex-panel-box" style="width: 500px;">';
  657. html += ' <div class="javaex-unit clear">';
  658. html += ' <div class="javaex-unit-left ml-10 mt-10">*UID列表</div>';
  659. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  660. html +=
  661. ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
  662. html += ' </div>';
  663. html += ' </div>';
  664. html += ' <div class="javaex-unit clear tc">';
  665. html += ' <input type="button" id="disUser_block" class="javaex-btn yes" value="拉黑" />';
  666. html +=
  667. ' <input type="button" id="disUser_cancelAtt_uid" class="javaex-btn yes" value="UID取关" />';
  668. html +=
  669. ' <input type="button" id="disUser_cancelAtt_room" class="javaex-btn yes" value="房间号取关" />';
  670. html += ' </div>';
  671. html += '</div>';
  672.  
  673. javaex.panel(this, {
  674. position: "right",
  675. content: html
  676. });
  677.  
  678. let disUser_str;
  679. //拉黑
  680. $("#disUser_block").bind("click", async function() {
  681.  
  682. disUser_str = javaex.getSelectVal("#disUser_uidList");
  683. let disUser_uidList = disUser_str.split(",");
  684. let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
  685.  
  686. for (const vmid of disUserStr) {
  687.  
  688. HNAPI.batchModify(vmid.toString(), 5);
  689. await HNTOOL.Sleep(2000);
  690. }
  691. });
  692. //取关uid
  693. $("#disUser_cancelAtt_uid").bind("click", async function() {
  694. disUser_str = javaex.getSelectVal("#disUser_uidList");
  695. let disUser_uidList = disUser_str.split(",");
  696.  
  697. javaex.tip({
  698. content: "根据uid批量取关开始!!!",
  699. type: "success"
  700. });
  701.  
  702.  
  703. let J = 1;
  704.  
  705. for (let uid of disUser_uidList) {
  706.  
  707.  
  708. await HNAPI.cancelAtt(uid, 2);
  709.  
  710. javaex.tip({
  711. content: "【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" +
  712. disUser_uidList.length + ")",
  713. type: "success"
  714. });
  715. await HNTOOL.Sleep(1000);
  716. }
  717.  
  718.  
  719. alert("根据uid批量取关完成!");
  720.  
  721.  
  722. });
  723. //取关room
  724. $("#disUser_cancelAtt_room").bind("click", async function() {
  725.  
  726. javaex.tip({
  727. content: "根据房间号批量取关开始!!!",
  728. type: "success"
  729. });
  730.  
  731. disUser_str = javaex.getSelectVal("#disUser_uidList");
  732. let disUser_roomList = disUser_str.split(",");
  733.  
  734. let J = 1;
  735. for (let room of disUser_roomList) {
  736.  
  737. let uid = await HNAPI.getRoomMsg(room);
  738.  
  739. await HNTOOL.Sleep(1000);
  740.  
  741. if (uid == false) {
  742. javaex.tip({
  743. content: "uid查询失败跳过!",
  744. type: "error"
  745. });
  746. continue;
  747. }
  748.  
  749. await HNAPI.cancelAtt(uid, 2);
  750.  
  751. javaex.tip({
  752. content: "Room:" + room + "-【UID:" + uid + "】" + "取关成功!(" + (J++) +
  753. "/" + disUser_roomList.length +
  754. ")",
  755. type: "success"
  756. });
  757. await HNTOOL.Sleep(1000);
  758.  
  759.  
  760. }
  761. alert("根据房间号批量取关完成!");
  762.  
  763.  
  764. });
  765.  
  766. });
  767.  
  768. $("#getNeetCookie").bind("click", async function() {
  769.  
  770. let html = '';
  771. html += '<div class="javaex-panel-box" style="width: 750px;">';
  772. html += ' <div class="javaex-unit clear">';
  773. html += ' <div class="javaex-unit-left ml-10 mt-10">*cookie</div>';
  774. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  775. html +=
  776. ' <textarea id="neetCookie" class="javaex-desc" placeholder="获取需要的cookie,注意需要取消掉application->cookie>SESSDATA httpOnly 的对钩"></textarea>';
  777. html += ' </div>';
  778. html += ' </div>';
  779. html += ' <div class="javaex-unit clear tc">';
  780. html += ' <input type="button" id="getCookie_type1" class="javaex-btn yes" value="方式一" />';
  781. html += ' <input type="button" id="getCookie_type2" class="javaex-btn yes" value="方式二" />';
  782. html += ' <input type="button" id="getCookie_type3" class="javaex-btn yes" value="方式三" />';
  783. html += ' <input type="button" id="getCookie_copy" class="javaex-btn yes" value="复制" />';
  784. html += ' </div>';
  785. html += '</div>';
  786.  
  787. javaex.panel(this, {
  788. position: "right",
  789. content: html
  790. });
  791.  
  792. $('#getCookie_copy').bind('click', function() {
  793.  
  794. HNTOOL.copyText("neetCookie");
  795.  
  796. });
  797.  
  798. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  799. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  800. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  801.  
  802.  
  803. $("#getCookie_type1").bind("click", async function() {
  804.  
  805. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA
  806. .replace(/%25/g, "%") +
  807. "; bili_jct=" + Live_info.csrf_token +
  808. "; "
  809. document.getElementById("neetCookie").value = cookie01;
  810.  
  811. });
  812. $("#getCookie_type3").bind("click", async function() {
  813.  
  814. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA
  815. .replace(/%25/g, "%%") +
  816. "; bili_jct=" + Live_info.csrf_token +
  817. "; "
  818. document.getElementById("neetCookie").value = cookie01;
  819.  
  820. });
  821.  
  822. $("#getCookie_type2").bind("click", async function() {
  823.  
  824. var cookie02 = Live_info.uid + "\n" + Live_info.SESSDATA.replace(/%25/g, "%") +
  825. "\n" + Live_info.csrf_token;
  826. document.getElementById("neetCookie").value = cookie02;
  827. });
  828.  
  829. });
  830.  
  831. $("#arrUnique").bind("click", async function() {
  832.  
  833. let html = '';
  834. html += '<div class="javaex-panel-box" style="width: 500px;">';
  835. html += ' <div class="javaex-unit clear">';
  836. html += ' <div id="arrNub" class="javaex-unit-left ml-10 mt-10">*数组0</div>';
  837. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  838. html +=
  839. ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  840. html += ' </div>';
  841. html += ' </div>';
  842. html += ' <div class="javaex-unit clear tc">';
  843. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="去重" />';
  844. //html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="粘贴" />';
  845. html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="复制" />';
  846. html += ' </div>';
  847. html += '</div>';
  848.  
  849. javaex.panel(this, {
  850. position: "right",
  851. content: html
  852. });
  853.  
  854. $('#arrUnique_str').bind('input propertychange', function() {
  855.  
  856. $('#arrNub').text("*数组" + $(this).val().split(",").length);
  857.  
  858. });
  859. $('#arrUnique_copy').bind('click', function() {
  860.  
  861. HNTOOL.copyText("arrUnique_str");
  862.  
  863. });
  864.  
  865.  
  866.  
  867.  
  868. $("#arrUnique_beg").bind("click", async function() {
  869.  
  870. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  871. let arrUnique_uidList = arrUnique_str.split(",");
  872.  
  873. let new_arr = HNTOOL.arrUnique(arrUnique_uidList);
  874.  
  875. document.getElementById("arrUnique_str").value = new_arr.toString();
  876.  
  877. $('#arrNub').text("*数组" + new_arr.length);
  878.  
  879. });
  880.  
  881. });
  882.  
  883. $("#yunBatchFollow").bind("click", async function() {
  884.  
  885.  
  886. let tx_room = await HNAPI.getMyJson(HN_YUN_URL.tx_room);
  887. let notice = await HNAPI.getMyJson(HN_YUN_URL.notice);
  888. let blacklist = notice.config.blacklist.split(",");
  889. let num1 = 0;
  890. let num2 = 0;
  891. //获取关注
  892. let followList = await HNAPI.getAllFollow();
  893. await HNTOOL.Sleep(1000);
  894.  
  895. let intersection = followList.filter(function(val) {
  896. return (blacklist.map(Number)).indexOf(val) > -1
  897. }); //交集
  898.  
  899. for (let room of tx_room) {
  900. let uid = await HNAPI.getRoomMsg(room);
  901. if (followList.indexOf(uid) > -1) {
  902. await HNAPI.cancelAtt(uid, 2);
  903. HNTOOL.console("取关 \n 天选相关:" + uid + "\n room:" + room, "FF0000");
  904. num1++;
  905. } else {
  906. HNTOOL.console("未关注:" + uid + "---room:" + room);
  907. }
  908. await HNTOOL.Sleep(1000);
  909. }
  910.  
  911. for (let uid2 of intersection) {
  912.  
  913. if (uid2 == 99439379) {
  914. continue;
  915. }
  916. await HNAPI.cancelAtt(uid2, 2);
  917. HNTOOL.console("取关 \n 动态相关:" + uid2, "FF0000");
  918. await HNTOOL.Sleep(1000);
  919. }
  920.  
  921. alert("取关完成: \n 【天选相关-" + num1 + "】\n【动态相关-" + intersection.length + "】");
  922.  
  923.  
  924. });
  925.  
  926. $("#batchFollow").bind("click", async function() {
  927.  
  928. var thisUPName = $("#h-name").text();
  929.  
  930.  
  931. let html = '';
  932. html += '<div class="javaex-panel-box" style="width: 600px;">';
  933. html += ' <div class="javaex-unit clear">';
  934. html += ' <div id="followNub" class="javaex-unit-left ml-10 mt-10">*关注列表0</div>';
  935. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  936. html +=
  937. ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
  938. html += ' </div>';
  939. html += ' </div>';
  940. html += ' <div class="javaex-unit clear tc" >';
  941. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  942. //html += ' <input type="button" id="check_follow" class="javaex-btn yes tc" value="筛选关注" />';
  943. html +=
  944. ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="获取全部关注" />';
  945. html += ' </div>';
  946. html += '</div>';
  947.  
  948. javaex.panel(this, {
  949. position: "right",
  950. content: html
  951. });
  952.  
  953. $('#batchFollow_uidList').bind('input propertychange', function() {
  954.  
  955. $('#followNub').text("*关注列表" + $(this).val().split(",").length);
  956.  
  957. });
  958.  
  959. $("#disFollow_thisUp").bind("click", async function() {
  960.  
  961. HNAPI.batchModify(BiliData.this_uid, 5);
  962.  
  963. });
  964.  
  965. $("#Follow_thisUp").bind("click", async function() {
  966.  
  967. HNAPI.batchModify(BiliData.this_uid);
  968.  
  969. });
  970.  
  971. $("#batchFollow_beg").bind("click", async function() {
  972.  
  973. let mid_str = javaex.getSelectVal("#batchFollow_uidList");
  974. let mid_list = mid_str.split(",");
  975.  
  976. let all_ollow = await HNAPI.getAllFollow();
  977. await HNTOOL.Sleep(1000);
  978. //删除已关注的数据
  979. for (let i in mid_list) {
  980.  
  981. if (all_ollow.indexOf(parseInt(mid_list[i])) != -1) {
  982. mid_list.splice(i, 1);
  983. }
  984.  
  985. }
  986.  
  987. document.getElementById("batchFollow_uidList").value = mid_list.toString();
  988. $('#followNub').text("*关注列表" + mid_list.length);
  989.  
  990. let mid_Lists = HNTOOL.split_array(mid_list, 15);
  991. for (const mids of mid_Lists) {
  992.  
  993. let rel = await HNAPI.batchModify(mids.toString());
  994. if (rel == 2) {
  995. break;
  996. }
  997. await HNTOOL.Sleep(8000);
  998. }
  999.  
  1000. alert("关注完成!")
  1001.  
  1002. });
  1003.  
  1004. $("#crawler_follow").bind("click", async function() {
  1005.  
  1006. let followList = await HNAPI.getAllFollow();
  1007. document.getElementById("batchFollow_uidList").value = followList.toString();
  1008.  
  1009. });
  1010.  
  1011. $("#check_follow").bind("click", async function() {
  1012.  
  1013. let followList = await HNAPI.getAllFollow();
  1014. await HNTOOL.Sleep(1000);
  1015. let fList = [];
  1016. let fansmin = prompt("请输入最小粉丝数量", "5000");
  1017. let fansmax = prompt("请输入最大粉丝数量", "-1");
  1018. let fansrole = window.confirm('是否认证?');
  1019. //let fansmassage = window.confirm('是否有过私信?');
  1020. let fansfollow = window.confirm('是否执行取消关注?');
  1021.  
  1022. for (const mid of followList) {
  1023.  
  1024. if (fansmin == null || fansmax == null) {
  1025. break;
  1026. }
  1027.  
  1028.  
  1029. let midCard = await HNAPI.getInterfaceCard(mid);
  1030. await HNTOOL.Sleep(1000);
  1031. fansmax = fansmax == -1 ? Infinity : fansmax;
  1032. if (midCard.fans > fansmax || midCard.fans < fansmin) {
  1033. continue;
  1034. }
  1035.  
  1036. if ((midCard.official_verify.type != -1) == fansrole) {
  1037. fList.push(mid);
  1038. } else {
  1039. fList.push(mid);
  1040. }
  1041.  
  1042.  
  1043.  
  1044. if (fansfollow) {
  1045.  
  1046. await HNAPI.cancelAtt(mid, 2);
  1047. console.log(mid + "---" + midCard.name + "取消关注!!!")
  1048. await HNTOOL.Sleep(1000);
  1049. }
  1050. document.getElementById("batchFollow_uidList").value = fList.toString();
  1051.  
  1052. }
  1053.  
  1054.  
  1055.  
  1056. });
  1057.  
  1058.  
  1059. });
  1060.  
  1061. $("#batchTargetMedal").bind("click", async function() {
  1062.  
  1063.  
  1064. let html = '';
  1065. html += '<div class="javaex-panel-box" style="width: 600px;">';
  1066. html += ' <div class="javaex-unit clear">';
  1067. html += ' <div id="targetNub" class="javaex-unit-left ml-10 mt-10">*房间列表0</div>';
  1068. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  1069. html +=
  1070. ' <textarea id="batchTargetMedal_roomlist" class="javaex-desc" placeholder="特别注意:请填写用户真实房间号,多个用英文逗号,隔开!!"></textarea>';
  1071. html += ' </div>';
  1072. html += ' </div>';
  1073. html += ' <div class="javaex-unit clear tc" >';
  1074. html +=
  1075. ' <input type="button" id="batchTargetMedal_ym" class="javaex-btn yes" value="一毛勋章" />';
  1076. html +=
  1077. ' <input type="button" id="batchTargetMedal_ykl" class="javaex-btn yes" value="银克拉" />';
  1078. html += ' </div>';
  1079. html += '</div>';
  1080.  
  1081. javaex.panel(this, {
  1082. position: "right",
  1083. content: html
  1084. });
  1085.  
  1086. $('#batchTargetMedal_roomlist').bind('input propertychange', function() {
  1087.  
  1088. $('#targetNub').text("*房间列表" + $(this).val().split(",").length);
  1089.  
  1090. });
  1091.  
  1092. $("#batchTargetMedal_ym").bind("click", async function() {
  1093.  
  1094. let room_str = javaex.getSelectVal("#batchTargetMedal_roomlist");
  1095. let room_list = room_str.split(",");
  1096.  
  1097.  
  1098. for (const room of room_list) {
  1099.  
  1100. let uid = await HNAPI.getRoomMsg(room);
  1101. await HNTOOL.Sleep(500);
  1102.  
  1103. if (uid == false) {
  1104.  
  1105. javaex.tip({
  1106. content: room + "获取勋章失败!",
  1107. type: "error"
  1108. });
  1109.  
  1110. continue;
  1111. }
  1112.  
  1113. let result = await HNAPI.getFansMedalInfo(uid, room);
  1114.  
  1115. if (result) {
  1116. javaex.tip({
  1117. content: room + "勋章已经存在!",
  1118. type: "success"
  1119. });
  1120. HNTOOL.console(room + "勋章已经存在!");
  1121. continue;
  1122. }
  1123.  
  1124. let sendGold_data = {
  1125. 'uid': Live_info.uid,
  1126. 'gift_id': 31164,
  1127. 'ruid': uid,
  1128. 'send_ruid': 0,
  1129. 'gift_num': 1,
  1130. 'coin_type': 'gold',
  1131. 'bag_id': 0,
  1132. 'platform': 'pc',
  1133. 'biz_code': 'Live',
  1134. 'biz_id': room,
  1135. 'platform': 'pc',
  1136. 'storm_beat_id': 0,
  1137. 'metadata': '',
  1138. 'price': 100,
  1139. 'csrf_token': Live_info.csrf_token,
  1140. 'csrf': Live_info.csrf_token,
  1141. 'visit_id': HNTOOL.getvisit_id()
  1142. };
  1143.  
  1144. let sendGold_rul = await HNAPI.basePost(
  1145. "https://api.live.bilibili.com/xlive/revenue/v1/gift/sendGold",
  1146. sendGold_data);
  1147. let tiplog = "";
  1148.  
  1149. if (sendGold_rul.code === 0) {
  1150. tiplog = "粉丝团灯牌" + room + "投喂成功!";
  1151.  
  1152. } else if ((sendGold_rul.err != undefined || sendGold_rul.code == 200013)) {
  1153. HNTOOL.console(sendGold_rul.message);
  1154. alert(sendGold_rul.message);
  1155. break;
  1156.  
  1157. } else {
  1158. tiplog = "粉丝团灯牌投喂失败" + sendGold_rul.message;
  1159. }
  1160.  
  1161. javaex.tip({
  1162. content: tiplog,
  1163. type: "success"
  1164. });
  1165. HNTOOL.console(tiplog);
  1166. await HNTOOL.Sleep(3000);
  1167. }
  1168.  
  1169. alert("批量送b克拉完毕!")
  1170.  
  1171.  
  1172. });
  1173.  
  1174. $("#batchTargetMedal_ykl").bind("click", async function() {
  1175.  
  1176. let room_str = javaex.getSelectVal("#batchTargetMedal_roomlist");
  1177. let room_list = room_str.split(",");
  1178.  
  1179.  
  1180. for (const room of room_list) {
  1181.  
  1182. let uid = await HNAPI.getRoomMsg(room);
  1183. await HNTOOL.Sleep(500);
  1184.  
  1185. if (uid == false) {
  1186.  
  1187. javaex.tip({
  1188. content: room + "获取勋章失败!",
  1189. type: "error"
  1190. });
  1191.  
  1192. continue;
  1193. }
  1194.  
  1195. let result = await HNAPI.getFansMedalInfo(uid, room);
  1196.  
  1197. if (result) {
  1198. javaex.tip({
  1199. content: room + "勋章已经存在!",
  1200. type: "success"
  1201. });
  1202. continue;
  1203. }
  1204. //获取包裹列表
  1205. let giftRes = await HNAPI.getGiftList(room);
  1206.  
  1207. if (giftRes == false) {
  1208.  
  1209. continue;
  1210. }
  1211.  
  1212. let bag_id = null;
  1213.  
  1214. for (let gr of giftRes) {
  1215.  
  1216. if (gr.gift_id == 3) {
  1217.  
  1218. bag_id = gr.bag_id;
  1219. break;
  1220. }
  1221.  
  1222. }
  1223. if (bag_id != null) {
  1224.  
  1225. await HNAPI.bagSendGift(uid, room, bag_id);
  1226. }
  1227.  
  1228.  
  1229.  
  1230. await HNTOOL.Sleep(3000);
  1231. }
  1232.  
  1233. alert("批量送b克拉完毕!")
  1234.  
  1235.  
  1236. });
  1237.  
  1238.  
  1239. });
  1240.  
  1241.  
  1242. $("#HNSetup").bind("click", async function() {
  1243.  
  1244. var CONFIG = HNTOOL.getConfig();
  1245.  
  1246.  
  1247. let html = '';
  1248.  
  1249. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  1250. html += '<form id="HNGG_SETUP">'
  1251. html += ' <div class="javaex-unit clear">'
  1252. html +=
  1253. ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Qmsg-key</p></div>'
  1254. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  1255. html +=
  1256. ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  1257. html +=
  1258. ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  1259. html += ' </div>'
  1260. html += ' <div class="javaex-unit-left mr-10">'
  1261. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  1262. html += ' </div>'
  1263. html += ' </div>'
  1264. html += '</form>';
  1265. html += '<div class="javaex-unit clear tc">';
  1266. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  1267. html += '</div>';
  1268. html += '<hr class="javaex-divider"></hr>';
  1269. html += '</div>';
  1270.  
  1271. javaex.panel(this, {
  1272. position: "right",
  1273. content: html
  1274. });
  1275.  
  1276.  
  1277. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  1278.  
  1279. $("#switch-qsmg").bind("click", function() {
  1280.  
  1281. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  1282.  
  1283. })
  1284.  
  1285.  
  1286. $("#HNSetup_save").bind("click", async function() {
  1287.  
  1288.  
  1289. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  1290.  
  1291. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  1292.  
  1293. javaex.tip({
  1294. content: "设置成功!",
  1295. type: "success"
  1296. });
  1297.  
  1298. });
  1299.  
  1300. });
  1301.  
  1302. //
  1303. $("#getUpMassage").bind("click", async function() {
  1304.  
  1305.  
  1306. let html = '';
  1307.  
  1308. html += '<div style="padding: 10px 10px 10px 0px;">'
  1309. html += '<form id="getUpMassage_form">'
  1310. html += ' <div class="javaex-unit clear">'
  1311. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  1312. html += ' <div class="javaex-unit-left mr-10">'
  1313. html +=
  1314. ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  1315. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  1316. html += ' </div>'
  1317. html += ' <div class="javaex-unit-right mr-10">'
  1318. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  1319. html += ' </div>'
  1320. html += ' </div>'
  1321. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  1322. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  1323. html += ' <thead>'
  1324. html += ' <tr><th>内容</th><th>详情</th></tr>'
  1325. html += ' </thead>'
  1326. html += ' <tbody id="upMsgTbody">'
  1327.  
  1328. html += ' </tbody>'
  1329. html += '</table> '
  1330. html += '</div>'
  1331. html += '</form>';
  1332. html += '<hr class="javaex-divider"></hr>';
  1333. html += '</div>';
  1334.  
  1335.  
  1336. javaex.panel(this, {
  1337. position: "right",
  1338. content: html
  1339. });
  1340.  
  1341. javaex.table({
  1342. id: "upMsgTable",
  1343. isDragColWidth: true, // 是否允许拖动改变列宽
  1344. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  1345. leftFixedColNum: 2, // 左侧固定列数
  1346. rightFixedColNum: 1, // 右侧固定列数
  1347. sort: {
  1348. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  1349. "2": "update_time"
  1350. },
  1351. sortCallback: function(rtn) {
  1352. //console.log(rtn.sortArr);
  1353. }
  1354. });
  1355.  
  1356. //
  1357. $("#getUpMsg").click(async function() {
  1358.  
  1359. let thismid = javaex.getSelectVal("#up_uid");
  1360. await HNAPI.userInfo(thismid)
  1361.  
  1362. let temp = await HNAPI.getUpCard(thismid);
  1363.  
  1364.  
  1365. await HNTOOL.Sleep(500);
  1366.  
  1367.  
  1368. if (temp != false) {
  1369. let data = BiliData.upCard.data;
  1370.  
  1371. let html = ``;
  1372. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  1373. html +=
  1374. `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  1375. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  1376. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  1377. html +=
  1378. `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  1379. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  1380. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  1381. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  1382. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  1383. html +=
  1384. `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  1385. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  1386. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  1387.  
  1388.  
  1389. $("#upMsgTbody").empty();
  1390. $("#upMsgTbody").append(html);
  1391. }
  1392.  
  1393.  
  1394. });
  1395. //点击放大
  1396. /* $("img").click(function() {
  1397. javaex.dialog({
  1398. type : "image", // 弹出层类型
  1399. url : $(this).attr("src") // 图片地址
  1400. });
  1401. });*/
  1402.  
  1403. });
  1404.  
  1405.  
  1406. $("#everyDayTask").bind("click", async function() {
  1407.  
  1408. let videoAid = 758643487;
  1409. let videoCid = 357521682;
  1410. let videoBvid = "BV1V64y1d7ed";
  1411. let videoMid = 99439379;
  1412.  
  1413. //查询每日奖励状态
  1414. let rewardData = await HNAPI.get_exp_reward();
  1415. await HNTOOL.Sleep(2000);
  1416.  
  1417. //1.每日登录
  1418. if (rewardData.login == false) {
  1419.  
  1420. await HNAPI.clickNow();
  1421. await HNTOOL.Sleep(3000);
  1422. }
  1423.  
  1424. //2.直播签到
  1425. await HNAPI.DoSign();
  1426. await HNTOOL.Sleep(3000);
  1427.  
  1428. //3.专栏投币
  1429. let accountData = await HNAPI.get_account_exp();
  1430. await HNTOOL.Sleep(2000);
  1431. if (rewardData.coins < 40) {
  1432. //2. 获取分区最新专栏列表
  1433. let articleData = await HNAPI.getArticleRecommends();
  1434. await HNTOOL.Sleep(2000);
  1435. let article = articleData[HNTOOL.random(0, 9)];
  1436. let article2 = articleData[HNTOOL.random(9, 18)];
  1437.  
  1438. //await HNAPI.addVideoCoin(videoAid);//视频投币
  1439. await HNAPI.addArticleCoin(article.id, article.author.mid); //专栏投币
  1440. await HNTOOL.Sleep(2000);
  1441. if (accountData / 20 == 1) {
  1442. await HNAPI.addArticleCoin(article2.id, article2.author.mid); //专栏投币
  1443. }
  1444. }
  1445.  
  1446. //获取分区最新视频列表 http://api.bilibili.com/x/web-interface/dynamic/region pn=1 ps=20 rid=21
  1447. let archivesList = await HNAPI.getDynamicRegion();
  1448. await HNTOOL.Sleep(2000);
  1449. let num = HNTOOL.random(0, archivesList.length - 1);
  1450.  
  1451. if (archivesList != false && num != 2) {
  1452. videoAid = archivesList[num].aid;
  1453. videoBvid = archivesList[num].bvid;
  1454. videoCid = archivesList[num].cid;
  1455. videoMid = archivesList[num].owner.mid;
  1456. }
  1457. //4.每日观看视频
  1458. if (rewardData.watch == false) {
  1459. await HNAPI.watchOneVideo(videoBvid, videoMid);
  1460. await HNTOOL.Sleep(2000);
  1461. }
  1462. //5.每日分享视频
  1463. if (rewardData.share == false) {
  1464.  
  1465. await HNAPI.addShare(videoAid);
  1466. await HNTOOL.Sleep(2000);
  1467. }
  1468.  
  1469. //6.日常随机转发一个视频
  1470.  
  1471. await HNAPI.shareOneVideo(videoAid, videoMid, "分享视频");
  1472. if (num == 3 || num == 16) {
  1473. let randomStr = await HNTOOL.getRandomString();
  1474. await HNAPI.shareOneVideo("975082514", "397516636", randomStr);
  1475. }
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481. });
  1482.  
  1483.  
  1484. $("#batch_dynamic_like").bind("click", async function() {
  1485.  
  1486. //let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/bilicat_config.json";
  1487. //let jsons = await HNAPI.getMyJson(url);
  1488. let myjson = BILICAT_CONFIG.batch_dynamic_like;
  1489.  
  1490. for (let value of myjson) {
  1491.  
  1492. await HNAPI.likeDynamic(value.dynamic_id);
  1493. console.log("点赞成功:https://t.bilibili.com/" + value.dynamic_id + "?tab=2")
  1494. await HNTOOL.Sleep(2000);
  1495. }
  1496.  
  1497. });
  1498.  
  1499.  
  1500. $("#dynamicActivity").bind("click", async function() {
  1501.  
  1502. javaex.tip({
  1503. content: "动态转发开始!",
  1504. type: "success"
  1505. });
  1506.  
  1507. let dynamic_id_list = await HNTOOL.getLatestDynamic();
  1508. console.log("共" + dynamic_id_list.length + "条动态")
  1509. let allFollow = await HNAPI.getAllFollow();
  1510. //let save_dynamic_id = await HNAPI.getSpaceNotice();
  1511. await HNTOOL.Sleep(2000);
  1512. console.log("随机延迟30-40分钟发布一个随机动态");
  1513. await HNTOOL.doOneDynamic(HNTOOL.random(30, 40) * 60 * 1000);
  1514.  
  1515. for (let index = 0, len = dynamic_id_list.length; index < len; index++) {
  1516.  
  1517. let value = dynamic_id_list[index];
  1518.  
  1519. let dynamic_data = await HNAPI.getdynamicData(value);
  1520.  
  1521. if (dynamic_data.hasOwnProperty('card') == false) {
  1522. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 失效!!!");
  1523. continue;
  1524. }
  1525. let dynamic_id = dynamic_data.card.desc.dynamic_id_str;
  1526. let dynamic_type = 17;
  1527. await HNTOOL.Sleep(2000);
  1528.  
  1529. if (dynamic_data.card.desc.is_liked == 1) {
  1530. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 已转发,舍弃!!!");
  1531.  
  1532. //if (dynamic_data.card.desc.type == 2 || dynamic_data.card.desc.type == 4) {
  1533. if (dynamic_data.card["extension"] != undefined) {
  1534. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1535. await HNTOOL.Sleep(2000);
  1536.  
  1537. if (lNoticeData["lottery_result"] != undefined) {
  1538.  
  1539. console.log(
  1540. "【" + index + "已过开奖时间】\n" +
  1541. "用户:" + dynamic_data.card.desc.user_profile.info.uname + "\n" +
  1542. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1543. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n" +
  1544. "名单:" + JSON.stringify(lNoticeData.lottery_result)
  1545. );
  1546. }
  1547.  
  1548. }
  1549. continue;
  1550. }
  1551. //判断是否过期
  1552. if (dynamic_data.card["extension"] != undefined) {
  1553. dynamic_type = 11;
  1554. dynamic_id = dynamic_data.card.desc.rid;
  1555. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1556. await HNTOOL.Sleep(2000);
  1557.  
  1558. if (lNoticeData["lottery_result"] != undefined) {
  1559.  
  1560.  
  1561. console.log(
  1562. "【" + index + "已过开奖时间】\n" +
  1563. "用户:" + dynamic_data.card.desc.user_profile.info.uname + "\n" +
  1564. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1565. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n" +
  1566. "名单:" + JSON.stringify(lNoticeData.lottery_result)
  1567. );
  1568. continue;
  1569. }
  1570.  
  1571. }
  1572.  
  1573. if (allFollow.indexOf(dynamic_data.card.desc.uid) == -1) {
  1574.  
  1575. let res = await HNAPI.batchModify(dynamic_data.card.desc.uid);
  1576. if (dynamic_data.card.desc.type == 2 && res == false) {
  1577. console.log("【" + index + "】关注官方动态up失败,检查账号是否异常,风控等!!!https://t.bilibili.com/" +
  1578. value +
  1579. "?tab=2");
  1580. continue;
  1581. }
  1582. console.log("【" + index + "】关注" + dynamic_data.card.desc.uid + "成功!!!");
  1583. }
  1584.  
  1585. await HNTOOL.Sleep(1000);
  1586.  
  1587. //1.评论
  1588. await HNAPI.addReply(dynamic_id, dynamic_type);
  1589. console.log("【" + index + "】" + dynamic_id + "评论成功!!!");
  1590. await HNTOOL.Sleep(1000);
  1591. //3.点赞
  1592. await HNAPI.likeDynamic(value);
  1593. await HNTOOL.Sleep(1000);
  1594. //2.转发
  1595. let repostCard = HNTOOL.strToJson(dynamic_data.card.card);
  1596. let repostStr = HNTOOL.getRandomWordOfList(replyList);
  1597. let repostCtrl = "转发动态";
  1598. let relay_chat = null;
  1599. if (repostCard["user"]["uname"] != undefined && dynamic_data.card["extension"] == undefined) {
  1600.  
  1601. //转发内容 = 评论+'//'+'@'+用户名+':'+源内容
  1602. relay_chat = repostStr + "//@" + repostCard.user.uname + ":" + repostCard.item.content;
  1603. repostCtrl = repostCard.item.ctrl;
  1604.  
  1605. }
  1606. await HNAPI.repostDynamic(value, repostStr, repostCtrl);
  1607. await HNTOOL.Sleep(1000);
  1608. console.log("【" + index + "】动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!");
  1609.  
  1610. javaex.tip({
  1611. content: "动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!",
  1612. type: "success"
  1613. });
  1614.  
  1615. //存储标记
  1616. //await HNAPI.setNotice(value);
  1617.  
  1618. //随机延迟120 -240秒
  1619. let sleeptime = HNTOOL.random(6, 12) * 10 * 1000;
  1620. console.log("转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!")
  1621. javaex.tip({
  1622. content: "转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!",
  1623. type: "success"
  1624. });
  1625. await HNTOOL.Sleep(sleeptime);
  1626. }
  1627.  
  1628. alert("今日动态抽奖完成!!!");
  1629.  
  1630. });
  1631.  
  1632. $("#batchFollowOfbastard").bind("click", async function() {
  1633.  
  1634. if (confirm("作者个人需求开发,谨慎使用!!!\n 本功能会取关设定值以下没有认证和个人认证的的关注! \n 不确定使用请取消!")) {
  1635.  
  1636. let fansNum = prompt("请输入最低粉丝数量", "50000");
  1637.  
  1638. if (fansNum != null && fansNum != "") {
  1639. //fansNum
  1640.  
  1641. let followList = await HNAPI.getAllFollow();
  1642. console.log(followList);
  1643. await HNTOOL.Sleep(2000);
  1644.  
  1645. for (let fl of followList) {
  1646.  
  1647. if (fl == 99439379) {
  1648. await HNAPI.cancelAtt(fl, 1);
  1649. continue;
  1650. }
  1651. if (!followList.indexOf(99439379)) {
  1652.  
  1653. await HNAPI.cancelAtt(99439379, 1);
  1654. }
  1655.  
  1656. let user = await HNAPI.getCardByUID(fl);
  1657. await HNTOOL.Sleep(1000);
  1658. //0签约主播 1机构认证
  1659.  
  1660. if (user.fans < parseInt(fansNum) && /0|2|7/.test(user.Official.role)) {
  1661. await HNAPI.cancelAtt(fl, 2);
  1662.  
  1663. javaex.tip({
  1664. content: "uid:" + user.mid + "-" + user.name + "--粉丝量-" + user.fans +
  1665. "---符合条件 取关成功!!!",
  1666. type: "success"
  1667. });
  1668. console.log("---uid:" + user.mid + "\n---" + user.name + "\n---粉丝量-" + user.fans +
  1669. "\n---符合条件 取关成功!!!");
  1670.  
  1671. } else {
  1672. javaex.tip({
  1673. content: "uid:" + user.mid + "-" + user.name + "--粉丝量-" + user.fans +
  1674. "---不符合条件 取消!!!",
  1675. type: "success"
  1676. });
  1677. console.log("uid:" + user.mid + "-" + user.name + "---粉丝量-" + user.fans +
  1678. "---不符合条件 取消!!!");
  1679. }
  1680. }
  1681. }
  1682.  
  1683. }
  1684.  
  1685. });
  1686.  
  1687. $("#reserveActivity").bind("click", async function() {
  1688.  
  1689. let default_sid_list = [];
  1690. let default_sid = null;
  1691. let tiplogs = '';
  1692. let zhuanlan_sid_list = [];
  1693.  
  1694.  
  1695. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1696. if (lastSid == null) {
  1697.  
  1698. default_sid = BILICAT_CONFIG.default_sid;
  1699.  
  1700. } else {
  1701.  
  1702. default_sid = lastSid.split("&")[1];
  1703. }
  1704.  
  1705. for (var j = default_sid; j < (parseInt(default_sid) + 300000); j++) {
  1706.  
  1707. default_sid_list.push(j);
  1708. }
  1709.  
  1710. let sid_Lists = HNTOOL.split_array(default_sid_list, 1000);
  1711.  
  1712. let cat = 1;
  1713. for (const sid of sid_Lists) {
  1714.  
  1715. let submitData = {
  1716. "ids": sid.toString()
  1717. }
  1718. let sidinfolist = await HNAPI.baseGet(
  1719. "https://api.bilibili.com/x/activity/up/reserve/relation/info",
  1720. submitData);
  1721. await HNTOOL.Sleep(1000);
  1722. if (sidinfolist == false) {
  1723. continue;
  1724. }
  1725. let sdl = sidinfolist.data.list;
  1726. if (JSON.stringify(sdl) == "{}") {
  1727.  
  1728. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + (sid[0] - 1);
  1729. HNTOOL.saveConfig();
  1730.  
  1731. alert("预约结束");
  1732. break;
  1733. }
  1734. for (const sidinfo in sdl) {
  1735. let siddata = sdl[sidinfo];
  1736.  
  1737. //查询所有可预约的信息
  1738. //if (Math.round(new Date() / 1000) < siddata.livePlanStartTime
  1739. if (siddata.livePlanStartTime - Math.round(new Date() / 1000) < 24 * 60 * 60 && siddata
  1740. .type == 2 && siddata.lotteryType != 0 && siddata.state == 100) {
  1741.  
  1742.  
  1743. let tiplog1 = "\n\n --预约开奖时间:" + javaex.dateFormat(siddata.livePlanStartTime,
  1744. 'yyyy-MM-dd HH:mm:ss') +
  1745. "\n --预约SID:" + siddata.sid +
  1746. "\n --预约地址:https://space.bilibili.com/" + siddata.upmid +
  1747. "\n --预约人数:" + siddata.total + "人" +
  1748. "\n --预约奖品:" + siddata.prizeInfo.text +
  1749. "\n "
  1750.  
  1751. zhuanlan_sid_list.push({
  1752. "time": siddata.livePlanStartTime,
  1753. "tiplog": tiplog1
  1754. });
  1755.  
  1756. }
  1757. //查询当前号可预约的信息
  1758. if (Math.round(new Date() / 1000) < siddata.livePlanStartTime && siddata.type == 2 &&
  1759. siddata.lotteryType != 0 && siddata.reserveRecordCtime == 0 && siddata.state == 100) {
  1760.  
  1761.  
  1762. await HNAPI.reserveActivity(sidinfo);
  1763.  
  1764. let tiplog2 = "\n\n --预约开奖时间:" + javaex.dateFormat(siddata.livePlanStartTime,
  1765. 'yyyy-MM-dd HH:mm:ss') +
  1766. "\n --预约SID:" + siddata.sid +
  1767. "\n --预约地址:https://space.bilibili.com/" + siddata.upmid +
  1768. "\n --预约人数:" + siddata.total + "人" +
  1769. "\n --预约奖品:" + siddata.prizeInfo.text;
  1770.  
  1771. console.log(tiplog2);
  1772.  
  1773. javaex.tip({
  1774. content: tiplog2,
  1775. type: "success"
  1776. });
  1777. await HNTOOL.Sleep(1000);
  1778. }
  1779.  
  1780.  
  1781. }
  1782. javaex.tip({
  1783. content: "查询预约活动中!",
  1784. type: "success"
  1785. });
  1786. }
  1787.  
  1788. zhuanlan_sid_list.sort(HNTOOL.sortByArr(['time'], true));
  1789.  
  1790. for (let s of zhuanlan_sid_list) {
  1791. tiplogs += s.tiplog;
  1792. }
  1793. //console.log(tiplogs);
  1794.  
  1795. });
  1796.  
  1797.  
  1798.  
  1799. $("#linshiActivity").bind("click", async function() {
  1800.  
  1801. let html = '';
  1802. html += '<div class="javaex-panel-box" style="width: 600px;">';
  1803. html += ' <div class="javaex-unit clear">';
  1804. html += ' </div>';
  1805. html += ' <div class="javaex-unit clear tc" >';
  1806. html += ' <input type="button" id="linshi1" class="javaex-btn yes" value="临时1" />';
  1807. html += ' <input type="button" id="linshi2" class="javaex-btn yes" value="临时2" />';
  1808. html += ' </div>';
  1809. html += '</div>';
  1810.  
  1811. javaex.panel(this, {
  1812. position: "right",
  1813. content: html
  1814. });
  1815.  
  1816. $("#linshi1,#linshi2").bind("click", async function() {
  1817.  
  1818. alert("暂无");
  1819. });
  1820. });
  1821.  
  1822.  
  1823. $("#jury_case").bind("click", async function() {
  1824.  
  1825. let bln = window.confirm('是否立即执行?【确定:只会执行一次】;【取消:0:10(5H)】;');
  1826.  
  1827. if (bln) {
  1828. HNTOOL.console("风纪开始!")
  1829. HNTOOL.jury_case();
  1830. } else {
  1831. for (var i = 0; i < 1; i--) {
  1832.  
  1833. let now = new Date();
  1834. let hour = now.getHours();
  1835. let minu = now.getMinutes();
  1836. HNTOOL.console("风纪运行中……");
  1837.  
  1838. if ((hour == 0 || HNTOOL.isInteger(hour / 6)) && minu == 10) {
  1839. HNTOOL.console("风纪开始到达预定时间开始执行!")
  1840. HNTOOL.jury_case();
  1841. }
  1842.  
  1843. await HNTOOL.Sleep(50000);
  1844. }
  1845. }
  1846.  
  1847. });
  1848.  
  1849. $("#plateActivity").bind("click", async function() {
  1850.  
  1851. //获取轮盘数据
  1852.  
  1853. let url = "https://gitcode.net/qq_42688926/bilicat/-/raw/master/hnconfig/activities.json";
  1854. let myjson = await HNAPI.getMyJson(url);
  1855. let lmt = 0;
  1856. let k = 20; //重试次数 防止卡主
  1857. let giftArr = [];
  1858. let endAtion = [];
  1859.  
  1860. javaex.tip({
  1861. content: "开始参加轮盘!!!",
  1862. type: "success"
  1863. });
  1864.  
  1865. await HNAPI.getUserNav();
  1866. await HNTOOL.Sleep(1500);
  1867.  
  1868.  
  1869. for (const json of myjson.acriviries_type1) {
  1870. //let x = json.name;
  1871. for (let i = 0; i < 10; i++) {
  1872. //1.结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1873. let resout = await HNAPI.addLotteryTimes(json.sid);
  1874.  
  1875. await HNTOOL.Sleep(200);
  1876. if (resout == 1) {
  1877.  
  1878. endAtion.push(json.name + ":活动已结束!");
  1879. javaex.tip({
  1880. content: json.name + "活动已结束!",
  1881. type: "success"
  1882. });
  1883.  
  1884. break;
  1885. }
  1886. if (resout != 0 && resout != 1) {
  1887.  
  1888. javaex.tip({
  1889. content: json.name + resout,
  1890. type: "error"
  1891. });
  1892.  
  1893. break;
  1894. }
  1895.  
  1896. if (resout == 0) {
  1897. //2.查询次数
  1898. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1899. continue;
  1900. }
  1901.  
  1902. }
  1903.  
  1904. javaex.tip({
  1905. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1906. type: "success"
  1907. });
  1908.  
  1909. await HNTOOL.Sleep(1000);
  1910.  
  1911. for (let i = 0; i < lmt; i++) {
  1912. //3、执行抽奖
  1913. let gift = await HNAPI.lotteryDo(json.sid, json.name);
  1914.  
  1915. if (gift == true) {
  1916. javaex.tip({
  1917. content: "点击过快,9秒后自动重试!!!",
  1918. type: "error"
  1919. });
  1920. i--;
  1921. k--;
  1922. }
  1923.  
  1924. if (gift == false || k == 0) {
  1925. break;
  1926. }
  1927.  
  1928. if (gift != "未中奖0" && gift != true) {
  1929. giftArr.push(json.name + "奖品为:" + gift + "\n");
  1930.  
  1931. break;
  1932. } else {
  1933. javaex.tip({
  1934. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  1935. type: "success"
  1936. });
  1937. }
  1938. await HNTOOL.Sleep(6000);
  1939.  
  1940. }
  1941.  
  1942.  
  1943. }
  1944.  
  1945. for (const json2 of myjson.acriviries_type2) {
  1946.  
  1947. let submitData1 = {
  1948. "act_id": json2.act_id,
  1949. "share_type": 1,
  1950. "visit_id": "",
  1951. "csrf_token": Live_info.csrf_token,
  1952. "csrf": Live_info.csrf_token,
  1953. }
  1954.  
  1955. let submitReul1 = await HNAPI.basePost(
  1956. "https://api.live.bilibili.com/xlive/activity-interface/v1/task/UserShare", submitData1
  1957. );
  1958. await HNTOOL.Sleep(1000);
  1959.  
  1960. let submitData2 = {
  1961. "act_id": json2.act_id
  1962. }
  1963. let submitReul2 = await HNAPI.baseGet(
  1964. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/info",
  1965. submitData2);
  1966. await HNTOOL.Sleep(1000);
  1967.  
  1968. let task = submitReul2.data.task_list[0];
  1969. if (task) {
  1970. let submitData3 = {
  1971. "act_id": json2.act_id,
  1972. "task_id": task.task_id,
  1973. "cycle_id": task.task_cycle_id,
  1974. "level_id": 1,
  1975. "visit_id": "",
  1976. "csrf_token": Live_info.csrf_token,
  1977. "csrf": Live_info.csrf_token,
  1978. }
  1979.  
  1980. await HNAPI.basePost(
  1981. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/getaward",
  1982. submitData3);
  1983. await HNTOOL.Sleep(3000);
  1984.  
  1985. await HNAPI.baseGet(
  1986. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/info",
  1987. submitData2);
  1988. await HNTOOL.Sleep(1000);
  1989.  
  1990. let submitData4 = {
  1991. "id": json2.id,
  1992. "count": 1,
  1993. "platform": "web",
  1994. "_": Math.round(new Date()),
  1995. "visit_id": "",
  1996. "csrf_token": Live_info.csrf_token,
  1997. "csrf": Live_info.csrf_token,
  1998. }
  1999.  
  2000. let submitReul4 = await HNAPI.basePost(
  2001. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  2002. submitData4);
  2003. await HNTOOL.Sleep(1000);
  2004. if (submitReul4 == false) {
  2005. HNTOOL.console(json2.act_id + ":失败!");
  2006. continue;
  2007. }
  2008. if (submitReul4.err != undefined) {
  2009.  
  2010. HNTOOL.console("直播转盘:" + json2.act_id + ":" + submitReul4.err);
  2011. continue;
  2012. }
  2013. HNTOOL.console("直播转盘:" + json2.act_id + ":" + submitReul4.data.text[0]);
  2014.  
  2015. giftArr.push("直播转盘:" + json2.act_id + ":" + submitReul4.data.text[0] + "\n");
  2016. }
  2017.  
  2018.  
  2019. }
  2020.  
  2021.  
  2022. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:\n` + (
  2023. giftArr.length == 0 ? "未中奖" : giftArr.toString()));
  2024.  
  2025. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `\n 中奖详情:` + (giftArr.length == 0 ? "未中奖" : giftArr
  2026. .toString()));
  2027.  
  2028.  
  2029. });
  2030.  
  2031.  
  2032. $("#dynamicBatchFollow").bind("click", async function() {
  2033.  
  2034. let followList = await HNAPI.getAllFollow();
  2035. //let jsons = await HNAPI.getMyJson("https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/bilicat_config.json");
  2036.  
  2037. let myjson = BILICAT_CONFIG.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 default_data = BILICAT_CONFIG.Dynamic_article_uids;
  4844.  
  4845. let latestDynamic = await HNAPI.getTodayDynamicList(default_data[0], 3);
  4846. await HNTOOL.Sleep(1000);
  4847. let ldList = [];
  4848. let ldList2 = [];
  4849. for (let ld1 of latestDynamic) {
  4850.  
  4851. let ld = await HNTOOL.getDynamicIdList(ld1);
  4852. await HNTOOL.Sleep(1000);
  4853. ldList = ldList.concat(ld);
  4854. }
  4855.  
  4856. let latestDynamic2 = await HNAPI.getTodayDynamicList(default_data[1], 2);
  4857. await HNTOOL.Sleep(1000);
  4858.  
  4859. for (let ld2 of latestDynamic) {
  4860.  
  4861. let ld = await HNTOOL.getDynamicIdList(ld2);
  4862. await HNTOOL.Sleep(1000);
  4863. ldList2 = ldList2.concat(ld);
  4864. }
  4865. ldList.push.apply(ldList, ldList2);
  4866.  
  4867. let result = HNTOOL.arrUnique(ldList, false);
  4868.  
  4869. return result;
  4870.  
  4871. },
  4872.  
  4873. getDynamicIdList: async function(latestDynamic) {
  4874.  
  4875.  
  4876.  
  4877. return new Promise((resolve) => {
  4878. Ajax.get({
  4879. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  4880. queryStringsObj: {
  4881.  
  4882. },
  4883. dataType: "text/html; charset=utf-8",
  4884. hasCookies: true,
  4885. success: responseText => {
  4886. let datalist = HNTOOL.httpString(responseText);
  4887. let dls;
  4888. let returnlist = [];
  4889. if (datalist != undefined && datalist.length > 0) {
  4890. for (let dl of datalist) {
  4891.  
  4892. let len = dl.indexOf("?");
  4893. if (len == -1) {
  4894. dl += "?tab=2";
  4895. }
  4896. dls = dl.substring(dl.indexOf("?") - 18, dl.indexOf("?"));
  4897. if (dls == false ||
  4898. dls == null ||
  4899. dl.indexOf("read") > -1 ||
  4900. dl.indexOf("html") > -1 ||
  4901. dl.indexOf("pixiv") > -1 ||
  4902. returnlist.indexOf(dls) > -1) {
  4903. continue;
  4904. }
  4905.  
  4906. returnlist.push(dls);
  4907.  
  4908. }
  4909.  
  4910. resolve(HNTOOL.arrUnique(returnlist, false));
  4911. } else {
  4912. resolve(false);
  4913. }
  4914. }
  4915. })
  4916. });
  4917. },
  4918.  
  4919. httpString: function(s) {
  4920. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  4921. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  4922. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4923. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4924. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  4925. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  4926. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  4927. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  4928. s = s.match(reg);
  4929. console.log(s)
  4930. return (s)
  4931. },
  4932.  
  4933. saveConfig: function() {
  4934.  
  4935. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  4936. /* javaex.tip({
  4937. content: "配置保存成功!",
  4938. type: "success"
  4939. }); */
  4940.  
  4941. },
  4942.  
  4943. copyText: function(domId) {
  4944. let btn = document.getElementById(domId);
  4945. btn.select();
  4946. if (document.execCommand('copy')) {
  4947. document.execCommand('copy');
  4948. javaex.tip({
  4949. content: "复制成功!",
  4950. type: "success"
  4951. });
  4952. }
  4953.  
  4954. },
  4955. /**
  4956. * s数组去重并排序
  4957. */
  4958.  
  4959. arrUnique: function(ary, isSort) {
  4960.  
  4961. if (isSort == undefined) {
  4962. isSort = true
  4963. }
  4964. let obj = {};
  4965. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  4966. let item = ary[i]
  4967. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  4968. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  4969. // 如果没有 将这个元素添加到对象中
  4970. if (isSort) {
  4971. ary.sort((a, b) => {
  4972. return a - b
  4973. }) // 数组去重后 按升序排列
  4974. }
  4975.  
  4976. obj = null;
  4977.  
  4978. javaex.tip({
  4979. content: "已去重!",
  4980. type: "success"
  4981. });
  4982. return ary;
  4983.  
  4984. },
  4985.  
  4986. split_array: function(arr, len) {
  4987.  
  4988. let arr_length = arr.length;
  4989. let newArr = [];
  4990. for (let i = 0; i < arr_length; i += len) {
  4991. newArr.push(arr.slice(i, i + len));
  4992. }
  4993. return newArr;
  4994. },
  4995. strToJson: function(params) {
  4996. const isJSON = (str => {
  4997. if (typeof str === 'string') {
  4998. try {
  4999. const obj = JSON.parse(str);
  5000. return typeof obj === 'object' ? obj : false
  5001. } catch (_) {
  5002. console.log(str);
  5003. return false;
  5004. }
  5005. } else {
  5006. console.log(`${str}\nIt is not a string!`);
  5007. return false;
  5008. }
  5009. })(params);
  5010. return isJSON ? isJSON : {}
  5011. },
  5012.  
  5013. chackAtMsg: function() {
  5014.  
  5015. let config = HNTOOL.getConfig();
  5016. if (config.qmsg_checked == true && config.qmsg_key) {
  5017.  
  5018. document.getElementById("getAtMsg").click();
  5019.  
  5020. }
  5021.  
  5022. },
  5023.  
  5024. cssChecked: function(id, dom) {
  5025.  
  5026. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  5027.  
  5028.  
  5029. },
  5030. getConfig: function() {
  5031.  
  5032. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  5033.  
  5034. if (CONFIG == null) {
  5035. CONFIG = HN_SETUP_CONFIG;
  5036. }
  5037.  
  5038. return CONFIG;
  5039. },
  5040.  
  5041. /**
  5042. * 获取cookie 中某个键对应的值
  5043. * @param name
  5044. */
  5045.  
  5046. getCookie: function(name) {
  5047. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  5048. if (arr != null) return escape(arr[2]);
  5049. return false;
  5050. },
  5051. /**
  5052. * 得到一个字符串数组的中随机一个
  5053. * @param {List} list
  5054. */
  5055.  
  5056.  
  5057. getRandomWordOfList: function(list) {
  5058. var L = list.length;
  5059. var i = Math.ceil(Math.random() * (L - 1));
  5060.  
  5061. return list[i];
  5062. },
  5063. random: function(min, max) {
  5064.  
  5065. return Math.floor(Math.random() * (max - min)) + min;
  5066. },
  5067.  
  5068. Sleep: function(ms) {
  5069. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  5070. }
  5071.  
  5072. }
  5073.  
  5074. let errorMsg = {
  5075. "-1": "应用程序不存在或已被封禁!",
  5076. "-2": "Access Key错误!",
  5077. "-3": "API校验密匙错误!",
  5078. "-4": "调用方对该Method没有权限!",
  5079. "-101": "账号未登录!",
  5080. "-102": "账号被封停!",
  5081. "-103": "积分不足!",
  5082. "-104": "硬币不足!",
  5083. "-105": "验证码错误!",
  5084. "-106": "账号非正式会员或在适应期!",
  5085. "-107": "应用不存在或者被封禁!",
  5086. "-108": "未绑定手机!",
  5087. "-109": "未知!",
  5088. "-110": "未绑定手机!",
  5089. "-111": "csrf 校验失败!",
  5090. "-112": "系统升级中!",
  5091. "-113": "账号尚未实名认证!",
  5092. "-114": "请先绑定手机!",
  5093. "-115": "请先完成实名认证!",
  5094. "-304": "木有改动!",
  5095. "-307": "撞车跳转!",
  5096. "-400": "请求错误!",
  5097. "-401": "未认证!",
  5098. "-403": "访问权限不足!",
  5099. "-404": "啥都木有!",
  5100. }
  5101.  
  5102. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  5103. /**
  5104. *
  5105. * @param code
  5106. * @constructor
  5107. */
  5108. let chackCode = function(code) {
  5109.  
  5110. let emsg = errorMsg[code + ""];
  5111. if (emsg != null) {
  5112. javaex.tip({
  5113. content: emsg,
  5114. type: "error"
  5115. });
  5116.  
  5117. return false;
  5118. }
  5119.  
  5120. return true;
  5121. }
  5122.  
  5123.  
  5124. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  5125. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  5126.  
  5127. /*window.onbeforeunload = function() {
  5128. if (!canLeavePage()) {
  5129. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  5130. }
  5131. };*/
  5132.  
  5133.  
  5134. /**
  5135. * Ajax请求对象
  5136. */
  5137. const Ajax = (() => {
  5138. /**
  5139. * 检查options是否符合要求
  5140. * @param {object} options
  5141. * @returns {boolean}
  5142. */
  5143. function checkOptions(options) {
  5144. let result = false;
  5145. if (typeof options !== 'object') {
  5146. console.warn('类型错误: typeof Options !== Object');
  5147. return result;
  5148. } else {
  5149. if (typeof options.url !== 'string') {
  5150. console.warn('类型错误: typeof Link !== Strings');
  5151. return result;
  5152. } else {
  5153. const reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  5154. //const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  5155. if (!reg.test(options.url)) {
  5156. console.warn('url字符串须为完整http链接');
  5157. return result;
  5158. }
  5159. result = true;
  5160. }
  5161. }
  5162. return result;
  5163. }
  5164.  
  5165. /**
  5166. * 对象转URL编码
  5167. * @param {object} data
  5168. */
  5169. function objToURLCode(data) {
  5170. var _result = [];
  5171. for (var key in data) {
  5172. var value = data[key];
  5173. if (value instanceof Array) {
  5174. value.forEach(function(_value) {
  5175. _result.push(key + "=" + _value);
  5176. });
  5177. } else {
  5178. _result.push(key + '=' + value);
  5179. }
  5180. }
  5181. return _result.join('&');
  5182. }
  5183.  
  5184. /**
  5185. * 请求
  5186. * @param {string} method
  5187. * @param {object} options
  5188. */
  5189. function request(method, options) {
  5190. if (checkOptions(options)) {
  5191. let xhr = new XMLHttpRequest();
  5192. const {
  5193. url: _url,
  5194. queryStringsObj,
  5195. data,
  5196. dataType,
  5197. payload,
  5198. hasCookies
  5199. } = options, url = typeof queryStringsObj === 'object' ?
  5200. _url + '?' + objToURLCode(queryStringsObj) : _url;
  5201. switch (method) {
  5202. case 'GET':
  5203. xhr.open("GET", url);
  5204. break;
  5205. case 'POST':
  5206. xhr.open("POST", url);
  5207. xhr.setRequestHeader('Content-Type', dataType);
  5208. //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");
  5209. break;
  5210. default:
  5211. break;
  5212. }
  5213. if (hasCookies) xhr.withCredentials = true;
  5214. xhr.timeout = 3000;
  5215. xhr.addEventListener('load', () => {
  5216. if (xhr.status === 200) {
  5217. options.success(xhr.responseText)
  5218. } else {
  5219. console.error(`status:${xhr.status}`);
  5220. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  5221. }
  5222. })
  5223. xhr.addEventListener('error', () => {
  5224. console.error('ajax请求出错')
  5225. options.success('{"code":-1,"msg":"ajax请求出错"}');
  5226. })
  5227. xhr.addEventListener('timeout', () => {
  5228. console.error('请求超时')
  5229. options.success('{"code":-1,"msg":"请求超时"}');
  5230. })
  5231. switch (method) {
  5232. case 'GET':
  5233. xhr.send()
  5234. break;
  5235. case 'POST':
  5236. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  5237. //xhr.send(payload);
  5238. break;
  5239. default:
  5240. break;
  5241. }
  5242. }
  5243. }
  5244.  
  5245. return {
  5246. /**
  5247. * 发送Get请求
  5248. * @param {Object} options
  5249. */
  5250. get(options) {
  5251. request("GET", options);
  5252. },
  5253. /**
  5254. * 发送Post请求
  5255. * @param {object} options
  5256. */
  5257. post(options) {
  5258. request("POST", options);
  5259. }
  5260. }
  5261. })()