-哔哩猫-(试用版)

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

目前為 2021-11-17 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/422731/989064/-%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.4.95
  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. $("#linshiActivity").bind("click", async function() {
  1675.  
  1676. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/bilicat_config.json";
  1677. let myjson = await HNAPI.getMyJson(url);
  1678.  
  1679. let uids = myjson.config_linshi;
  1680.  
  1681. for (let uid of uids) {
  1682. await HNAPI.cancelAtt(uid, 2);
  1683. await HNTOOL.Sleep(1000);
  1684. }
  1685.  
  1686. await HNAPI.batchModify(uids.toString(), 1);
  1687. await HNTOOL.Sleep(5000);
  1688.  
  1689. await HNAPI.baseGet(
  1690. " https://api.live.bilibili.com/xlive/activity-interface/v2/userTask/GetNewUserTaskInfo", {
  1691. "task_id": 351
  1692. });
  1693.  
  1694. await HNTOOL.Sleep(1000);
  1695. let open_capsule_by_id = {
  1696. 'id': 308,
  1697. 'count': 1,
  1698. 'platform': 'web',
  1699. 'csrf_token': Live_info.csrf_token,
  1700. 'csrf': Live_info.csrf_token,
  1701. 'visit_id': '',
  1702. '_': Math.round(new Date()),
  1703. };
  1704.  
  1705. let open_capsule = await HNAPI.basePost(
  1706. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  1707. open_capsule_by_id);
  1708. await HNTOOL.Sleep(1000);
  1709.  
  1710. if (open_capsule == false) {
  1711. alert("失败");
  1712. }
  1713.  
  1714. GM_setClipboard(((open_capsule.data.awards)[0]).gift_value);
  1715.  
  1716. alert("已复制到剪切板:" + ((open_capsule.data.awards)[0]).gift_value);
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722. /*let activity_id = 5629850673711360;
  1723. await HNAPI.wwjdg_inform(activity_id);
  1724. await HNAPI.wwjdg_inform_off(activity_id, "info1");
  1725. await HNAPI.wwjdg_inform(activity_id);
  1726. await HNAPI.wwjdg_inform_off(activity_id, "info2");
  1727. await HNAPI.exchange_prize(activity_id);
  1728. await HNAPI.exchange_chance(activity_id);
  1729. await HNAPI.get_draw_chance(activity_id);
  1730. await HNAPI.get_draw_chance(activity_id);
  1731. await HNAPI.lottery_draw_one();
  1732. await HNAPI.diary_upload(5597469229992192, 1);
  1733. await HNTOOL.Sleep(1500);
  1734. await HNAPI.diary_upload(5597469229992192, 2);
  1735. await HNTOOL.Sleep(1500);
  1736. await HNAPI.diary_upload(5597469229992192, 3);
  1737. await HNTOOL.Sleep(1500);
  1738. await HNAPI.get_draw_chance(5597469229992192);
  1739. await HNTOOL.Sleep(1000);
  1740. await HNAPI.lottery_draw(5597469229992192);
  1741. await HNTOOL.Sleep(1500);
  1742. await HNAPI.get_draw_chance(5597469229992192);
  1743. await HNTOOL.Sleep(1000);
  1744. await HNAPI.lottery_draw(5597469229992192);
  1745. await HNTOOL.Sleep(1500);
  1746. await HNAPI.get_draw_chance(5597469229992192);
  1747. await HNTOOL.Sleep(1000);
  1748. await HNAPI.lottery_draw(5597469229992192);
  1749. await HNTOOL.Sleep(1500);
  1750. alert(await HNAPI.lottery_record(5597469229992192)); */
  1751.  
  1752.  
  1753. });
  1754.  
  1755.  
  1756. $("#jury_case").bind("click", async function() {
  1757.  
  1758. let bln = window.confirm('是否立即执行?【确定:只会执行一次】;【取消:0:10(5H)】;');
  1759.  
  1760. if (bln) {
  1761. HNTOOL.console("风纪开始!")
  1762. HNTOOL.jury_case();
  1763. } else {
  1764. for (var i = 0; i < 1; i--) {
  1765.  
  1766. let now = new Date();
  1767. let hour = now.getHours();
  1768. let minu = now.getMinutes();
  1769. HNTOOL.console("风纪运行中……");
  1770.  
  1771. if ((hour == 0 || HNTOOL.isInteger(hour / 6)) && minu == 10) {
  1772. HNTOOL.console("风纪开始到达预定时间开始执行!")
  1773. HNTOOL.jury_case();
  1774. }
  1775.  
  1776. await HNTOOL.Sleep(50000);
  1777. }
  1778. }
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788. });
  1789.  
  1790. $("#plateActivity").bind("click", async function() {
  1791.  
  1792. //获取轮盘数据
  1793.  
  1794. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1795. let myjson = await HNAPI.getMyJson(url);
  1796. let lmt = 0;
  1797. let k = 20; //重试次数 防止卡主
  1798. let giftArr = [];
  1799. let endAtion = [];
  1800.  
  1801. javaex.tip({
  1802. content: "开始参加轮盘!!!",
  1803. type: "success"
  1804. });
  1805.  
  1806. await HNAPI.getUserNav();
  1807. await HNTOOL.Sleep(1500);
  1808.  
  1809.  
  1810. for (const json of myjson) {
  1811. //let x = json.name;
  1812. for (let i = 0; i < 10; i++) {
  1813. //1.结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1814. let resout = await HNAPI.addLotteryTimes(json.sid);
  1815.  
  1816. await HNTOOL.Sleep(200);
  1817. if (resout == 1) {
  1818.  
  1819. endAtion.push(json.name + ":活动已结束!");
  1820. javaex.tip({
  1821. content: json.name + "活动已结束!",
  1822. type: "success"
  1823. });
  1824.  
  1825. break;
  1826. }
  1827. if (resout != 0 && resout != 1) {
  1828.  
  1829. javaex.tip({
  1830. content: json.name + resout,
  1831. type: "error"
  1832. });
  1833.  
  1834. break;
  1835. }
  1836.  
  1837. if (resout == 0) {
  1838. //2.查询次数
  1839. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1840. continue;
  1841. }
  1842.  
  1843. }
  1844.  
  1845. javaex.tip({
  1846. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1847. type: "success"
  1848. });
  1849.  
  1850. await HNTOOL.Sleep(1000);
  1851.  
  1852. for (let i = 0; i < lmt; i++) {
  1853. //3、执行抽奖
  1854. let gift = await HNAPI.lotteryDo(json.sid);
  1855.  
  1856. if (gift == true) {
  1857. javaex.tip({
  1858. content: "点击过快,9秒后自动重试!!!",
  1859. type: "error"
  1860. });
  1861. i--;
  1862. k--;
  1863. }
  1864.  
  1865. if (gift == false || k == 0) {
  1866. break;
  1867. }
  1868.  
  1869. if (gift != "未中奖0" && gift != true) {
  1870. giftArr.push(json.name + "奖品为:" + gift);
  1871. break;
  1872. } else {
  1873. javaex.tip({
  1874. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  1875. type: "success"
  1876. });
  1877. }
  1878. await HNTOOL.Sleep(7000);
  1879.  
  1880. }
  1881.  
  1882.  
  1883. }
  1884.  
  1885.  
  1886. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (
  1887. giftArr.length ==
  1888. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1889.  
  1890. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1891. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1892.  
  1893.  
  1894. });
  1895.  
  1896. $("#addPlay").bind("click", async function() {
  1897.  
  1898.  
  1899. let html = '';
  1900.  
  1901. html += '<div style="padding: 10px 10px 10px 0px;">'
  1902. html += '<form id="getUpMassage_form">'
  1903.  
  1904. html += ' <div class="javaex-unit clear">'
  1905. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  1906. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  1907. html +=
  1908. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  1909. html +=
  1910. ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  1911. html += ' </div>'
  1912. html += ' </div>'
  1913. html += ' <div class="javaex-unit clear">'
  1914. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  1915. html +=
  1916. ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  1917. html +=
  1918. ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  1919. html +=
  1920. ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  1921. html += ' </div>'
  1922. html += ' </div>'
  1923. html += '</form>';
  1924. html += ' <div class="javaex-unit clear tc">'
  1925. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  1926. html += ' </div>'
  1927. html += '<hr class="javaex-divider"></hr>';
  1928. html += '</div>';
  1929.  
  1930.  
  1931. javaex.panel(this, {
  1932. position: "right",
  1933. content: html
  1934. });
  1935.  
  1936. $("#addPlay_bgn").click(async function() {
  1937.  
  1938. let MID = javaex.getSelectVal("#addPlay_uid")
  1939. let BV = javaex.getSelectVal("#addPlay_bv");
  1940. let bvArr = [];
  1941. let bvArr2 = [];
  1942.  
  1943. MID = javaex.ifnull(MID, BiliData.author_uid);
  1944.  
  1945.  
  1946. if (BV == "0") {
  1947.  
  1948. //1.查询up所有视频BV号 2.发送心跳间隔2s
  1949. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  1950. await HNTOOL.Sleep(500);
  1951. bvArr2 = BiliData.BVList;
  1952.  
  1953. for (let i = 1; i > 0; i++) {
  1954.  
  1955. HNAPI.getUpAllBV(MID, i);
  1956.  
  1957. await HNTOOL.Sleep(500);
  1958.  
  1959. if (BiliData.BVList.length == 0) {
  1960. if (bvArr.length == 0) {
  1961. javaex.tip({
  1962. content: "该用户无投稿视频,请确认是否有误!",
  1963. type: "success"
  1964. });
  1965. await HNTOOL.Sleep(2000);
  1966. }
  1967. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  1968. bvArr = bvArr.concat(bvArr2);
  1969. break;
  1970. }
  1971.  
  1972. bvArr = bvArr.concat(BiliData.BVList);
  1973. }
  1974.  
  1975.  
  1976. if (bvArr.length != 0) {
  1977.  
  1978. for (const emt of bvArr) {
  1979.  
  1980. HNAPI.playOneVideo(emt.bvid, MID);
  1981.  
  1982. await HNTOOL.Sleep(2000);
  1983.  
  1984. }
  1985.  
  1986. alert("播放完成!!!");
  1987.  
  1988. }
  1989.  
  1990.  
  1991. } else {
  1992. //1.调用点击播放接口
  1993. //2.发送心跳
  1994.  
  1995. await HNTOOL.Sleep(500);
  1996.  
  1997. HNAPI.playOneVideo(BV);
  1998. }
  1999.  
  2000.  
  2001. });
  2002.  
  2003.  
  2004. });
  2005.  
  2006. }
  2007.  
  2008.  
  2009.  
  2010.  
  2011. let addSetPage = async function() {
  2012.  
  2013. HNTOOL.Sleep(1000);
  2014.  
  2015. $('body').append('' +
  2016. '<div id="left_navbar">' +
  2017. '<div class="javaex-menu-container"> ' +
  2018. ' <div id="menu" class="javaex-menu"> ' +
  2019. ' <ul> ' +
  2020. ' <li class="javaex-menu-item alone hover" > ' +
  2021. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  2022. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  2023. ' </li> ' +
  2024. ' </ul> ' +
  2025. ' <ul> ' +
  2026. ' <li class="javaex-menu-item"> ' +
  2027. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  2028. ' <ul> ' +
  2029. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  2030. ' </ul> ' +
  2031. ' </li> ' +
  2032. ' <li id="chackList" class="javaex-menu-item"> ' +
  2033. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  2034. ' <ul> ' +
  2035. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  2036. //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  2037. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  2038. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  2039. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  2040. ' </ul> ' +
  2041. ' </li> ' +
  2042. ' <li class="javaex-menu-item"> ' +
  2043. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  2044. ' <ul> ' +
  2045. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  2046. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  2047. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  2048. ' <li id="batchFollowOfbastard" class="javaex-hover-pulse"><a href="javaScript:;" >批量取关-慎用</a></li> ' +
  2049. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  2050. ' <li id="batch_dynamic_like" class="javaex-hover-pulse"><a href="javaScript:;" >批量动态点赞</a></li> ' +
  2051. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  2052. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  2053. ' </ul> ' +
  2054. ' </li> ' +
  2055. ' <li class="javaex-menu-item"> ' +
  2056. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  2057. ' <ul> ' +
  2058. ' <li id="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
  2059. ' <li id="jury_case" class="javaex-hover-pulse"><a href="javaScript:;" >一键风纪任务【0:10(5H)】</a></li> ' +
  2060. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  2061. ' <li id="linshiActivity" class="javaex-hover-pulse"><a href="javaScript:;" >临时转盘</a></li> ' +
  2062. //' <li id="liveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >直播转盘</a></li> ' +
  2063. //' <li id="likeInDynamicComments" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  2064. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  2065. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  2066. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  2067. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  2068. ' <li id="dynamicActivity" class="javaex-hover-pulse"><a href="javaScript:;" >动态抽奖</a></li> ' +
  2069. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  2070. //' <li id="auto_check_question" class="javaex-hover-pulse"><a href="javaScript:;">一键答题</a></li> ' +
  2071. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  2072. ' </ul> ' +
  2073. ' </li> ' +
  2074. ' <li class="javaex-menu-item"> ' +
  2075. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  2076. ' <ul> ' +
  2077. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  2078. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  2079. ' </ul> ' +
  2080. ' </li> ' +
  2081.  
  2082. ' </ul> ' +
  2083. ' </div> ' +
  2084. '</div>' +
  2085. '</div>');
  2086. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  2087.  
  2088. javaex.menu({
  2089. id: "menu",
  2090. isShowAll: false
  2091. });
  2092.  
  2093. }
  2094.  
  2095.  
  2096.  
  2097.  
  2098. let showUnreadMsg = function() {
  2099.  
  2100. var html = '';
  2101. html += '<div class="javaex-panel-box" style="width: 250px;">';
  2102. html += ' <ul>';
  2103. html += ` <p style="color: #FFF;">用户消息</p>`;
  2104. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  2105. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  2106. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  2107. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  2108. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  2109. html += ' <hr class="javaex-divider"></hr>';
  2110. html += ' </ul>';
  2111. html += '</div>';
  2112.  
  2113.  
  2114. javaex.panel(document.getElementById("getUnread"), {
  2115. position: "right",
  2116. content: html
  2117. });
  2118.  
  2119. javaex.tip({
  2120. content: "查询用户通知成功!",
  2121. type: "success"
  2122. });
  2123.  
  2124. }
  2125.  
  2126. /**
  2127. * 检查 艾特信息
  2128. * @returns {Promise<void>}
  2129. */
  2130. let chackAtMsg = async function(items) {
  2131.  
  2132. await HNTOOL.Sleep(500);
  2133.  
  2134. if (items != false && typeof(items) != "undefined") {
  2135.  
  2136.  
  2137. var html = '';
  2138. html += '<div class="javaex-panel-box" style="width: auto;">';
  2139. html += ' <ul>';
  2140. html += ` <p style="color: #FFF;">@信息</p>`;
  2141. items.forEach(function(item) {
  2142.  
  2143. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  2144. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  2145. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  2146.  
  2147. html +=
  2148. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  2149. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  2150. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  2151. html += ' <hr class="javaex-divider"></hr>';
  2152. });
  2153. html += ' </ul>';
  2154. html += '</div>';
  2155.  
  2156.  
  2157. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  2158. javaex.panel(document.getElementById("getAtMsg"), {
  2159. position: "right",
  2160. content: html
  2161. });
  2162. } else {
  2163. javaex.panel(document.getElementById("chackList"), {
  2164. position: "right",
  2165. content: html
  2166. });
  2167. }
  2168.  
  2169.  
  2170. }
  2171.  
  2172. }
  2173.  
  2174.  
  2175. let addStyle = function() {
  2176. const animate = GM_getResourceText('animate');
  2177. const common = GM_getResourceText('common');
  2178. const defaultCss = GM_getResourceText('defaultCss');
  2179. //const icomoonex = GM_getResourceText('icomoonex');
  2180. //const AllCss = animate + common + defaultCss + icomoonex;
  2181. const AllCss = animate + common + defaultCss;
  2182. const style = document.createElement('style');
  2183. style.innerHTML = AllCss;
  2184. return document.getElementsByTagName('head')[0].appendChild(style);
  2185. }
  2186.  
  2187. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  2188.  
  2189.  
  2190. /*-----------------------------------------------常用API--------------------------------------------------*/
  2191.  
  2192. let HNAPI = {
  2193.  
  2194. basePost: async function(api, data) {
  2195. return new Promise((resolve) => {
  2196. Ajax.post({
  2197. url: api,
  2198. hasCookies: true,
  2199. dataType: 'application/x-www-form-urlencoded',
  2200. data: data,
  2201. success: responseText => {
  2202. let res = HNTOOL.strToJson(responseText);
  2203. if (res.code === 0) {
  2204.  
  2205. resolve(res);
  2206. } else {
  2207.  
  2208. resolve(false);
  2209. }
  2210. }
  2211. })
  2212. });
  2213. },
  2214.  
  2215.  
  2216.  
  2217. baseGet: async function(api, queryObj) {
  2218. return new Promise((resolve) => {
  2219.  
  2220. Ajax.get({
  2221. url: api,
  2222. queryStringsObj: queryObj,
  2223. hasCookies: true,
  2224. success: responseText => {
  2225. let res = HNTOOL.strToJson(responseText);
  2226. if (res.code === 0) {
  2227.  
  2228. resolve(res);
  2229. } else {
  2230.  
  2231. resolve(false);
  2232. }
  2233. }
  2234. })
  2235. });
  2236. },
  2237.  
  2238. exchange_chance: async function(activity_id) {
  2239. return new Promise((resolve) => {
  2240.  
  2241. Ajax.get({
  2242. url: "https://qcloud-sdkact-api.biligame.com/exchange/chance",
  2243. queryStringsObj: {
  2244. 't': Math.round(new Date()),
  2245. 'activity_id': activity_id,
  2246.  
  2247. },
  2248. hasCookies: true,
  2249. success: responseText => {
  2250. let res = HNTOOL.strToJson(responseText);
  2251. if (res.code === 0) {
  2252.  
  2253. resolve(true);
  2254. } else {
  2255.  
  2256. resolve(false);
  2257. }
  2258. }
  2259. })
  2260. });
  2261. },
  2262. wwjdg_inform: async function(activity_id) {
  2263. return new Promise((resolve) => {
  2264.  
  2265. Ajax.get({
  2266. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/inform",
  2267. queryStringsObj: {
  2268. 't': Math.round(new Date()),
  2269. 'activity_id': activity_id,
  2270.  
  2271. },
  2272. hasCookies: true,
  2273. success: responseText => {
  2274. let res = HNTOOL.strToJson(responseText);
  2275. if (res.code === 0) {
  2276.  
  2277. resolve(true);
  2278. } else {
  2279.  
  2280. resolve(false);
  2281. }
  2282. }
  2283. })
  2284. });
  2285. },
  2286. wwjdg_inform_off: async function(activity_id, info_no) {
  2287. return new Promise((resolve) => {
  2288. Ajax.post({
  2289. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/inform/off?t=" + Math.round(
  2290. new Date()),
  2291. hasCookies: true,
  2292. dataType: 'application/x-www-form-urlencoded',
  2293. data: {
  2294.  
  2295. activity_id: activity_id,
  2296. info_no: info_no,
  2297.  
  2298. },
  2299. success: responseText => {
  2300. let res = HNTOOL.strToJson(responseText);
  2301. if (res.code === 0) {
  2302.  
  2303. resolve(true);
  2304. } else {
  2305.  
  2306. resolve(false);
  2307. }
  2308. }
  2309. })
  2310. });
  2311. },
  2312.  
  2313. exchange_prize: async function(activity_id) {
  2314. return new Promise((resolve) => {
  2315.  
  2316. Ajax.get({
  2317. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/exchange_prize",
  2318. queryStringsObj: {
  2319. 't': Math.round(new Date()),
  2320. 'activity_id': activity_id,
  2321. 'prize_id': 5629853426288896,
  2322. },
  2323. hasCookies: true,
  2324. success: responseText => {
  2325. let res = HNTOOL.strToJson(responseText);
  2326. if (res.code === 0) {
  2327.  
  2328. resolve(true);
  2329. } else {
  2330.  
  2331. resolve(false);
  2332. }
  2333. }
  2334. })
  2335. });
  2336. },
  2337. lottery_draw_one: async function() {
  2338. return new Promise((resolve) => {
  2339. Ajax.post({
  2340. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw?t=" + Math
  2341. .round(new Date()),
  2342. hasCookies: true,
  2343. dataType: 'application/x-www-form-urlencoded',
  2344. data: {
  2345.  
  2346. activity_id: 5629854950017280
  2347.  
  2348. },
  2349. success: responseText => {
  2350. let res = HNTOOL.strToJson(responseText);
  2351. if (res.code === 0) {
  2352.  
  2353. alert(res.data.name)
  2354.  
  2355. } else if (res.code === 11001 || res.code == -905) {
  2356.  
  2357. Ajax.post({
  2358. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw?t=" +
  2359. Math
  2360. .round(new Date()),
  2361. hasCookies: true,
  2362. dataType: 'application/x-www-form-urlencoded',
  2363. data: {
  2364.  
  2365. activity_id: 5629850673711360
  2366.  
  2367. },
  2368. success: responseText => {
  2369. let res2 = HNTOOL.strToJson(responseText);
  2370. if (res2.code === 0) {
  2371.  
  2372. alert(res2.data.name)
  2373. } else if (res.code == -905) {
  2374. alert(res2.message);
  2375. } else {
  2376.  
  2377. resolve(false);
  2378. }
  2379. }
  2380. })
  2381.  
  2382. } else {
  2383.  
  2384. resolve(false);
  2385. }
  2386. }
  2387. })
  2388. });
  2389. },
  2390. /**
  2391. *
  2392. */
  2393.  
  2394. jury_vote: async function(case_id, vote, anonymous) {
  2395. return new Promise((resolve) => {
  2396. Ajax.post({
  2397. url: BILIBLI_PATH.api + "/x/credit/v2/jury/vote",
  2398. hasCookies: true,
  2399. dataType: 'application/x-www-form-urlencoded',
  2400. data: {
  2401.  
  2402. case_id: case_id,
  2403. vote: vote,
  2404. anonymous: anonymous,
  2405. content: "",
  2406. csrf: Live_info.csrf_token
  2407. },
  2408. success: responseText => {
  2409. let res = HNTOOL.strToJson(responseText);
  2410. if (res.code === 0) {
  2411.  
  2412. resolve(true);
  2413. } else {
  2414.  
  2415. resolve(res.message);
  2416. }
  2417. }
  2418. })
  2419. });
  2420. },
  2421.  
  2422. /**
  2423. *
  2424. */
  2425. jury_case_opinion: async function(case_id) {
  2426. return new Promise((resolve) => {
  2427.  
  2428. Ajax.get({
  2429. url: BILIBLI_PATH.api + "/x/credit/v2/jury/case/opinion",
  2430. queryStringsObj: {
  2431. 'case_id': case_id,
  2432. 'pn': 1,
  2433. 'ps': 5,
  2434.  
  2435. },
  2436. hasCookies: true,
  2437. success: responseText => {
  2438. let res = HNTOOL.strToJson(responseText);
  2439. if (res.code === 0) {
  2440. resolve(true);
  2441. } else {
  2442.  
  2443. HNTOOL.console("获取案件详情发生错误!" + res.message, "error");
  2444.  
  2445. resolve(false);
  2446. }
  2447. }
  2448. })
  2449. });
  2450. },
  2451. /**
  2452. *
  2453. */
  2454. jury_case_info: async function(case_id) {
  2455. return new Promise((resolve) => {
  2456.  
  2457. Ajax.get({
  2458. url: BILIBLI_PATH.api + "/x/credit/v2/jury/case/info",
  2459. queryStringsObj: {
  2460. 'case_id': case_id
  2461. },
  2462. hasCookies: true,
  2463. success: responseText => {
  2464. let res = HNTOOL.strToJson(responseText);
  2465. if (res.code === 0) {
  2466. let comment_content = "";
  2467. let itemlist = [1, 1, 1, 1, 2, 2, 2, 2, 3, 0];
  2468. let x = itemlist[HNTOOL.random(0, 10)];
  2469.  
  2470. let vote_item = res.data.vote_items[x];
  2471. let case_type = res.data.case_type;
  2472. if (case_type == 4) {
  2473. //4:截屏内弹幕
  2474. comment_content = "截屏内弹幕";
  2475.  
  2476. } else {
  2477. comment_content = res.data.case_info.comment.content;
  2478. }
  2479.  
  2480.  
  2481. HNTOOL.console(
  2482. "\n 案号:" + case_id +
  2483. "\n 详情:" + comment_content +
  2484. "\n 选择:" + vote_item.vote_text
  2485. );
  2486. resolve(vote_item.vote);
  2487. } else {
  2488.  
  2489. HNTOOL.console("获取案件详情发生错误!" + res.message, "error");
  2490.  
  2491. resolve(false);
  2492. }
  2493. }
  2494. })
  2495. });
  2496. },
  2497.  
  2498. /**
  2499. *
  2500. */
  2501. jury_case_next: async function() {
  2502. return new Promise((resolve) => {
  2503.  
  2504. Ajax.get({
  2505. url: BILIBLI_PATH.api + '/x/credit/v2/jury/case/next',
  2506. queryStringsObj: {
  2507.  
  2508. },
  2509. hasCookies: true,
  2510. success: responseText => {
  2511. let res = HNTOOL.strToJson(responseText);
  2512. if (res.code === 0) {
  2513.  
  2514. resolve(res.data.case_id);
  2515. } else if (res.code === 25014 || res.code === 25008) {
  2516.  
  2517. HNTOOL.console(res.message);
  2518.  
  2519.  
  2520. } else {
  2521. HNTOOL.console("今日风纪已完成&暂时无案子!");
  2522. resolve(false);
  2523. }
  2524. }
  2525. })
  2526. });
  2527. },
  2528.  
  2529. answer_check: async function(question_id, ans_hash, type) {
  2530. return new Promise((resolve) => {
  2531. Ajax.post({
  2532.  
  2533. url: "https://api.bilibili.com/x/answer/v4/" + type + "/check",
  2534. hasCookies: true,
  2535. dataType: 'application/x-www-form-urlencoded',
  2536. data: {
  2537. question_id: question_id,
  2538. ans_hash: ans_hash,
  2539. csrf: Live_info.csrf_token
  2540. },
  2541. success: responseText => {
  2542. let res = HNTOOL.strToJson(responseText);
  2543. if (res.code === 0) {
  2544. console.log("答题成功");
  2545. resolve(res.data);
  2546. } else if (res.code === 41020) {
  2547. resolve(1);
  2548. } else {
  2549. javaex.tip({
  2550. content: "错误!",
  2551. type: "error"
  2552. });
  2553. resolve(false);
  2554. }
  2555. }
  2556. })
  2557. });
  2558. },
  2559.  
  2560. /**
  2561. *
  2562. */
  2563. pull_answer: async function(type) {
  2564. return new Promise((resolve) => {
  2565.  
  2566. Ajax.get({
  2567. url: 'https://api.bilibili.com/x/answer/v4/' + type,
  2568. queryStringsObj: {
  2569.  
  2570. },
  2571. hasCookies: true,
  2572. success: responseText => {
  2573. let res = HNTOOL.strToJson(responseText);
  2574. if (res.code === 0) {
  2575.  
  2576. resolve(res.data);
  2577. } else if (res.code === 41020) {
  2578. console.log("用户" + type + "题已通过")
  2579. resolve(1);
  2580. } else {
  2581. console.log("拉取" + type + "题目失败:" + res.message);
  2582. resolve(false);
  2583. }
  2584. }
  2585. })
  2586. });
  2587. },
  2588.  
  2589. /**
  2590. *
  2591. */
  2592. answer_status: async function() {
  2593. return new Promise((resolve) => {
  2594. Ajax.get({
  2595. url: 'https://api.bilibili.com/x/answer/v4/status',
  2596. queryStringsObj: {
  2597.  
  2598. },
  2599. hasCookies: true,
  2600. success: responseText => {
  2601. let res = HNTOOL.strToJson(responseText);
  2602. if (res.code === 0) {
  2603.  
  2604. resolve(res.data);
  2605.  
  2606. } else {
  2607. console.log("查询答题状态失败:" + res.message);
  2608. resolve(false);
  2609. }
  2610. }
  2611. })
  2612. });
  2613. },
  2614.  
  2615. /**
  2616. * 查询每日投币数量
  2617. */
  2618. get_account_exp: async function() {
  2619. return new Promise((resolve) => {
  2620. Ajax.get({
  2621. url: 'http://www.bilibili.com/plus/account/exp.php',
  2622. queryStringsObj: {
  2623.  
  2624. },
  2625. hasCookies: true,
  2626. success: responseText => {
  2627. let res = HNTOOL.strToJson(responseText);
  2628. if (res.code === 0) {
  2629.  
  2630. resolve(res.number);
  2631.  
  2632. } else {
  2633. console.log("查询每日投币数量失败:" + res.message);
  2634. resolve(false);
  2635. }
  2636. }
  2637. })
  2638. });
  2639. },
  2640. /**
  2641. * 查询每日奖励状态
  2642. */
  2643. get_exp_reward: async function() {
  2644. return new Promise((resolve) => {
  2645. Ajax.get({
  2646. url: BILIBLI_PATH.api + '/x/member/web/exp/reward',
  2647. queryStringsObj: {
  2648.  
  2649. },
  2650. hasCookies: true,
  2651. success: responseText => {
  2652. let res = HNTOOL.strToJson(responseText);
  2653. if (res.code === 0) {
  2654.  
  2655. resolve(res.data);
  2656.  
  2657. } else {
  2658. console.log("查询每日奖励状态失败:" + res.message);
  2659. resolve(false);
  2660. }
  2661. }
  2662. })
  2663. });
  2664. },
  2665.  
  2666. diary_upload: async function(activity_id, game_part) {
  2667. return new Promise((resolve) => {
  2668. Ajax.post({
  2669. url: "https://qcloud-sdkact-api.biligame.com/rabbit/diary/upload",
  2670. hasCookies: true,
  2671. dataType: 'application/x-www-form-urlencoded',
  2672. data: {
  2673. t: Math.round(new Date()),
  2674. activity_id: activity_id,
  2675. game_part: game_part
  2676. },
  2677. payload: '{"activity_id":"' + activity_id + '","game_part":' + game_part + '}',
  2678.  
  2679. success: responseText => {
  2680. let res = HNTOOL.strToJson(responseText);
  2681. if (res.code === 0) {
  2682. console.log("成功:");
  2683. resolve(true);
  2684. } else {
  2685. javaex.tip({
  2686. content: "错误!",
  2687. type: "error"
  2688. });
  2689. resolve(false);
  2690. }
  2691. }
  2692. })
  2693. });
  2694. },
  2695. lottery_draw: async function(activity_id) {
  2696. return new Promise((resolve) => {
  2697. Ajax.post({
  2698. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw",
  2699. hasCookies: true,
  2700. dataType: 'application/x-www-form-urlencoded',
  2701. data: {
  2702. t: Math.round(new Date()),
  2703. activity_id: activity_id,
  2704. },
  2705. payload: '{"activity_id":"' + activity_id + '","t":' + Math.round(new Date()) +
  2706. '}',
  2707.  
  2708. success: responseText => {
  2709. let res = HNTOOL.strToJson(responseText);
  2710. if (res.code === 0) {
  2711. console.log("成功");
  2712. resolve(true);
  2713. } else {
  2714. javaex.tip({
  2715. content: "错误!",
  2716. type: "error"
  2717. });
  2718. resolve(false);
  2719. }
  2720. }
  2721. })
  2722. });
  2723. },
  2724. lottery_record: async function(activity_id) {
  2725. return new Promise((resolve) => {
  2726. Ajax.get({
  2727. url: 'https://qcloud-sdkact-api.biligame.com/common/lottery/record',
  2728. queryStringsObj: {
  2729. t: Math.round(new Date()),
  2730. activity_id: activity_id,
  2731. },
  2732. hasCookies: true,
  2733. success: responseText => {
  2734. let res = HNTOOL.strToJson(responseText);
  2735. if (res.code === 0) {
  2736. let str = "";
  2737. for (let s of res.data) {
  2738. str += s.name
  2739. }
  2740.  
  2741. resolve(str);
  2742.  
  2743. } else {
  2744. console.log("查询每日奖励状态失败:" + res.message);
  2745. resolve(false);
  2746. }
  2747. }
  2748. })
  2749. });
  2750. },
  2751. get_draw_chance: async function(activity_id) {
  2752. return new Promise((resolve) => {
  2753. Ajax.get({
  2754. url: 'https://qcloud-sdkact-api.biligame.com/activity/lottery/get_draw_chance',
  2755. queryStringsObj: {
  2756. t: Math.round(new Date()),
  2757. activity_id: activity_id,
  2758. },
  2759. hasCookies: true,
  2760. success: responseText => {
  2761. let res = HNTOOL.strToJson(responseText);
  2762. if (res.code === 0) {
  2763.  
  2764. resolve(true);
  2765.  
  2766. } else {
  2767. console.log("查询每日奖励状态失败:" + res.message);
  2768. resolve(false);
  2769. }
  2770. }
  2771. })
  2772. });
  2773. },
  2774. /**
  2775. * 转发一个视频
  2776. * @param {Object} videoAid
  2777. * @param {Object} videoMid
  2778. * @param {Object} randomStr
  2779. */
  2780.  
  2781. shareOneVideo: async function(videoAid, videoMid, randomStr) {
  2782. return new Promise((resolve) => {
  2783. Ajax.post({
  2784. url: BILIBLI_PATH.vcapi + "/dynamic_repost/v1/dynamic_repost/share",
  2785. hasCookies: true,
  2786. dataType: 'application/x-www-form-urlencoded',
  2787. data: {
  2788.  
  2789. platform: "pc",
  2790. uid: videoMid,
  2791. type: 8,
  2792. content: randomStr,
  2793. repost_code: 20000,
  2794. rid: videoAid,
  2795. csrf: Live_info.csrf_token
  2796. },
  2797. success: responseText => {
  2798. let res = HNTOOL.strToJson(responseText);
  2799. if (res.code === 0) {
  2800. console.log("转发一个视频成功:" + res.data.dynamic_id);
  2801. resolve(true);
  2802. } else {
  2803. javaex.tip({
  2804. content: "转发一个视频错误!" + res.message,
  2805. type: "error"
  2806. });
  2807. resolve(false);
  2808. }
  2809. }
  2810. })
  2811. });
  2812. },
  2813.  
  2814. /**
  2815. * 批量关注和拉黑 batchModify
  2816. *
  2817. * https://api.bilibili.com/x/relation/batch/modify
  2818. * @param uid
  2819. */
  2820.  
  2821. /**
  2822. * 发布动态
  2823. * @param {Object} mid
  2824. */
  2825. batchModify: async function(uids, act) {
  2826. return new Promise((resolve) => {
  2827. Ajax.post({
  2828. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  2829. hasCookies: true,
  2830. dataType: 'application/x-www-form-urlencoded',
  2831. data: {
  2832.  
  2833. "fids": uids,
  2834. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  2835. "re_src": 222,
  2836. "csrf": Live_info.csrf_token,
  2837. },
  2838. success: responseText => {
  2839. let res = HNTOOL.strToJson(responseText);
  2840. if (res.code === 0) {
  2841.  
  2842. if (res.data.failed_fids.length > 0) {
  2843. console.log("关注失败:" + res.data.failed_fids);
  2844. resolve(false);
  2845. } else {
  2846. console.log("关注成功:" + uids);
  2847. resolve(true);
  2848. }
  2849.  
  2850.  
  2851. } else {
  2852. javaex.tip({
  2853. content: "批量关注错误!" + res.message,
  2854. type: "error"
  2855. });
  2856. resolve(false);
  2857. }
  2858. }
  2859. })
  2860. });
  2861. },
  2862.  
  2863. /**
  2864. * 发布动态
  2865. * @param {Object} mid
  2866. */
  2867. sendOneDynamic: async function(content) {
  2868. return new Promise((resolve) => {
  2869. Ajax.post({
  2870. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/create',
  2871. hasCookies: true,
  2872. dataType: 'application/x-www-form-urlencoded',
  2873. data: {
  2874. csrf: Live_info.csrf_token,
  2875. dynamic_id: 0,
  2876. type: 4,
  2877. dynamic_id: 0,
  2878. content: content,
  2879. extension: '{"emoji_type":1,"from":{"emoji_type":1},"flag_cfg":{}}'
  2880. },
  2881. hasCookies: true,
  2882. success: responseText => {
  2883. let res = HNTOOL.strToJson(responseText);
  2884. if (res.code === 0) {
  2885.  
  2886. console.log("随机发送一条动态:" + content);
  2887. resolve(true);
  2888.  
  2889. } else {
  2890. console.log("随机发送一条动态:" + res.message);
  2891. resolve(false);
  2892. }
  2893. }
  2894. })
  2895. });
  2896. },
  2897. /**
  2898. * @param {num} mid
  2899. * 用户详细信息2 (用于名片)
  2900. */
  2901. getInterfaceCard: async function(mid) {
  2902. return new Promise((resolve) => {
  2903. Ajax.get({
  2904. url: BILIBLI_PATH.api + '/x/web-interface/card',
  2905. queryStringsObj: {
  2906. "mid": mid
  2907. },
  2908.  
  2909. hasCookies: true,
  2910. success: responseText => {
  2911. let res = HNTOOL.strToJson(responseText);
  2912. if (res.code === 0) {
  2913.  
  2914. resolve(res.data.card);
  2915.  
  2916. } else {
  2917. console.log("获取用户详细信息失败:" + res.message);
  2918. resolve(false);
  2919. }
  2920. }
  2921. })
  2922. });
  2923. },
  2924.  
  2925.  
  2926. getLotteryNotice: async function(dynamic_id) {
  2927. return new Promise((resolve) => {
  2928. Ajax.get({
  2929. url: BILIBLI_PATH.vcapi + '/lottery_svr/v1/lottery_svr/lottery_notice',
  2930. queryStringsObj: {
  2931. "dynamic_id": dynamic_id
  2932. },
  2933. hasCookies: true,
  2934. success: responseText => {
  2935. let res = HNTOOL.strToJson(responseText);
  2936. if (res.code === 0) {
  2937.  
  2938. resolve(res.data);
  2939.  
  2940. } else {
  2941. console.log("获取开奖信息失败:" + res.message);
  2942. resolve(false);
  2943. }
  2944. }
  2945. })
  2946. });
  2947. },
  2948.  
  2949.  
  2950. likeDynamic: async function(dynamic_id) {
  2951.  
  2952. return new Promise((resolve) => {
  2953. Ajax.post({
  2954. url: BILIBLI_PATH.vcapi + '/dynamic_like/v1/dynamic_like/thumb',
  2955. hasCookies: true,
  2956. dataType: 'application/x-www-form-urlencoded',
  2957. data: {
  2958. uid: Live_info.uid,
  2959. dynamic_id: dynamic_id,
  2960. up: 1,
  2961. csrf: Live_info.csrf_token
  2962. },
  2963. success: responseText => {
  2964. let res = HNTOOL.strToJson(responseText);
  2965. if (res.code === 0) {
  2966.  
  2967. javaex.tip({
  2968. content: "动态点赞成功!",
  2969. type: "success"
  2970. });
  2971.  
  2972. resolve(true);
  2973. } else {
  2974.  
  2975. console.log("动态点赞发生错误!" + res.message);
  2976.  
  2977. javaex.tip({
  2978. content: "动态点赞发生错误!" + res.message,
  2979. type: "error"
  2980. });
  2981.  
  2982. resolve(false);
  2983. }
  2984. }
  2985. })
  2986. });
  2987. },
  2988.  
  2989. repostDynamic: async function(dynamic_id, content, ctrl) {
  2990.  
  2991. return new Promise((resolve) => {
  2992. Ajax.post({
  2993. url: BILIBLI_PATH.vcapi + '/dynamic_repost/v1/dynamic_repost/repost',
  2994. dataType: 'application/x-www-form-urlencoded',
  2995. hasCookies: true,
  2996. data: {
  2997. uid: Live_info.uid,
  2998. dynamic_id: dynamic_id,
  2999. content: content,
  3000. extension: '{"emoji_type":1}',
  3001. at_uids: "",
  3002. ctrl: ctrl == null || ctrl == "转发动态" ? "[]" : ctrl,
  3003. csrf_token: Live_info.csrf_token,
  3004. csrf: Live_info.csrf_token
  3005. },
  3006. success: responseText => {
  3007. let res = HNTOOL.strToJson(responseText);
  3008. if (res.code === 0) {
  3009.  
  3010. javaex.tip({
  3011. content: "动态转发成功!",
  3012. type: "success"
  3013. });
  3014.  
  3015. resolve(true);
  3016. } else {
  3017.  
  3018. console.log("动态转发发生错误!" + res.message);
  3019.  
  3020. javaex.tip({
  3021. content: "动态转发发生错误!" + res.message,
  3022. type: "error"
  3023. });
  3024.  
  3025. resolve(false);
  3026. }
  3027. }
  3028. })
  3029. });
  3030. },
  3031.  
  3032. addReply: async function(oid, type) {
  3033.  
  3034. return new Promise((resolve) => {
  3035. Ajax.post({
  3036. url: BILIBLI_PATH.api + '/x/v2/reply/add',
  3037. dataType: 'application/x-www-form-urlencoded',
  3038. hasCookies: true,
  3039. data: {
  3040. "oid": oid,
  3041. "type": type, //11官方 17 加码
  3042. "ordering": 'heat',
  3043. "message": HNTOOL.getRandomWordOfList(replyList) == undefined ? "不错[鼓掌]" :
  3044. HNTOOL.getRandomWordOfList(
  3045. replyList),
  3046. "jsonp": 'jsonp',
  3047. "csrf": Live_info.csrf_token
  3048. },
  3049. success: responseText => {
  3050. let res = HNTOOL.strToJson(responseText);
  3051. if (res.code === 0) {
  3052. javaex.tip({
  3053. content: "'自动评论成功'!",
  3054. type: "success"
  3055. });
  3056. resolve(0);
  3057. } else if (res.code === -404) {
  3058. console.log('自动评论原动态已删除');
  3059. resolve(0);
  3060. } else if (res.code === 12002) {
  3061. console.log('自动评论评论区已关闭');
  3062. resolve(0);
  3063. } else if (res.code === 12015) {
  3064. console.log('自动评论需要输入验证码');
  3065. resolve(1);
  3066. } else {
  3067. console.log('自动评论', `评论失败\n${responseText}`);
  3068. resolve(0);
  3069. }
  3070. }
  3071. })
  3072. });
  3073. },
  3074.  
  3075.  
  3076. setNotice: async function(notice) {
  3077.  
  3078. return new Promise((resolve) => {
  3079. Ajax.post({
  3080. url: BILIBLI_PATH.api + '/x/space/notice/set',
  3081. hasCookies: true,
  3082. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3083. data: {
  3084. notice: notice,
  3085. jsonp: 'jsonp',
  3086. csrf: Live_info.csrf_token
  3087. },
  3088. success: responseText => {
  3089. let res = HNTOOL.strToJson(responseText);
  3090. if (res.code === 0) {
  3091.  
  3092. javaex.tip({
  3093. content: "动态标记保存到个人公告成功!",
  3094. type: "success"
  3095. });
  3096.  
  3097. resolve(true);
  3098. } else {
  3099.  
  3100. javaex.tip({
  3101. content: res.message,
  3102. type: "error"
  3103. });
  3104.  
  3105. resolve(false);
  3106. }
  3107. }
  3108. })
  3109. });
  3110. },
  3111.  
  3112. getSpaceNotice: async function() {
  3113. return new Promise((resolve) => {
  3114. Ajax.get({
  3115. url: BILIBLI_PATH.api + '/x/space/notice',
  3116. queryStringsObj: {
  3117. "mid": Live_info.uid
  3118. },
  3119. hasCookies: true,
  3120. success: responseText => {
  3121. let res = HNTOOL.strToJson(responseText);
  3122. if (res.code === 0) {
  3123.  
  3124. resolve(res.data);
  3125.  
  3126. } else {
  3127. console.log("获取公告信息失败:" + res.message);
  3128. resolve(false);
  3129. }
  3130. }
  3131. })
  3132. });
  3133. },
  3134.  
  3135. getdynamicData: async function(dynamic_id_str) {
  3136. return new Promise((resolve) => {
  3137. Ajax.get({
  3138.  
  3139. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
  3140. queryStringsObj: {
  3141. "dynamic_id": dynamic_id_str
  3142. },
  3143. hasCookies: true,
  3144. success: responseText => {
  3145. let res = HNTOOL.strToJson(responseText);
  3146. if (res.code === 0) {
  3147.  
  3148. resolve(res.data);
  3149.  
  3150. } else {
  3151. console.log("获取动态信息失败:" + res.message);
  3152. resolve(false);
  3153. }
  3154. }
  3155. })
  3156. });
  3157. },
  3158.  
  3159. getAllFollow: async function() {
  3160. return new Promise((resolve) => {
  3161. Ajax.get({
  3162.  
  3163. url: BILIBLI_PATH.vcapi + '/feed/v1/feed/get_attention_list',
  3164. queryStringsObj: {
  3165. "uid": Live_info.uid
  3166. },
  3167. hasCookies: true,
  3168. success: responseText => {
  3169. let res = HNTOOL.strToJson(responseText);
  3170. if (res.code === 0) {
  3171.  
  3172. resolve(res.data.list);
  3173.  
  3174. } else {
  3175. console.log("查询失败!" + res.message);
  3176. resolve(false);
  3177. }
  3178. }
  3179. })
  3180. });
  3181. },
  3182.  
  3183. getCardByUID: async function(UID) {
  3184. return new Promise((resolve) => {
  3185. Ajax.get({
  3186.  
  3187. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3188. queryStringsObj: {
  3189. "mid": UID
  3190. },
  3191. hasCookies: true,
  3192. success: responseText => {
  3193. let res = HNTOOL.strToJson(responseText);
  3194. if (res.code === 0) {
  3195.  
  3196. resolve(res.data.card);
  3197.  
  3198. } else {
  3199. console.log("查询失败!" + res.message);
  3200. resolve(false);
  3201. }
  3202. }
  3203. })
  3204. });
  3205. },
  3206.  
  3207.  
  3208. /**
  3209. *
  3210. *
  3211. */
  3212.  
  3213. getTodayDynamicList: async function(mid, index) {
  3214. return new Promise((resolve) => {
  3215. Ajax.get({
  3216.  
  3217. url: BILIBLI_PATH.api + '/x/space/article',
  3218. queryStringsObj: {
  3219. "mid": mid,
  3220. "pn": 1,
  3221. "ps": 12,
  3222. "sort": 'publish_time'
  3223. },
  3224. hasCookies: true,
  3225. success: responseText => {
  3226. let res = HNTOOL.strToJson(responseText);
  3227. if (res.code === 0) {
  3228. let artlist = false;
  3229. let articlesList = [];
  3230. let articles = res.data.articles;
  3231. for (var i = 0, len = articles.length; i < index; i++) {
  3232. articlesList[i] = articles[i];
  3233. }
  3234.  
  3235. resolve(articlesList);
  3236. } else {
  3237.  
  3238.  
  3239. console.log("查询失败!" + res.message);
  3240. resolve(false);
  3241. }
  3242. }
  3243. })
  3244. });
  3245. },
  3246.  
  3247. getDataByLiveSid: async function(ids) {
  3248. return new Promise((resolve) => {
  3249. Ajax.get({
  3250.  
  3251. url: BILIBLI_PATH.api + '/x/activity/up/reserve/relation/info',
  3252. queryStringsObj: {
  3253. "ids": ids
  3254. },
  3255. hasCookies: true,
  3256. success: responseText => {
  3257. let res = HNTOOL.strToJson(responseText);
  3258. if (res.code === 0 && Object.keys(res.data.list).length != 0) {
  3259.  
  3260. resolve(res.data.list);
  3261. } else {
  3262.  
  3263. /* javaex.tip({
  3264. content: "查询失败!" + res.message,
  3265. type: "error"
  3266. }); */
  3267. console.log("查询失败!" + res.message);
  3268.  
  3269. resolve(false);
  3270. }
  3271. }
  3272. })
  3273. });
  3274. },
  3275.  
  3276. /**
  3277. * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
  3278. */
  3279. clickNow: async function() {
  3280. return new Promise((resolve) => {
  3281. Ajax.get({
  3282.  
  3283. url: BILIBLI_PATH.api + '/x/report/click/now',
  3284. queryStringsObj: {
  3285. jsonp: "jsonp"
  3286. },
  3287. hasCookies: true,
  3288. success: responseText => {
  3289. let res = HNTOOL.strToJson(responseText);
  3290. if (res.code === 0) {
  3291.  
  3292. javaex.tip({
  3293. content: "每日登录" + res.data.text,
  3294. type: "success"
  3295. });
  3296. resolve(true);
  3297.  
  3298. } else {
  3299.  
  3300. javaex.tip({
  3301. content: res.message,
  3302. type: "error"
  3303. });
  3304.  
  3305. resolve(false);
  3306. }
  3307. }
  3308. })
  3309. });
  3310. },
  3311.  
  3312. /**
  3313. * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
  3314. * @param {number} videoAid
  3315. */
  3316. addShare: async function(videoAid) {
  3317. return new Promise((resolve) => {
  3318. Ajax.post({
  3319. url: BILIBLI_PATH.api + '/x/web-interface/share/add',
  3320. hasCookies: true,
  3321. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3322. data: {
  3323. aid: videoAid,
  3324. csrf: Live_info.csrf_token
  3325. },
  3326. success: responseText => {
  3327. let res = HNTOOL.strToJson(responseText);
  3328. if (res.code === 0) {
  3329.  
  3330. javaex.tip({
  3331. content: "每日分享视频成功",
  3332. type: "success"
  3333. });
  3334.  
  3335. resolve(true);
  3336. } else {
  3337.  
  3338. javaex.tip({
  3339. content: res.message,
  3340. type: "error"
  3341. });
  3342.  
  3343. resolve(false);
  3344. }
  3345. }
  3346. })
  3347. });
  3348. },
  3349.  
  3350.  
  3351.  
  3352. /**
  3353. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  3354. * @param {number} videoAid
  3355. */
  3356. addArticleCoin: async function(cvID, mid) {
  3357. return new Promise((resolve) => {
  3358. Ajax.post({
  3359. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  3360. hasCookies: true,
  3361. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3362. data: {
  3363. aid: cvID,
  3364. upid: mid,
  3365. multiply: 2,
  3366. avtype: 2,
  3367. csrf: Live_info.csrf_token
  3368. },
  3369. success: responseText => {
  3370. let res = HNTOOL.strToJson(responseText);
  3371. if (res.code === 0) {
  3372.  
  3373. javaex.tip({
  3374. content: '专栏:' + cvID + "投币成功",
  3375. type: "success"
  3376. });
  3377.  
  3378. resolve(true);
  3379. } else {
  3380.  
  3381. javaex.tip({
  3382. content: res.message,
  3383. type: "error"
  3384. });
  3385.  
  3386. console.log('专栏投币失败:' + cvID + res.message);
  3387.  
  3388. resolve(false);
  3389. }
  3390. }
  3391. })
  3392. });
  3393. },
  3394.  
  3395. /**
  3396. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  3397. * @param {number} videoAid
  3398. */
  3399. addVideoCoin: async function(videoAid) {
  3400. return new Promise((resolve) => {
  3401. Ajax.post({
  3402. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  3403. hasCookies: true,
  3404. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3405. data: {
  3406. aid: videoAid,
  3407. multiply: 2,
  3408. select_like: 0,
  3409. cross_domain: true,
  3410. csrf: Live_info.csrf_token
  3411. },
  3412. success: responseText => {
  3413. let res = HNTOOL.strToJson(responseText);
  3414. if (res.code === 0) {
  3415.  
  3416. javaex.tip({
  3417. content: "投币成功",
  3418. type: "success"
  3419. });
  3420.  
  3421. resolve(true);
  3422. } else {
  3423.  
  3424. javaex.tip({
  3425. content: res.message,
  3426. type: "error"
  3427. });
  3428.  
  3429. resolve(false);
  3430. }
  3431. }
  3432. })
  3433. });
  3434. },
  3435.  
  3436.  
  3437. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  3438.  
  3439. DoSign: async function() {
  3440. return new Promise((resolve) => {
  3441. Ajax.get({
  3442.  
  3443. url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
  3444. queryStringsObj: {
  3445.  
  3446. },
  3447. hasCookies: true,
  3448. success: responseText => {
  3449. let res = HNTOOL.strToJson(responseText);
  3450. if (res.code === 0) {
  3451.  
  3452. javaex.tip({
  3453. content: "签到成功:" + res.data.text,
  3454. type: "success"
  3455. });
  3456. resolve(true);
  3457.  
  3458. } else if (res.code === 1011040) {
  3459.  
  3460. javaex.tip({
  3461. content: res.message,
  3462. type: "success"
  3463. });
  3464.  
  3465. resolve(true);
  3466. } else {
  3467.  
  3468. javaex.tip({
  3469. content: res.message,
  3470. type: "error"
  3471. });
  3472.  
  3473. resolve(false);
  3474. }
  3475. }
  3476. })
  3477. });
  3478. },
  3479.  
  3480.  
  3481. /**
  3482. * // 获取分区最新专栏列表 https://api.bilibili.com/x/article/recommends?cid=0&pn=1
  3483. */
  3484. getArticleRecommends: async function() {
  3485. return new Promise((resolve) => {
  3486. Ajax.get({
  3487.  
  3488. url: BILIBLI_PATH.api + '/x/article/recommends',
  3489. queryStringsObj: {
  3490. "cid": 0,
  3491. "pn": 1
  3492. },
  3493. hasCookies: true,
  3494. success: responseText => {
  3495. let res = HNTOOL.strToJson(responseText);
  3496. if (res.code === 0) {
  3497.  
  3498. javaex.tip({
  3499. content: "获取最新专栏成功!",
  3500. type: "success"
  3501. });
  3502. resolve(res.data);
  3503.  
  3504. } else {
  3505.  
  3506. javaex.tip({
  3507. content: "获取最新专栏失败!" + res.message,
  3508. type: "error"
  3509. });
  3510.  
  3511. console.log(res.message);
  3512.  
  3513. resolve(false);
  3514. }
  3515. }
  3516. })
  3517. });
  3518. },
  3519. /**
  3520. * // 获取分区最新视频列表
  3521. */
  3522. getDynamicRegion: async function() {
  3523. return new Promise((resolve) => {
  3524. Ajax.get({
  3525.  
  3526. url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
  3527. queryStringsObj: {
  3528. "pn": 1,
  3529. "ps": 20,
  3530. "rid": 21
  3531. },
  3532. hasCookies: true,
  3533. success: responseText => {
  3534. let res = HNTOOL.strToJson(responseText);
  3535. if (res.code === 0) {
  3536.  
  3537. javaex.tip({
  3538. content: "获取分区最新视频成功",
  3539. type: "success"
  3540. });
  3541. resolve(res.data.archives);
  3542.  
  3543. } else {
  3544.  
  3545. javaex.tip({
  3546. content: "获取分区最新视频失败" + res.message,
  3547. type: "error"
  3548. });
  3549.  
  3550. resolve(false);
  3551. }
  3552. }
  3553. })
  3554. });
  3555. },
  3556.  
  3557. /*
  3558. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  3559. * @param {Object} sid
  3560. */
  3561. reserveActivity: async function(sid) {
  3562. return new Promise((resolve) => {
  3563. Ajax.post({
  3564. url: BILIBLI_PATH.api + '/x/space/reserve',
  3565. hasCookies: true,
  3566. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3567. data: {
  3568. sid: sid, //当前用户
  3569. jsonp: "jsonp",
  3570. csrf: Live_info.csrf_token
  3571. },
  3572. success: responseText => {
  3573. let res = HNTOOL.strToJson(responseText);
  3574. if (res.code === 0) {
  3575.  
  3576. resolve(true);
  3577. } else {
  3578. javaex.tip({
  3579. content: res.message,
  3580. type: "error"
  3581. });
  3582. resolve(false);
  3583. }
  3584. }
  3585. })
  3586. });
  3587. },
  3588. /**
  3589. reserveActivity: async function(sid, reserve_total) {
  3590. return new Promise((resolve) => {
  3591. Ajax.post({
  3592. url: BILIBLI_PATH.vcapi + '/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
  3593. hasCookies: true,
  3594. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3595. data: {
  3596. reserve_id: sid,
  3597. cur_btn_status: 1,
  3598. reserve_total: reserve_total,
  3599. csrf: Live_info.csrf_token
  3600. },
  3601. success: responseText => {
  3602. let res = HNTOOL.strToJson(responseText);
  3603. if (res.code === 0) {
  3604.  
  3605. resolve(res.data);
  3606. } else {
  3607.  
  3608. javaex.tip({
  3609. content: res.message,
  3610. type: "error"
  3611. });
  3612.  
  3613. resolve(false);
  3614. }
  3615. }
  3616. })
  3617. });
  3618. }, */
  3619.  
  3620. getGiftList: async function(room) {
  3621. return new Promise((resolve) => {
  3622. Ajax.get({
  3623.  
  3624. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  3625. queryStringsObj: {
  3626. "room_id": room
  3627. },
  3628. hasCookies: true,
  3629. success: responseText => {
  3630. let res = HNTOOL.strToJson(responseText);
  3631. if (res.code === 0) {
  3632.  
  3633. resolve(res.data.list);
  3634. } else {
  3635.  
  3636. javaex.tip({
  3637. content: "查询包裹失败!" + res.message,
  3638. type: "error"
  3639. });
  3640.  
  3641. resolve(false)
  3642. }
  3643. }
  3644. })
  3645. });
  3646. },
  3647.  
  3648. /**
  3649. * 送银B克拉
  3650. * @param {Object} ruid
  3651. * @param {Object} roomid
  3652. */
  3653. bagSendGift: async function(ruid, roomid, bag_id) {
  3654. return new Promise((resolve) => {
  3655. Ajax.post({
  3656. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  3657. hasCookies: true,
  3658. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3659. data: {
  3660. uid: Live_info.uid, //当前用户
  3661. gift_id: 3,
  3662. ruid: ruid,
  3663. send_ruid: 0,
  3664. gift_num: 1,
  3665. bag_id: bag_id,
  3666. //rnd: Math.round(new Date() / 1000); //时间戳,
  3667. platform: 'pc',
  3668. biz_code: 'Live',
  3669. biz_id: roomid,
  3670. storm_beat_id: 0,
  3671. price: 0,
  3672. csrf_token: Live_info.csrf_token,
  3673. csrf: Live_info.csrf_token
  3674.  
  3675. },
  3676. success: responseText => {
  3677. let res = HNTOOL.strToJson(responseText);
  3678. if (res.code === 0) {
  3679.  
  3680. javaex.tip({
  3681. content: roomid + "赠送b克拉成功!" + res.message,
  3682. type: "success"
  3683. });
  3684.  
  3685. resolve(true);
  3686. } else {
  3687.  
  3688. javaex.tip({
  3689. content: res.message,
  3690. type: "error"
  3691. });
  3692.  
  3693. resolve(false);
  3694. }
  3695. }
  3696. })
  3697. });
  3698. },
  3699.  
  3700.  
  3701. /**
  3702. * 判断是否有勋章
  3703. * @param {Object} uid
  3704. * @param {Object} room
  3705. */
  3706.  
  3707. getFansMedalInfo: async function(uid, room) {
  3708. return new Promise((resolve) => {
  3709. Ajax.get({
  3710.  
  3711. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  3712. queryStringsObj: {
  3713. "target_id": uid,
  3714. "room_id": room
  3715. },
  3716. //dataType:'application/json, text/plain, */*',
  3717. hasCookies: true,
  3718. success: responseText => {
  3719. let res = HNTOOL.strToJson(responseText);
  3720. if (res.code === 0) {
  3721.  
  3722. if (res.data.my_fans_medal.level == 0) {
  3723. resolve(false)
  3724. } else {
  3725. resolve(true)
  3726. }
  3727.  
  3728. } else {
  3729.  
  3730. javaex.tip({
  3731. content: "查询勋章失败!" + res.message,
  3732. type: "error"
  3733. });
  3734.  
  3735. resolve(false)
  3736. }
  3737. }
  3738. })
  3739. });
  3740. },
  3741.  
  3742.  
  3743.  
  3744.  
  3745. getDisuidList: async function(re_version, pn) {
  3746. return new Promise((resolve) => {
  3747. Ajax.get({
  3748.  
  3749. url: BILIBLI_PATH.api + '/x/relation/blacks',
  3750. queryStringsObj: {
  3751. "re_version": re_version,
  3752. "pn": pn
  3753. },
  3754. hasCookies: true,
  3755. success: responseText => {
  3756. let res = HNTOOL.strToJson(responseText);
  3757. if (res.code === 0) {
  3758. resolve(res.data.list)
  3759. } else {
  3760.  
  3761. javaex.tip({
  3762. content: "查询黑名单失败!" + res.message,
  3763. type: "error"
  3764. });
  3765.  
  3766. resolve(null)
  3767. }
  3768. }
  3769. })
  3770. });
  3771. },
  3772.  
  3773. /**
  3774. * @param {Object} uid
  3775. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  3776. */
  3777. cancelAtt: async function(uid, act, re_src) {
  3778. return new Promise((resolve) => {
  3779. Ajax.post({
  3780. url: BILIBLI_PATH.api + '/x/relation/modify',
  3781. hasCookies: true,
  3782. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3783. data: {
  3784. fid: uid,
  3785. act: act,
  3786. re_src: re_src == undefined ? 11 : 116,
  3787. jsonp: "jsonp",
  3788. csrf: Live_info.csrf_token,
  3789. },
  3790. success: responseText => {
  3791. let res = HNTOOL.strToJson(responseText);
  3792. if (res.code === 0) {
  3793.  
  3794. //HNAPI.cancelAtt(uid, 6);
  3795.  
  3796. javaex.tip({
  3797. content: "取关成功!" + res.message,
  3798. type: "success"
  3799. });
  3800.  
  3801. resolve(true);
  3802. } else if (res.code === 22003) {
  3803.  
  3804. HNAPI.cancelAtt(uid, 6);
  3805.  
  3806. javaex.tip({
  3807. content: "取消拉黑" + res.message,
  3808. type: "success"
  3809. });
  3810. resolve(true);
  3811. } else {
  3812.  
  3813. javaex.tip({
  3814. content: res.message,
  3815. type: "error"
  3816. });
  3817.  
  3818. resolve(false);
  3819. }
  3820. }
  3821. })
  3822. });
  3823. },
  3824.  
  3825. getRoomMsg: async function(roomid) {
  3826. return new Promise((resolve) => {
  3827. Ajax.get({
  3828.  
  3829. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  3830. queryStringsObj: {
  3831. "roomid": roomid
  3832. },
  3833. hasCookies: true,
  3834. success: responseText => {
  3835. let res = HNTOOL.strToJson(responseText);
  3836. if (res.code === 0) {
  3837. resolve(res.data.info.uid)
  3838. } else {
  3839. resolve(false)
  3840. }
  3841. }
  3842. })
  3843. });
  3844. },
  3845.  
  3846. /**
  3847. *
  3848. * @param sid
  3849. * @returns {Promise<unknown>}
  3850. */
  3851. lotteryDo: async function(sid) {
  3852. return new Promise((resolve) => {
  3853. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/do';
  3854. if (sid.indexOf("newLottery") != -1) {
  3855. func_url = BILIBLI_PATH.api + "/x/lottery/do";
  3856. }
  3857. Ajax.post({
  3858. url: func_url,
  3859. hasCookies: true,
  3860. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3861. data: {
  3862.  
  3863. sid: sid,
  3864. type: 1,
  3865. csrf: Live_info.csrf_token,
  3866. },
  3867. success: responseText => {
  3868. let res = HNTOOL.strToJson(responseText);
  3869. if (res.code === 0) {
  3870. HNTOOL.console("转盘:" + sid + "\n" + (res.data)[0].gift_name);
  3871. resolve((res.data)[0].gift_name);
  3872.  
  3873. } else if (res.code ===
  3874. 75400) { // || res.code === 75003 || res.code === 75403
  3875.  
  3876. resolve(true);
  3877. } else {
  3878. javaex.tip({
  3879. content: "本次抽奖失败!" + res.message,
  3880. type: "error"
  3881. });
  3882. resolve(false);
  3883. }
  3884. }
  3885. })
  3886. });
  3887. },
  3888.  
  3889.  
  3890. getLotteryMytimes: async function(sid) {
  3891. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/mytimes';
  3892. if (sid.indexOf("newLottery") != -1) {
  3893. func_url = BILIBLI_PATH.api + "/x/lottery/mytimes";
  3894. }
  3895. return new Promise((resolve) => {
  3896. Ajax.get({
  3897. url: func_url,
  3898. queryStringsObj: {
  3899. sid: sid
  3900. },
  3901. hasCookies: true,
  3902. success: responseText => {
  3903. let res = HNTOOL.strToJson(responseText);
  3904. if (res.code === 0) {
  3905. resolve(res.data.times)
  3906. } else {
  3907. resolve(0)
  3908. }
  3909. }
  3910. })
  3911. });
  3912. },
  3913.  
  3914. /**
  3915. * 增加抽奖次数一般是分享
  3916. * @param sid 活动sid
  3917. * @returns {Promise<unknown>} 0 成功 1:活动结束
  3918. */
  3919. addLotteryTimes: async function(sid) {
  3920. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/addtimes';
  3921. if (sid.indexOf("newLottery") != -1) {
  3922. func_url = BILIBLI_PATH.api + "/x/lottery/addtimes";
  3923. }
  3924.  
  3925. return new Promise((resolve) => {
  3926. Ajax.post({
  3927. url: func_url,
  3928. hasCookies: true,
  3929. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3930. data: {
  3931.  
  3932. sid: sid,
  3933. action_type: 3,
  3934. csrf: Live_info.csrf_token,
  3935. },
  3936. success: responseText => {
  3937. let res = HNTOOL.strToJson(responseText);
  3938. if (res.code === 0) {
  3939.  
  3940. resolve(0)
  3941. } else if (res.code === 75003 || res.code === 170405 || res.code ===
  3942. 75001 || res.code === 170001 || res.code === 75405) {
  3943.  
  3944. resolve(1)
  3945.  
  3946. } else {
  3947.  
  3948. resolve(res.message);
  3949. }
  3950. }
  3951. })
  3952. });
  3953. },
  3954. /**
  3955. * 查询用户关注 默认一次查询50
  3956. * @param vmid 用户uid
  3957. * @param pn 页码
  3958. * @returns {Promise<unknown>}
  3959. */
  3960. getMyFollow: async function(vmid, pn) {
  3961. return new Promise((resolve) => {
  3962. Ajax.get({
  3963. url: BILIBLI_PATH.api + '/x/relation/followings',
  3964. queryStringsObj: {
  3965. vmid: vmid,
  3966. pn: pn
  3967. },
  3968. hasCookies: true,
  3969. success: responseText => {
  3970. let res = HNTOOL.strToJson(responseText);
  3971. if (res.code === 0) {
  3972. resolve(res.data)
  3973. } else {
  3974. resolve(null)
  3975. }
  3976. }
  3977. })
  3978. });
  3979. },
  3980.  
  3981.  
  3982. getMyinfo: function() {
  3983. return new Promise((resolve) => {
  3984. Ajax.get({
  3985. url: BILIBLI_PATH.api + '/x/space/myinfo',
  3986. queryStringsObj: {},
  3987. hasCookies: true,
  3988. success: responseText => {
  3989. let res = HNTOOL.strToJson(responseText);
  3990. if (res.code === 0) {
  3991. resolve(res.data)
  3992. } else {
  3993. resolve(null)
  3994. }
  3995. }
  3996. })
  3997. });
  3998. },
  3999.  
  4000. getMyJson: function(url) {
  4001. return new Promise((resolve) => {
  4002. GM_xmlhttpRequest({
  4003. method: "GET",
  4004. url: url,
  4005. onload: function(response) {
  4006. const res = HNTOOL.strToJson((response || {}).responseText)
  4007. resolve(res);
  4008. }
  4009. });
  4010. })
  4011. },
  4012.  
  4013.  
  4014. userInfo: function(mid) {
  4015.  
  4016. Ajax.get({
  4017. url: BILIBLI_PATH.api + '/x/space/acc/info',
  4018. queryStringsObj: {
  4019. mid: mid
  4020. },
  4021. hasCookies: true,
  4022. success: responseText => {
  4023.  
  4024. var json = JSON.parse(responseText);
  4025.  
  4026. if (json.code != 0) {
  4027.  
  4028.  
  4029. }
  4030. }
  4031. });
  4032.  
  4033. },
  4034.  
  4035. sendQmsg: async function(key, msg) {
  4036.  
  4037. $.ajax({
  4038. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  4039.  
  4040. success: function(result) {
  4041.  
  4042. }
  4043. });
  4044.  
  4045.  
  4046. /*GM_xmlhttpRequest({
  4047. method: "GET",
  4048. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  4049. onload: function (response) {
  4050.  
  4051. let json = JSON.parse(response.response);
  4052. if (json.code == 0) {
  4053.  
  4054. javaex.tip({
  4055. content: "自动动态中奖提醒成功!" + json.reason,
  4056. type: "success"
  4057. });
  4058. } else {
  4059. console.log("自动动态中奖提醒失败!" + json.reason);
  4060. javaex.tip({
  4061. content: "自动动态中奖提醒失败!" + json.reason,
  4062. type: "error"
  4063. });
  4064. }
  4065.  
  4066. }
  4067. });*/
  4068.  
  4069. },
  4070.  
  4071. /**
  4072. * //https://api.bilibili.com/x/relation/modify
  4073. *
  4074. * @param UID
  4075. */
  4076. disUserByUid: function(vmid) {
  4077.  
  4078. Ajax.post({
  4079. url: BILIBLI_PATH.api + '/x/relation/modify',
  4080. data: {
  4081. fid: parseInt(vmid),
  4082. re_src: 11,
  4083. act: 5,
  4084. jsonp: "jsonp",
  4085. csrf: Live_info.csrf_token,
  4086. },
  4087. hasCookies: true,
  4088. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4089. success: responseText => {
  4090.  
  4091. var json = JSON.parse(responseText);
  4092.  
  4093. if (json.code != 0) {
  4094.  
  4095. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  4096. javaex.tip({
  4097. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  4098. type: "error"
  4099. });
  4100.  
  4101. } else {
  4102. console.log("拉黑用户成功 uid:" + vmid);
  4103. javaex.tip({
  4104. content: "拉黑用户成功 uid:" + vmid,
  4105. type: "success"
  4106. });
  4107. }
  4108. }
  4109. });
  4110.  
  4111. },
  4112. /**
  4113. * http://api.bilibili.com/x/web-interface/view
  4114. * @param BV
  4115. * 心跳间隔15秒
  4116. */
  4117. watchOneVideo: function(BV, MID) {
  4118.  
  4119. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  4120. Ajax.post({
  4121. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  4122. hasCookies: true,
  4123. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4124. data: {
  4125.  
  4126. "bvid": BV,
  4127. "part": 1,
  4128. "mid": Live_info.uid,
  4129. "lv": 2,
  4130. "jsonp": "jsonp",
  4131. "type": 3,
  4132. "sub_type": 0
  4133. },
  4134. success: responseText => {
  4135.  
  4136. let json = JSON.parse(responseText);
  4137.  
  4138. if (/^{"code":0/.test(responseText)) {
  4139. //发送一次心跳
  4140. HNAPI.sendHeartbeat(BV, MID);
  4141.  
  4142. } else {
  4143. javaex.tip({
  4144. content: "视频" + data.bvid + "播放失败!" + json.message,
  4145. type: "error"
  4146. });
  4147. }
  4148. }
  4149. })
  4150.  
  4151.  
  4152. },
  4153.  
  4154. //上报视频播放心跳(web端)
  4155. /**
  4156. * http://api.bilibili.com/x/click-interface/web/heartbeat
  4157. * @param json
  4158. */
  4159. sendHeartbeat: function(bvid, MID) {
  4160.  
  4161. Ajax.post({
  4162. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  4163. hasCookies: true,
  4164. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4165. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  4166. data: {
  4167. "bvid": bvid,
  4168. "type": 3,
  4169. "dt": 2,
  4170. "played_time": HNTOOL.random(12, 40),
  4171. "realtime": HNTOOL.random(12, 40),
  4172. "play_type": 0
  4173. },
  4174. success: responseText => {
  4175.  
  4176. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  4177.  
  4178. javaex.tip({
  4179. content: "视频BV" + bvid + "播放一次!",
  4180. type: "success"
  4181. });
  4182. }
  4183. }
  4184. })
  4185.  
  4186. },
  4187.  
  4188. //获取up所有投稿视频
  4189. /**
  4190. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  4191. * @param mid
  4192. */
  4193. getUpAllBV: function(mid, pn, ps) {
  4194. ps = (ps === undefined ? 30 : ps); // a默认值为1
  4195. Ajax.get({
  4196. url: BILIBLI_PATH.api + '/x/space/arc/search',
  4197. queryStringsObj: {
  4198. mid: mid,
  4199. tid: 0,
  4200. order: 'pubdate',
  4201. jsonp: 'jsonp',
  4202. pn: pn,
  4203. ps: ps
  4204. },
  4205. hasCookies: true,
  4206. success: responseText => {
  4207.  
  4208. var json = JSON.parse(responseText);
  4209.  
  4210. if (json.code != 0) {
  4211.  
  4212. javaex.tip({
  4213. content: "获取up所有投稿视频失败!" + json.message,
  4214. type: "success"
  4215. });
  4216.  
  4217. } else {
  4218. BiliData.BVList = json.data.list.vlist;
  4219.  
  4220. }
  4221. }
  4222. });
  4223.  
  4224. },
  4225.  
  4226.  
  4227. /**
  4228. *
  4229. * @param path
  4230. * @param data
  4231. * @param saveObj
  4232. * @param Func
  4233. */
  4234. publicGet: function(path, queryStringsObj) {
  4235.  
  4236. if (typeof(queryStringsObj) != "undefined") {
  4237. queryStringsObj = {};
  4238. }
  4239. Ajax.get({
  4240. url: BILIBLI_PATH.api + path,
  4241. queryStringsObj: queryStringsObj,
  4242. hasCookies: true,
  4243. success: responseText => {
  4244.  
  4245. let json = JSON.parse(responseText);
  4246. if (chackCode(json.code) && json.code == 0) {
  4247.  
  4248. return json.data;
  4249. }
  4250.  
  4251. return false;
  4252.  
  4253. }
  4254. })
  4255.  
  4256. },
  4257.  
  4258. /**
  4259. * 导航栏用户信息
  4260. */
  4261. getUserNav: async function() {
  4262.  
  4263. GM_xmlhttpRequest({
  4264. method: "GET",
  4265. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  4266. //timeout:3000,
  4267. onload: function(response) {
  4268.  
  4269. let json = JSON.parse(response.response);
  4270. console.log(json);
  4271. BiliData.login_code = json.code;
  4272. BiliData.login_message = json.message;
  4273. BiliData.LoginData = json.data;
  4274.  
  4275. }
  4276. });
  4277.  
  4278. },
  4279.  
  4280. /**
  4281. * 获取某up详细信息
  4282. * http://api.bilibili.com/x/web-interface/card
  4283. */
  4284. getUpCard: function(mid) {
  4285.  
  4286. Ajax.get({
  4287. url: BILIBLI_PATH.api + '/x/web-interface/card',
  4288. queryStringsObj: {
  4289. mid: mid,
  4290. photo: false
  4291. },
  4292. hasCookies: true,
  4293. success: responseText => {
  4294.  
  4295. var json = JSON.parse(responseText);
  4296.  
  4297. if (json.code != 0) {
  4298.  
  4299. javaex.tip({
  4300. content: "查询失败!" + json.message,
  4301. type: "success"
  4302. });
  4303. return false;
  4304. } else {
  4305. BiliData.upCard = json;
  4306.  
  4307. }
  4308.  
  4309.  
  4310. }
  4311. })
  4312.  
  4313. },
  4314.  
  4315. /**
  4316. *
  4317. * @param uid 用户uid
  4318. * @param ps 每页视频个数 默认30个
  4319. * @param pn 第几页
  4320. */
  4321. getUpAllVideo: function(uid, ps, pn) {
  4322.  
  4323. },
  4324. getChallenge: async function() {
  4325.  
  4326.  
  4327. },
  4328. /**
  4329. * 硬币记录
  4330. * @returns {Promise<void>}
  4331. */
  4332. getCoinLog: async function() {
  4333.  
  4334. GM_xmlhttpRequest({
  4335. method: "GET",
  4336. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  4337. //url: "http://api.bilibili.com/x/member/web/coin/log",
  4338. onload: function(response) {
  4339.  
  4340. let json = JSON.parse(response.response);
  4341. if (json.code == 0) {
  4342.  
  4343. console.log("硬币记录" + json);
  4344. BiliData.CoinLog = json.data;
  4345.  
  4346. return true;
  4347. }
  4348.  
  4349. }
  4350. });
  4351. },
  4352. /**
  4353. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  4354. * @returns {Promise<void>}
  4355. */
  4356. getUnread: async function() {
  4357.  
  4358. Ajax.get({
  4359. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  4360. hasCookies: true,
  4361. success: responseText => {
  4362.  
  4363. let json = JSON.parse(responseText);
  4364. if (chackCode(json.code) && json.code == 0) {
  4365.  
  4366. BiliData.Unread = json.data;
  4367. showUnreadMsg();
  4368. }
  4369.  
  4370. return false;
  4371.  
  4372. }
  4373. })
  4374.  
  4375. /* GM_xmlhttpRequest({
  4376. method: "GET",
  4377. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  4378. onload: function (response) {
  4379.  
  4380. let json = JSON.parse(response.response);
  4381.  
  4382. if (chackCode(json.code) && json.code == 0) {
  4383.  
  4384. BiliData.Unread = json.code;
  4385. showUnreadMsg();
  4386.  
  4387. }
  4388.  
  4389. }
  4390. });*/
  4391. },
  4392. /**
  4393. *
  4394. * @param type reply:回复我的 at @我的
  4395. */
  4396. getMsgfeed: function(type) {
  4397. Ajax.get({
  4398. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  4399. queryStringsObj: {
  4400. build: 0,
  4401. mobi_app: 'web'
  4402. },
  4403. hasCookies: true,
  4404. success: responseText => {
  4405.  
  4406. var json = JSON.parse(responseText);
  4407.  
  4408. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  4409. return false;
  4410. } else {
  4411. chackAtMsg(json.data.items);
  4412.  
  4413. return true;
  4414. }
  4415.  
  4416.  
  4417. }
  4418. })
  4419.  
  4420. },
  4421.  
  4422. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  4423. * @returns {Promise<void>}
  4424. */
  4425. getUnrewad: async function() {
  4426.  
  4427. GM_xmlhttpRequest({
  4428. method: "GET",
  4429. data: {
  4430. "mid": 99439379,
  4431. "pn": 1,
  4432. "ps": 5,
  4433. },
  4434. url: BILIBLI_PATH.api + "/x/space/arc/search",
  4435. onload: function(response) {
  4436.  
  4437. let json = JSON.parse(response.response);
  4438. if (json.code == 0) {
  4439.  
  4440. BiliData.Video = json.data;
  4441. console.log("未读消息数" + json);
  4442. }
  4443.  
  4444. }
  4445. });
  4446. },
  4447.  
  4448. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  4449. * @param {number} oid
  4450. * @param {nbumber} rpid
  4451. * @param {number} action
  4452. * @returns {Promise<void>}
  4453. * type: 11
  4454. * ordering: heat
  4455. * jsonp: jsonp
  4456. * csrf: 54a******* CSRF Token(位于cookie)
  4457. */
  4458.  
  4459. likeInDynamicComments: async function(latestDynamic) {
  4460.  
  4461.  
  4462. Ajax.post({
  4463. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  4464. hasCookies: true,
  4465. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4466. data: {
  4467. "oid": oid,
  4468. "type": 11,
  4469. "rpid": rpid,
  4470. "action": action,
  4471. "ordering": "heat",
  4472. "jsonp": "jsonp",
  4473. "csrf": Live_info.csrf_token,
  4474. },
  4475. success: responseText => {
  4476.  
  4477. if (/^{"code":0/.test(responseText)) {
  4478.  
  4479. BiliData.replyAction = JSON.parse(responseText);
  4480. console.log("点赞成功!" + responseText);
  4481. }
  4482. }
  4483. })
  4484.  
  4485. }
  4486.  
  4487.  
  4488. }
  4489.  
  4490. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  4491. var http_request = null;
  4492.  
  4493. function send_request(url, method) {}
  4494.  
  4495. let HNTOOL = {
  4496. /**
  4497. * 判断是否为整数类型方式
  4498. * @param {Object} obj
  4499. */
  4500. isInteger: function(obj) {
  4501.  
  4502. return obj % 1 === 0
  4503.  
  4504. },
  4505.  
  4506. jury_case: async function() {
  4507.  
  4508. for (let i = 0; i < 30; i++) {
  4509.  
  4510. //1.获取题号
  4511. let case_id = await HNAPI.jury_case_next();
  4512. await HNTOOL.Sleep(1000);
  4513. if (case_id == false) {
  4514. break;
  4515. }
  4516. //2.获取该题号详情
  4517. let vote = await HNAPI.jury_case_info(case_id);
  4518. await HNTOOL.Sleep(4 * 1000);
  4519. if (vote == false) {
  4520. break;
  4521. }
  4522. let opinion = await HNAPI.jury_case_opinion(case_id);
  4523. await HNTOOL.Sleep(15 * 1000);
  4524. //3.开始答题
  4525. let result = await HNAPI.jury_vote(case_id, vote, 1);
  4526. if (result) {
  4527. HNTOOL.console("第" + (i + 1) + "个案号:" + case_id + "完成!");
  4528. } else {
  4529. alert(result);
  4530. }
  4531. let case_id3 = await HNAPI.jury_case_next();
  4532.  
  4533. }
  4534.  
  4535. },
  4536. console: function(str, type) {
  4537.  
  4538. console.log(javaex.now() + "\n" + str);
  4539.  
  4540. javaex.tip({
  4541. content: str,
  4542. type: type == undefined || type == "success" ? "success" : type
  4543. });
  4544.  
  4545. },
  4546.  
  4547. doOneDynamic: async function(randomtime) {
  4548.  
  4549. var myVar = setInterval(async function() {
  4550.  
  4551. let randomStr = await HNTOOL.getRandomString();
  4552. await HNAPI.sendOneDynamic(randomStr);
  4553.  
  4554. }, randomtime);
  4555. },
  4556.  
  4557. getRandomString: function() {
  4558.  
  4559. return new Promise((resolve) => {
  4560. Ajax.get({
  4561. url: "https://api.mcloc.cn/love/",
  4562. //url: 'https://api.mcloc.cn/words/?type=json',//随机一个句子
  4563. //url: 'https://interface.meiriyiwen.com/article/random?dev=1',//随机一个句子
  4564. queryStringsObj: {
  4565. type: "json"
  4566. },
  4567. dataType: "text/html; charset=UTF-8",
  4568. hasCookies: false,
  4569. success: responseText => {
  4570.  
  4571. try {
  4572. let res = HNTOOL.strToJson(responseText);
  4573. resolve(res.data); //随机一句情话
  4574. //resolve(body.data+"---"+body.creator);//随机一个句子
  4575. //resolve(body.data.digest);//随机一个句子
  4576. } catch (e) {
  4577.  
  4578. resolve("你的名字,是我见过最短的情诗。"); //随机一句情话
  4579. }
  4580.  
  4581.  
  4582. }
  4583. })
  4584. });
  4585. },
  4586.  
  4587. getLatestDynamic: async function() {
  4588.  
  4589. let latestDynamic = await HNAPI.getTodayDynamicList(226257459, 3);
  4590. await HNTOOL.Sleep(1000);
  4591. let ldList = [];
  4592. let ldList2 = [];
  4593. for (let ld1 of latestDynamic) {
  4594.  
  4595. let ld = await HNTOOL.getDynamicIdList(ld1);
  4596. await HNTOOL.Sleep(1000);
  4597. ldList = ldList.concat(ld);
  4598. }
  4599.  
  4600. let latestDynamic2 = await HNAPI.getTodayDynamicList(2295698, 2);
  4601. await HNTOOL.Sleep(1000);
  4602.  
  4603. for (let ld2 of latestDynamic) {
  4604.  
  4605. let ld = await HNTOOL.getDynamicIdList(ld2);
  4606. await HNTOOL.Sleep(1000);
  4607. ldList2 = ldList2.concat(ld);
  4608. }
  4609. ldList.push.apply(ldList, ldList2);
  4610.  
  4611. let result = HNTOOL.arrUnique(ldList, false);
  4612.  
  4613. return result;
  4614.  
  4615. },
  4616.  
  4617. getDynamicIdList: async function(latestDynamic) {
  4618.  
  4619.  
  4620.  
  4621. return new Promise((resolve) => {
  4622. Ajax.get({
  4623. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  4624. queryStringsObj: {
  4625.  
  4626. },
  4627. dataType: "text/html; charset=utf-8",
  4628. hasCookies: true,
  4629. success: responseText => {
  4630. let datalist = HNTOOL.httpString(responseText);
  4631. let dls;
  4632. let returnlist = [];
  4633. if (datalist != undefined && datalist.length > 0) {
  4634. for (let dl of datalist) {
  4635.  
  4636. let len = dl.indexOf("?");
  4637. if (len == -1) {
  4638. dl += "?tab=2";
  4639. }
  4640. dls = dl.substring(dl.indexOf("?") - 18, dl.indexOf("?"));
  4641. if (dls == false ||
  4642. dls == null ||
  4643. dl.indexOf("read") > -1 ||
  4644. dl.indexOf("html") > -1 ||
  4645. dl.indexOf("pixiv") > -1 ||
  4646. returnlist.indexOf(dls) > -1) {
  4647. continue;
  4648. }
  4649.  
  4650. returnlist.push(dls);
  4651.  
  4652. }
  4653.  
  4654. resolve(HNTOOL.arrUnique(returnlist, false));
  4655. } else {
  4656. resolve(false);
  4657. }
  4658. }
  4659. })
  4660. });
  4661. },
  4662.  
  4663. httpString: function(s) {
  4664. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  4665. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  4666. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4667. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4668. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  4669. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  4670. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  4671. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  4672. s = s.match(reg);
  4673. console.log(s)
  4674. return (s)
  4675. },
  4676.  
  4677. saveConfig: function() {
  4678.  
  4679. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  4680. /* javaex.tip({
  4681. content: "配置保存成功!",
  4682. type: "success"
  4683. }); */
  4684.  
  4685. },
  4686.  
  4687. copyText: function(domId) {
  4688. let btn = document.getElementById(domId);
  4689. btn.select();
  4690. if (document.execCommand('copy')) {
  4691. document.execCommand('copy');
  4692. javaex.tip({
  4693. content: "复制成功!",
  4694. type: "success"
  4695. });
  4696. }
  4697.  
  4698. },
  4699. /**
  4700. * s数组去重并排序
  4701. */
  4702.  
  4703. arrUnique: function(ary, isSort) {
  4704.  
  4705. if (isSort == undefined) {
  4706. isSort = true
  4707. }
  4708. let obj = {};
  4709. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  4710. let item = ary[i]
  4711. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  4712. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  4713. // 如果没有 将这个元素添加到对象中
  4714. if (isSort) {
  4715. ary.sort((a, b) => {
  4716. return a - b
  4717. }) // 数组去重后 按升序排列
  4718. }
  4719.  
  4720. obj = null;
  4721.  
  4722. javaex.tip({
  4723. content: "已去重!",
  4724. type: "success"
  4725. });
  4726. return ary;
  4727.  
  4728. },
  4729.  
  4730. split_array: function(arr, len) {
  4731.  
  4732. let arr_length = arr.length;
  4733. let newArr = [];
  4734. for (let i = 0; i < arr_length; i += len) {
  4735. newArr.push(arr.slice(i, i + len));
  4736. }
  4737. return newArr;
  4738. },
  4739. strToJson: function(params) {
  4740. const isJSON = (str => {
  4741. if (typeof str === 'string') {
  4742. try {
  4743. const obj = JSON.parse(str);
  4744. return typeof obj === 'object' ? obj : false
  4745. } catch (_) {
  4746. console.log(str);
  4747. return false;
  4748. }
  4749. } else {
  4750. console.log(`${str}\nIt is not a string!`);
  4751. return false;
  4752. }
  4753. })(params);
  4754. return isJSON ? isJSON : {}
  4755. },
  4756.  
  4757. chackAtMsg: function() {
  4758.  
  4759. let config = HNTOOL.getConfig();
  4760. if (config.qmsg_checked == true && config.qmsg_key) {
  4761.  
  4762. document.getElementById("getAtMsg").click();
  4763.  
  4764. }
  4765.  
  4766. },
  4767.  
  4768. cssChecked: function(id, dom) {
  4769.  
  4770. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  4771.  
  4772.  
  4773. },
  4774. getConfig: function() {
  4775.  
  4776. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  4777.  
  4778. if (CONFIG == null) {
  4779. CONFIG = HN_SETUP_CONFIG;
  4780. }
  4781.  
  4782. return CONFIG;
  4783. },
  4784.  
  4785. /**
  4786. * 获取cookie 中某个键对应的值
  4787. * @param name
  4788. */
  4789.  
  4790. getCookie: function(name) {
  4791. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  4792. if (arr != null) return escape(arr[2]);
  4793. return false;
  4794. },
  4795. /**
  4796. * 得到一个字符串数组的中随机一个
  4797. * @param {List} list
  4798. */
  4799.  
  4800.  
  4801. getRandomWordOfList: function(list) {
  4802. var L = list.length;
  4803. var i = Math.ceil(Math.random() * (L - 1));
  4804.  
  4805. return list[i];
  4806. },
  4807. random: function(min, max) {
  4808.  
  4809. return Math.floor(Math.random() * (max - min)) + min;
  4810. },
  4811.  
  4812. Sleep: function(ms) {
  4813. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  4814. }
  4815.  
  4816. }
  4817.  
  4818. let errorMsg = {
  4819. "-1": "应用程序不存在或已被封禁!",
  4820. "-2": "Access Key错误!",
  4821. "-3": "API校验密匙错误!",
  4822. "-4": "调用方对该Method没有权限!",
  4823. "-101": "账号未登录!",
  4824. "-102": "账号被封停!",
  4825. "-103": "积分不足!",
  4826. "-104": "硬币不足!",
  4827. "-105": "验证码错误!",
  4828. "-106": "账号非正式会员或在适应期!",
  4829. "-107": "应用不存在或者被封禁!",
  4830. "-108": "未绑定手机!",
  4831. "-109": "未知!",
  4832. "-110": "未绑定手机!",
  4833. "-111": "csrf 校验失败!",
  4834. "-112": "系统升级中!",
  4835. "-113": "账号尚未实名认证!",
  4836. "-114": "请先绑定手机!",
  4837. "-115": "请先完成实名认证!",
  4838. "-304": "木有改动!",
  4839. "-307": "撞车跳转!",
  4840. "-400": "请求错误!",
  4841. "-401": "未认证!",
  4842. "-403": "访问权限不足!",
  4843. "-404": "啥都木有!",
  4844. }
  4845.  
  4846. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  4847. /**
  4848. *
  4849. * @param code
  4850. * @constructor
  4851. */
  4852. let chackCode = function(code) {
  4853.  
  4854. let emsg = errorMsg[code + ""];
  4855. if (emsg != null) {
  4856. javaex.tip({
  4857. content: emsg,
  4858. type: "error"
  4859. });
  4860.  
  4861. return false;
  4862. }
  4863.  
  4864. return true;
  4865. }
  4866.  
  4867.  
  4868. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  4869. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  4870.  
  4871. /*window.onbeforeunload = function() {
  4872. if (!canLeavePage()) {
  4873. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  4874. }
  4875. };*/
  4876.  
  4877.  
  4878. /**
  4879. * Ajax请求对象
  4880. */
  4881. const Ajax = (() => {
  4882. /**
  4883. * 检查options是否符合要求
  4884. * @param {object} options
  4885. * @returns {boolean}
  4886. */
  4887. function checkOptions(options) {
  4888. let result = false;
  4889. if (typeof options !== 'object') {
  4890. console.warn('类型错误: typeof Options !== Object');
  4891. return result;
  4892. } else {
  4893. if (typeof options.url !== 'string') {
  4894. console.warn('类型错误: typeof Link !== Strings');
  4895. return result;
  4896. } else {
  4897. const reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  4898. //const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  4899. if (!reg.test(options.url)) {
  4900. console.warn('url字符串须为完整http链接');
  4901. return result;
  4902. }
  4903. result = true;
  4904. }
  4905. }
  4906. return result;
  4907. }
  4908.  
  4909. /**
  4910. * 对象转URL编码
  4911. * @param {object} data
  4912. */
  4913. function objToURLCode(data) {
  4914. var _result = [];
  4915. for (var key in data) {
  4916. var value = data[key];
  4917. if (value instanceof Array) {
  4918. value.forEach(function(_value) {
  4919. _result.push(key + "=" + _value);
  4920. });
  4921. } else {
  4922. _result.push(key + '=' + value);
  4923. }
  4924. }
  4925. return _result.join('&');
  4926. }
  4927.  
  4928. /**
  4929. * 请求
  4930. * @param {string} method
  4931. * @param {object} options
  4932. */
  4933. function request(method, options) {
  4934. if (checkOptions(options)) {
  4935. let xhr = new XMLHttpRequest();
  4936. const {
  4937. url: _url,
  4938. queryStringsObj,
  4939. data,
  4940. dataType,
  4941. payload,
  4942. hasCookies
  4943. } = options, url = typeof queryStringsObj === 'object' ?
  4944. _url + '?' + objToURLCode(queryStringsObj) : _url;
  4945. switch (method) {
  4946. case 'GET':
  4947. xhr.open("GET", url);
  4948. break;
  4949. case 'POST':
  4950. xhr.open("POST", url);
  4951. xhr.setRequestHeader('Content-Type', dataType);
  4952. //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");
  4953. break;
  4954. default:
  4955. break;
  4956. }
  4957. if (hasCookies) xhr.withCredentials = true;
  4958. xhr.timeout = 3000;
  4959. xhr.addEventListener('load', () => {
  4960. if (xhr.status === 200) {
  4961. options.success(xhr.responseText)
  4962. } else {
  4963. console.error(`status:${xhr.status}`);
  4964. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  4965. }
  4966. })
  4967. xhr.addEventListener('error', () => {
  4968. console.error('ajax请求出错')
  4969. options.success('{"code":-1,"msg":"ajax请求出错"}');
  4970. })
  4971. xhr.addEventListener('timeout', () => {
  4972. console.error('请求超时')
  4973. options.success('{"code":-1,"msg":"请求超时"}');
  4974. })
  4975. switch (method) {
  4976. case 'GET':
  4977. xhr.send()
  4978. break;
  4979. case 'POST':
  4980. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  4981. //xhr.send(payload);
  4982. break;
  4983. default:
  4984. break;
  4985. }
  4986. }
  4987. }
  4988.  
  4989. return {
  4990. /**
  4991. * 发送Get请求
  4992. * @param {Object} options
  4993. */
  4994. get(options) {
  4995. request("GET", options);
  4996. },
  4997. /**
  4998. * 发送Post请求
  4999. * @param {object} options
  5000. */
  5001. post(options) {
  5002. request("POST", options);
  5003. }
  5004. }
  5005. })()