-哔哩猫-(试用版)

练手

当前为 2022-02-11 提交的版本,查看 最新版本

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

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