-哔哩猫-(试用版)

注:练手作品,多多包涵,不接受恶意差评,有问题群内咨询(Q群1031014013):批量播放视频;批量拉黑;批量关注;动态艾特消息提醒(友情天选群746790091 )

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

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