Greasy Fork 还支持 简体中文。

-哔哩猫-(试用版)

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

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

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