-哔哩猫-(试用版)

练手

当前为 2021-12-12 提交的版本,查看 最新版本

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