-哔哩猫-(试用版)

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

目前为 2021-08-03 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/422731/956931/-%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 1.9.98
  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. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
  10. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex.min.js
  11. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex-formVerify.js
  12. // @resource animate http://cdn.javaex.cn/javaex/pc/css/animate.css
  13. // @resource common http://cdn.javaex.cn/javaex/pc/css/common.css
  14. // @resource defaultCss http://cdn.javaex.cn/javaex/pc/css/skin/default.css
  15. // @grant unsafeWindow
  16. // @grant GM_getValue
  17. // @grant GM_setValue
  18. // @grant GM_xmlhttpRequest
  19. // @grant GM_getResourceText
  20. // @grant GM_openInTab
  21. // @grant GM_addStyle
  22. // @run-at document-idle
  23. // @license MIT License
  24. // @connect github.com
  25. // @connect gitee.com
  26. // @connect api.bilibili.com
  27. // @connect qmsg.zendee.cn
  28. // @connect passport.bilibili.com
  29. // @connect api.live.bilibili.com
  30. // @namespace http://tampermonkey.net/
  31. // ==/UserScript==
  32.  
  33.  
  34.  
  35.  
  36. GM_addStyle(
  37. `
  38.  
  39. #switch-qsmg:before {
  40. content: "开关";
  41. letter-spacing: 16px;
  42. top: 4px;
  43. left: 10px;
  44. }
  45. #left_navbar{
  46. z-index: 1000;
  47. position: absolute;
  48. top: 100px;
  49. left: 5px;
  50. }
  51. button[hnBtn="btn_open"] {
  52. z-index: 1001;
  53. z-index: 1000px;
  54. position: absolute;
  55. top: 58px;
  56. left: 220px;
  57. }
  58. .javaex-panel.javaex-panel-right.javaex-animated-zoom-in {
  59. top: 60px;
  60. }
  61. .javaex-menu-container {
  62. border: 1px solid #eee;
  63. }
  64. .javaex-panel-box p {
  65. text-align: center;
  66. background: #fb7299;
  67. }
  68. .fontbold{
  69. color: #00a1d6;
  70. font-weight: bold;
  71. cursor: pointer;
  72. }
  73. `
  74. );
  75.  
  76.  
  77. let HN_SETUP_CONFIG = {
  78.  
  79. qmsg_key: null, //后期改为kull 存储到本地
  80. qmsg_checked: false,
  81. Booking_last_sid: null,
  82. }
  83.  
  84. let replyList = ["哇⊙ω⊙", "仙女震惊", "都关注这么久了给个吧", "大佬,看下孩子吧,这次一定", "会有我吗?黑幕一手",
  85. "酋长在线拉低中奖率", "好耶(✪▽✪)", "建议直接送我", "我愿意用我二十斤的肉肉换这次的好运", "希望欧一次", "永不缺席", " 永不中奖", " 永不放弃!", "万一呢", "在", "冲吖~", "来了",
  86. "芜湖,都想要,抽中那个都不亏阿", "从未中,从未停", "来力", "秋", "懂我意思吧", "宝,我今天去吃面了,吃的什么面,突然想见你一面", "从不缺席",
  87. "站友保佑抽到", "可以", "恰", "不会吧", "1", "好", "rush", "来", "来来", "ok", "冲", "凑热闹", "我要我要", "我还能中!", "让我中!!!",
  88. "是我的", "我是天选之子", "给我中一次吧!", "坚持不懈,迎难而上", "开拓创新!", "我来抽个奖", "中中中中中", "我我我", "搞笑 这不得转", "啪一下我就下手了",
  89. "看这里就想中一次", "不可能", "我不挑,都可以", "俺要当分母", "万一呢"
  90. ]
  91.  
  92.  
  93. let Live_info = {
  94. room_id: undefined,
  95. uid: undefined,
  96. blocked: undefined,
  97. csrf_token: undefined,
  98. SESSDATA: undefined,
  99. visit_id: undefined,
  100. rnd: undefined,
  101. ruid: undefined,
  102. uname: undefined,
  103. user_level: undefined,
  104. ruid: undefined,
  105. };
  106.  
  107. let BILIBLI_PATH = {
  108.  
  109. "live": "https://api.live.bilibili.com",
  110. "vcapi": "https://api.vc.bilibili.com",
  111. "passport": "https://passport.bilibili.com",
  112. "api": "https://api.bilibili.com",
  113. "video": "https://www.bilibili.com/video/",
  114. "single_unread": "http://api.vc.bilibili.com/",
  115.  
  116. }
  117.  
  118. let BILIBILI_URL = {
  119. // 导航栏用户信息
  120. "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
  121. }
  122.  
  123. let BiliData = {
  124.  
  125. this_uid: window.location.href.split("/")[3], //当前页面uid
  126. author_uid: 99439379,
  127. login_code: null,
  128. login_message: "",
  129. LoginData: {},
  130. CoinLog: {},
  131. Unread: null,
  132. Video: {},
  133. replyAction: {},
  134. upCard: {},
  135. BVList: [],
  136. }
  137.  
  138. window.onload = function() {
  139.  
  140.  
  141. //界面显示
  142. init();
  143.  
  144.  
  145. }
  146.  
  147.  
  148. function init() {
  149.  
  150. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  151. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  152. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  153.  
  154. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&54988";
  155.  
  156.  
  157. addStyle();
  158. addSetPage();
  159.  
  160. HNTOOL.chackAtMsg();
  161.  
  162. $("#getCoinLog").bind("click", async function() {
  163.  
  164.  
  165. if (HNAPI.getCoinLog()) {
  166.  
  167. await HNTOOL.Sleep(500);
  168. let html = '';
  169. html += '<div class="javaex-panel-box" style="width: 250px;">';
  170. html += ' <ul>';
  171. html += ` <p style="color: #FFF;">硬币使用记录</p>`;
  172.  
  173. BiliData.CoinLog.list.forEach(function(item) {
  174.  
  175. let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
  176. if (BV.indexOf("BV") != -1) {
  177. html += `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
  178. }
  179. html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
  180.  
  181.  
  182. });
  183. html += ' <hr class="javaex-divider"></hr>';
  184. html += ' </ul>';
  185. html += '</div>';
  186.  
  187. javaex.panel(this, {
  188. position: "right",
  189. //offsetTop: "104",
  190. content: html
  191. });
  192. javaex.tip({
  193. content: "获取用户成功!",
  194. type: "success"
  195. });
  196.  
  197. } else {
  198. javaex.tip({
  199. content: "获取硬币记录失败,请稍后重试!",
  200. type: "error"
  201. });
  202. }
  203.  
  204.  
  205. });
  206.  
  207. $("#getUnread").bind("click", async function() {
  208.  
  209. javaex.tip({
  210. content: "获取中,请稍候...",
  211. type: "submit"
  212. });
  213. HNAPI.getUnread();
  214.  
  215.  
  216. });
  217.  
  218.  
  219. $("#likeInDynamicComments").bind("click", async function() {
  220.  
  221. let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get("likeInDynamic_PRID");
  222. let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get("likeInDynamic_OID");
  223.  
  224. let html = '';
  225.  
  226. html += '<div style="padding: 10px 10px 10px 0px;">'
  227. html += '<form id="likeInDynamic_form">'
  228. html += ' <div class="javaex-unit clear">'
  229. html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
  230. html += ' <div class="javaex-unit-right">'
  231. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
  232. html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
  233. html += ' </div>'
  234. html += ' </div>'
  235. html += ' <div class="javaex-unit clear">'
  236. html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
  237. html += ' <div class="javaex-unit-right">'
  238. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
  239. html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
  240. html += ' </div>'
  241. html += ' </div>'
  242. html += ' <div class="javaex-unit clear tc">'
  243. html +=
  244. ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
  245. html +=
  246. ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
  247. html += ' </div>'
  248. html += '</form>';
  249. html += '<hr class="javaex-divider"></hr>';
  250. html += '</div>';
  251.  
  252.  
  253. javaex.panel(this, {
  254. position: "right",
  255. content: html
  256. });
  257.  
  258.  
  259. // 监听点击保存按钮事件
  260. $("#likeInDynamic_yes").click(async function() {
  261. // 表单验证函数
  262. if (javaexVerify()) {
  263.  
  264. HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex.getSelectVal(
  265. "#likeInDynamic_PRID"), 1);
  266. await HNTOOL.Sleep(1000);
  267.  
  268. if (BiliData.replyAction.code == 0) {
  269.  
  270. LocalData.set("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  271. LocalData.set("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  272.  
  273. javaex.tip({
  274. content: "评论区点赞成功!",
  275. type: "success"
  276. });
  277. } else {
  278. javaex.tip({
  279. content: "评论区点赞失败!",
  280. type: "error"
  281. });
  282. }
  283. if (BiliData.replyAction.code == 65006) {
  284. javaex.tip({
  285. content: "请勿重复点赞!",
  286. type: "error"
  287. });
  288. }
  289. }
  290. });
  291.  
  292. // 监听点击返回按钮事件
  293. $("#likeInDynamic_no").click(async function() {
  294.  
  295. if (javaexVerify()) {
  296.  
  297. HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +javaex.getLocalStorage(
  298. "#likeInDynamic_PRID"), 0);
  299. await HNTOOL.Sleep(500);
  300.  
  301. if (BiliData.replyAction.code == 0) {
  302.  
  303. javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  304. javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  305.  
  306. javaex.tip({
  307. content: "评论区取消点赞成功!",
  308. type: "success"
  309. });
  310. } else {
  311. javaex.tip({
  312. content: "评论区取消点赞失败!",
  313. type: "error"
  314. });
  315. }
  316. if (BiliData.replyAction.code == 65006) {
  317. javaex.tip({
  318. content: "请勿重复取消点赞!",
  319. type: "error"
  320. });
  321. }
  322. }
  323. });
  324.  
  325. });
  326.  
  327. $("#biliUserMsg").bind("click", async function() {
  328.  
  329.  
  330. //刷新信息
  331. HNAPI.getUserNav();
  332. await HNTOOL.Sleep(500);
  333.  
  334. let isLogin = "未登录";
  335. let vipType = "无";
  336. //判断是否成功
  337. if (BiliData.login_code == 0) {
  338.  
  339.  
  340. if (BiliData.LoginData.isLogin) {
  341. isLogin = "已登录";
  342. }
  343.  
  344. if (BiliData.LoginData.vipType == 1) {
  345. vipType = "月度大会员";
  346. } else if (BiliData.LoginData.vipType == 2) {
  347. vipType = "年度大会员";
  348. }
  349.  
  350. let html = '';
  351. html += '<div class="javaex-panel-box" style="width: 250px;">';
  352. html += ' <ul>';
  353. html += ` <p style="color: #FFF;">用户信息</p>`;
  354. html += ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
  355. html += ` <li>用户状态:${isLogin} </li> `;
  356. html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
  357. html +=
  358. ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
  359. html += ` <li>UID${BiliData.LoginData.mid} </li> `;
  360. html += ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
  361. html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
  362. html += ` <li>会员:${vipType} </li> `;
  363. html += ' <hr class="javaex-divider"></hr>';
  364. html += ' </ul>';
  365. html += '</div>';
  366.  
  367.  
  368. javaex.panel(this, {
  369. position: "right",
  370. content: html
  371. });
  372.  
  373. javaex.tip({
  374. content: "获取用户成功!",
  375. type: "success"
  376. });
  377.  
  378. } else {
  379. javaex.tip({
  380. content: "获取用户信息失败!",
  381. type: "error"
  382. });
  383. }
  384.  
  385.  
  386. });
  387.  
  388. $("#getAtMsg").bind("click", async function() {
  389.  
  390. if (HNAPI.getMsgfeed("at") && typeof(HNAPI.getMsgfeed("at")) != "undefined") {
  391.  
  392. javaex.tip({
  393. content: "可能中奖了!!!",
  394. type: "success"
  395. });
  396. }
  397. });
  398.  
  399.  
  400. $("#disUser").bind("click", async function() {
  401.  
  402. let html = '';
  403. html += '<div class="javaex-panel-box" style="width: 500px;">';
  404. html += ' <div class="javaex-unit clear">';
  405. html += ' <div class="javaex-unit-left ml-10 mt-10">*UID列表</div>';
  406. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  407. html +=
  408. ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
  409. html += ' </div>';
  410. html += ' </div>';
  411. html += ' <div class="javaex-unit clear tc">';
  412. html += ' <input type="button" id="disUser_block" class="javaex-btn yes" value="拉黑" />';
  413. html += ' <input type="button" id="disUser_cancelAtt_uid" class="javaex-btn yes" value="UID取关" />';
  414. html += ' <input type="button" id="disUser_cancelAtt_room" class="javaex-btn yes" value="房间号取关" />';
  415. html += ' </div>';
  416. html += '</div>';
  417.  
  418. javaex.panel(this, {
  419. position: "right",
  420. content: html
  421. });
  422.  
  423. let disUser_str;
  424. //拉黑
  425. $("#disUser_block").bind("click", async function() {
  426.  
  427. disUser_str = javaex.getSelectVal("#disUser_uidList");
  428. let disUser_uidList = disUser_str.split(",");
  429. let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
  430.  
  431. for (const vmid of disUserStr) {
  432.  
  433. HNAPI.batchModify(vmid.toString(), 5);
  434. await HNTOOL.Sleep(2000);
  435. }
  436. });
  437. //取关uid
  438. $("#disUser_cancelAtt_uid").bind("click", async function() {
  439. disUser_str = javaex.getSelectVal("#disUser_uidList");
  440. let disUser_uidList = disUser_str.split(",");
  441.  
  442. javaex.tip({
  443. content: "根据uid批量取关开始!!!",
  444. type: "success"
  445. });
  446.  
  447. /*
  448. let disuidList = [];
  449. let PN = 100;
  450. PN = disUser_uidList.length == 1 ? 0 : PN;
  451.  
  452. for (var i = 0; i < PN; i++) {
  453.  
  454. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  455. javaex.tip({
  456. content: "获取第" + i + "页黑名单成功!",
  457. type: "success"
  458. });
  459. await HNTOOL.Sleep(1000);
  460.  
  461. if (uidList.length == 0) {
  462. break;
  463. }
  464. if (uidList == null) {
  465. continue;
  466. }
  467.  
  468. for (let disuid of uidList) {
  469. if (disuidList.indexOf(disuid.mid) == -1) {
  470. disuidList.push(disuid.mid + "");
  471. }
  472. }
  473.  
  474.  
  475. } */
  476. let J = 1;
  477.  
  478. for (let uid of disUser_uidList) {
  479.  
  480. /* let uidType = "未在黑名单";
  481. if (disuidList.indexOf(uid) == -1) {
  482.  
  483. await HNAPI.cancelAtt(uid, 2);
  484. } else {
  485.  
  486. await HNAPI.cancelAtt(uid, 6, 116);
  487. uidType = "黑名单用户";
  488. } */
  489. await HNAPI.cancelAtt(uid, 2);
  490.  
  491. javaex.tip({
  492. content: "【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" + disUser_uidList.length + ")",
  493. type: "success"
  494. });
  495. await HNTOOL.Sleep(1000);
  496. }
  497.  
  498.  
  499. alert("根据uid批量取关完成!");
  500.  
  501. /* javaex.alert({
  502. content: "根据uid批量取关完成!",
  503. confirm: function() {
  504.  
  505. //return false;
  506. }
  507. }); */
  508.  
  509. });
  510. //取关room
  511. $("#disUser_cancelAtt_room").bind("click", async function() {
  512.  
  513. javaex.tip({
  514. content: "根据房间号批量取关开始!!!",
  515. type: "success"
  516. });
  517.  
  518. disUser_str = javaex.getSelectVal("#disUser_uidList");
  519. let disUser_roomList = disUser_str.split(",");
  520. /* let disuidList = [];
  521. let PN = 100;
  522. PN = disUser_roomList.length == 1 ? 0 : PN;
  523.  
  524. for (var i = 0; i < PN; i++) {
  525.  
  526. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  527. javaex.tip({
  528. content: "获取第" + i + "页黑名单成功!",
  529. type: "success"
  530. });
  531. await HNTOOL.Sleep(1000);
  532.  
  533. if (uidList.length == 0) {
  534. break;
  535. }
  536. if (uidList == null) {
  537. continue;
  538. }
  539.  
  540. for (let disuid of uidList) {
  541.  
  542. if (disuidList.indexOf(disuid.mid) == -1) {
  543. disuidList.push(disuid.mid);
  544. }
  545.  
  546. }
  547.  
  548.  
  549. } */
  550. let J = 1;
  551. for (let room of disUser_roomList) {
  552.  
  553. let uid = await HNAPI.getRoomMsg(room);
  554.  
  555. await HNTOOL.Sleep(1000);
  556.  
  557. if (uid == false) {
  558. javaex.tip({
  559. content: "uid查询失败跳过!",
  560. type: "error"
  561. });
  562. continue;
  563. }
  564. /* let uidType = "未在黑名单";
  565. if (disuidList.indexOf(uid) == -1) {
  566.  
  567. await HNAPI.cancelAtt(uid, 2);
  568. } else {
  569.  
  570. await HNAPI.cancelAtt(uid, 6, 116);
  571. uidType = "黑名单用户";
  572. } */
  573. await HNAPI.cancelAtt(uid, 2);
  574.  
  575. javaex.tip({
  576. content: "Room:" + room + "-【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" + disUser_roomList.length +
  577. ")",
  578. type: "success"
  579. });
  580. await HNTOOL.Sleep(1000);
  581.  
  582.  
  583. }
  584. alert("根据房间号批量取关完成!");
  585. /* javaex.alert({
  586. content: ,
  587. confirm: function() {
  588.  
  589. return false;
  590. }
  591. }); */
  592.  
  593. });
  594.  
  595. });
  596.  
  597. $("#getNeetCookie").bind("click", async function() {
  598.  
  599. let html = '';
  600. html += '<div class="javaex-panel-box" style="width: 750px;">';
  601. html += ' <div class="javaex-unit clear">';
  602. html += ' <div class="javaex-unit-left ml-10 mt-10">*cookie</div>';
  603. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  604. html +=
  605. ' <textarea id="neetCookie" class="javaex-desc" placeholder="获取需要的cookie,注意需要取消掉application->cookie>SESSDATA httpOnly 的对钩"></textarea>';
  606. html += ' </div>';
  607. html += ' </div>';
  608. html += ' <div class="javaex-unit clear tc">';
  609. html += ' <input type="button" id="getCookie_type1" class="javaex-btn yes" value="方式一" />';
  610. html += ' <input type="button" id="getCookie_type2" class="javaex-btn yes" value="方式二" />';
  611. html += ' <input type="button" id="getCookie_type3" class="javaex-btn yes" value="方式三" />';
  612. html += ' <input type="button" id="getCookie_copy" class="javaex-btn yes" value="复制" />';
  613. html += ' </div>';
  614. html += '</div>';
  615.  
  616. javaex.panel(this, {
  617. position: "right",
  618. content: html
  619. });
  620.  
  621. $('#getCookie_copy').bind('click', function() {
  622.  
  623. HNTOOL.copyText("neetCookie");
  624.  
  625. });
  626.  
  627. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  628. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  629. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  630.  
  631.  
  632. $("#getCookie_type1").bind("click", async function() {
  633.  
  634. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA.replace(/%25/g, "%") +
  635. "; bili_jct=" + Live_info.csrf_token +
  636. "; "
  637. document.getElementById("neetCookie").value = cookie01;
  638.  
  639. });
  640. $("#getCookie_type3").bind("click", async function() {
  641.  
  642. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA.replace(/%25/g, "%%") +
  643. "; bili_jct=" + Live_info.csrf_token +
  644. "; "
  645. document.getElementById("neetCookie").value = cookie01;
  646.  
  647. });
  648.  
  649. $("#getCookie_type2").bind("click", async function() {
  650.  
  651. var cookie02 = Live_info.uid + "\n" + Live_info.SESSDATA.replace(/%25/g, "%") + "\n" + Live_info.csrf_token;
  652. document.getElementById("neetCookie").value = cookie02;
  653. });
  654.  
  655. });
  656.  
  657. $("#arrUnique").bind("click", async function() {
  658.  
  659. let html = '';
  660. html += '<div class="javaex-panel-box" style="width: 500px;">';
  661. html += ' <div class="javaex-unit clear">';
  662. html += ' <div id="arrNub" class="javaex-unit-left ml-10 mt-10">*数组0</div>';
  663. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  664. html += ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  665. html += ' </div>';
  666. html += ' </div>';
  667. html += ' <div class="javaex-unit clear tc">';
  668. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="去重" />';
  669. //html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="粘贴" />';
  670. html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="复制" />';
  671. html += ' </div>';
  672. html += '</div>';
  673.  
  674. javaex.panel(this, {
  675. position: "right",
  676. content: html
  677. });
  678.  
  679. $('#arrUnique_str').bind('input propertychange', function() {
  680.  
  681. $('#arrNub').text("*数组" + $(this).val().split(",").length);
  682.  
  683. });
  684. $('#arrUnique_copy').bind('click', function() {
  685.  
  686. HNTOOL.copyText("arrUnique_str");
  687.  
  688. });
  689.  
  690.  
  691.  
  692.  
  693. $("#arrUnique_beg").bind("click", async function() {
  694.  
  695. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  696. let arrUnique_uidList = arrUnique_str.split(",");
  697.  
  698. let new_arr = HNTOOL.arrUnique(arrUnique_uidList);
  699.  
  700. document.getElementById("arrUnique_str").value = new_arr.toString();
  701.  
  702. $('#arrNub').text("*数组" + new_arr.length);
  703.  
  704. });
  705.  
  706. });
  707.  
  708. $("#batchFollow").bind("click", async function() {
  709.  
  710. var thisUPName = $("#h-name").text();
  711.  
  712.  
  713. let html = '';
  714. html += '<div class="javaex-panel-box" style="width: 600px;">';
  715. html += ' <div class="javaex-unit clear">';
  716. html += ' <div id="followNub" class="javaex-unit-left ml-10 mt-10">*关注列表0</div>';
  717. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  718. html +=
  719. ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
  720. html += ' </div>';
  721. html += ' </div>';
  722. html += ' <div class="javaex-unit clear tc" >';
  723. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  724. html += ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="爬取全部关注" />';
  725. html += ` <input type="button" id="Follow_thisUp" class="javaex-btn yes tc" value="关注${thisUPName}" />`;
  726. html += ` <input type="button" id="disFollow_thisUp" class="javaex-btn yes tc" value="拉黑${thisUPName}" /> `;
  727. html += ' </div>';
  728. html += '</div>';
  729.  
  730. javaex.panel(this, {
  731. position: "right",
  732. content: html
  733. });
  734.  
  735. $('#batchFollow_uidList').bind('input propertychange', function() {
  736.  
  737. $('#followNub').text("*关注列表" + $(this).val().split(",").length);
  738.  
  739. });
  740.  
  741. $("#disFollow_thisUp").bind("click", async function() {
  742.  
  743. HNAPI.batchModify(BiliData.this_uid, 5);
  744.  
  745. });
  746.  
  747. $("#Follow_thisUp").bind("click", async function() {
  748.  
  749. HNAPI.batchModify(BiliData.this_uid);
  750.  
  751. });
  752.  
  753. $("#batchFollow_beg").bind("click", async function() {
  754.  
  755. let mid_str = javaex.getSelectVal("#batchFollow_uidList");
  756. mid_list = mid_str.split(",");
  757.  
  758. let mid_Lists = HNTOOL.split_array(mid_list, 15);
  759. for (const mids of mid_Lists) {
  760.  
  761. HNAPI.batchModify(mids.toString());
  762. await HNTOOL.Sleep(8000);
  763. }
  764.  
  765. alert("关注完成!")
  766.  
  767. });
  768.  
  769. $("#crawler_follow").bind("click", async function() {
  770.  
  771. //x/space/myinfo
  772. let myinfoData = await HNAPI.getMyinfo();
  773. await HNAPI.getUpCard(myinfoData.mid);
  774. await HNTOOL.Sleep(1000);
  775. let len = parseInt(BiliData.upCard.data.card.attention / 20);
  776. let followData = [];
  777.  
  778. for (let i = 0; i < len; i++) {
  779. if (BiliData.upCard.code != 0) {
  780. javaex.tip({
  781. content: `爬取关注出现异常 终止爬取!{BiliData.upCard.message}`,
  782. type: "error"
  783. });
  784. break;
  785. }
  786.  
  787. javaex.tip({
  788. content: `正在爬取` + myinfoData.mid + `的` + i + `页的关注!!!`,
  789. type: "success"
  790. });
  791.  
  792. let followList = await HNAPI.getMyFollow(myinfoData.mid, i);
  793. if (followList != null) {
  794. for (const fl of followList.list) {
  795.  
  796. /* if (fl.official_verify.type != 1 || fl.vip.vipType == 0) {
  797. continue;
  798. } */
  799.  
  800. followData.push(fl.mid);
  801.  
  802. }
  803. }
  804.  
  805.  
  806. await HNTOOL.Sleep(3000);
  807. }
  808.  
  809. document.getElementById("batchFollow_uidList").value = followData.toString();
  810.  
  811. });
  812.  
  813.  
  814. });
  815.  
  816. $("#batchTargetMedal").bind("click", async function() {
  817.  
  818.  
  819. let html = '';
  820. html += '<div class="javaex-panel-box" style="width: 600px;">';
  821. html += ' <div class="javaex-unit clear">';
  822. html += ' <div id="targetNub" class="javaex-unit-left ml-10 mt-10">*房间列表0</div>';
  823. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  824. html +=
  825. ' <textarea id="batchTargetMedal_roomlist" class="javaex-desc" placeholder="特别注意:请填写用户真实房间号,多个用英文逗号,隔开!!"></textarea>';
  826. html += ' </div>';
  827. html += ' </div>';
  828. html += ' <div class="javaex-unit clear tc" >';
  829. html += ' <input type="button" id="batchTargetMedal_beg" class="javaex-btn yes" value="开始" />';
  830. html += ' </div>';
  831. html += '</div>';
  832.  
  833. javaex.panel(this, {
  834. position: "right",
  835. content: html
  836. });
  837.  
  838. $('#batchTargetMedal_roomlist').bind('input propertychange', function() {
  839.  
  840. $('#targetNub').text("*房间列表" + $(this).val().split(",").length);
  841.  
  842. });
  843.  
  844. $("#batchTargetMedal_beg").bind("click", async function() {
  845.  
  846. let room_str = javaex.getSelectVal("#batchTargetMedal_roomlist");
  847. let room_list = room_str.split(",");
  848.  
  849.  
  850. for (const room of room_list) {
  851.  
  852. let uid = await HNAPI.getRoomMsg(room);
  853. await HNTOOL.Sleep(500);
  854.  
  855. if (uid == false) {
  856.  
  857. javaex.tip({
  858. content: room + "获取勋章失败!",
  859. type: "error"
  860. });
  861.  
  862. continue;
  863. }
  864.  
  865. let result = await HNAPI.getFansMedalInfo(uid, room);
  866.  
  867. if (result) {
  868. javaex.tip({
  869. content: room + "勋章已经存在!",
  870. type: "success"
  871. });
  872. continue;
  873. }
  874. //获取包裹列表
  875. let giftRes = await HNAPI.getGiftList(room);
  876.  
  877. if (giftRes == false) {
  878.  
  879. continue;
  880. }
  881.  
  882. let bag_id = null;
  883.  
  884. for (let gr of giftRes) {
  885.  
  886. if (gr.gift_id == 3) {
  887.  
  888. bag_id = gr.bag_id;
  889. break;
  890. }
  891.  
  892. }
  893. if (bag_id != null) {
  894.  
  895. await HNAPI.bagSendGift(uid, room, bag_id);
  896. }
  897.  
  898.  
  899.  
  900. await HNTOOL.Sleep(5000);
  901. }
  902.  
  903. alert("批量送b克拉完毕!")
  904.  
  905.  
  906. });
  907.  
  908.  
  909. });
  910.  
  911.  
  912. $("#HNSetup").bind("click", async function() {
  913.  
  914. var CONFIG = HNTOOL.getConfig();
  915.  
  916.  
  917. let html = '';
  918.  
  919. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  920. html += '<form id="HNGG_SETUP">'
  921. html += ' <div class="javaex-unit clear">'
  922. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Qmsg-key</p></div>'
  923. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  924. html += ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  925. html += ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  926. html += ' </div>'
  927. html += ' <div class="javaex-unit-left mr-10">'
  928. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  929. html += ' </div>'
  930. html += ' </div>'
  931. html += '</form>';
  932. html += '<div class="javaex-unit clear tc">';
  933. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  934. html += '</div>';
  935. html += '<hr class="javaex-divider"></hr>';
  936. html += '</div>';
  937.  
  938. javaex.panel(this, {
  939. position: "right",
  940. content: html
  941. });
  942.  
  943.  
  944. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  945.  
  946. $("#switch-qsmg").bind("click", function() {
  947.  
  948. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  949.  
  950. })
  951.  
  952.  
  953. $("#HNSetup_save").bind("click", async function() {
  954.  
  955.  
  956. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  957.  
  958. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  959.  
  960. javaex.tip({
  961. content: "设置成功!",
  962. type: "success"
  963. });
  964.  
  965. });
  966.  
  967. });
  968.  
  969. //
  970. $("#getUpMassage").bind("click", async function() {
  971.  
  972.  
  973. let html = '';
  974.  
  975. html += '<div style="padding: 10px 10px 10px 0px;">'
  976. html += '<form id="getUpMassage_form">'
  977. html += ' <div class="javaex-unit clear">'
  978. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  979. html += ' <div class="javaex-unit-left mr-10">'
  980. html +=
  981. ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  982. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  983. html += ' </div>'
  984. html += ' <div class="javaex-unit-right mr-10">'
  985. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  986. html += ' </div>'
  987. html += ' </div>'
  988. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  989. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  990. html += ' <thead>'
  991. html += ' <tr><th>内容</th><th>详情</th></tr>'
  992. html += ' </thead>'
  993. html += ' <tbody id="upMsgTbody">'
  994.  
  995. html += ' </tbody>'
  996. html += '</table> '
  997. html += '</div>'
  998. html += '</form>';
  999. html += '<hr class="javaex-divider"></hr>';
  1000. html += '</div>';
  1001.  
  1002.  
  1003. javaex.panel(this, {
  1004. position: "right",
  1005. content: html
  1006. });
  1007.  
  1008. javaex.table({
  1009. id: "upMsgTable",
  1010. isDragColWidth: true, // 是否允许拖动改变列宽
  1011. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  1012. leftFixedColNum: 2, // 左侧固定列数
  1013. rightFixedColNum: 1, // 右侧固定列数
  1014. sort: {
  1015. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  1016. "2": "update_time"
  1017. },
  1018. sortCallback: function(rtn) {
  1019. //console.log(rtn.sortArr);
  1020. }
  1021. });
  1022.  
  1023. //
  1024. $("#getUpMsg").click(async function() {
  1025.  
  1026. let thismid = javaex.getSelectVal("#up_uid");
  1027. await HNAPI.userInfo(thismid)
  1028.  
  1029. let temp = await HNAPI.getUpCard(thismid);
  1030.  
  1031.  
  1032. await HNTOOL.Sleep(500);
  1033.  
  1034.  
  1035. if (temp != false) {
  1036. let data = BiliData.upCard.data;
  1037.  
  1038. let html = ``;
  1039. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  1040. html += `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  1041. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  1042. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  1043. html +=
  1044. `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  1045. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  1046. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  1047. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  1048. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  1049. html +=
  1050. `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  1051. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  1052. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  1053.  
  1054.  
  1055. $("#upMsgTbody").empty();
  1056. $("#upMsgTbody").append(html);
  1057. }
  1058.  
  1059.  
  1060. });
  1061. //点击放大
  1062. /* $("img").click(function() {
  1063. javaex.dialog({
  1064. type : "image", // 弹出层类型
  1065. url : $(this).attr("src") // 图片地址
  1066. });
  1067. });*/
  1068.  
  1069. });
  1070.  
  1071.  
  1072. $("#everyDayTask").bind("click", async function() {
  1073.  
  1074. let videoAid = 758643487;
  1075. let videoCid = 357521682;
  1076. let videoBvid = "BV1V64y1d7ed";
  1077. let videoMid = 99439379;
  1078.  
  1079. await HNAPI.clickNow();
  1080. await HNTOOL.Sleep(3000);
  1081.  
  1082. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  1083. await HNAPI.DoSign();
  1084. await HNTOOL.Sleep(3000);
  1085.  
  1086.  
  1087. //2.每日观看视频 获取分区最新视频列表 http://api.bilibili.com/x/web-interface/dynamic/region pn=1 ps=20 rid=21
  1088. let archivesList = await HNAPI.getDynamicRegion();
  1089. await HNTOOL.Sleep(2000);
  1090. //2.每日观看视频 获取分区最新专栏列表
  1091. let articleData = await HNAPI.getArticleRecommends();
  1092. await HNTOOL.Sleep(2000);
  1093.  
  1094. let num = HNTOOL.random(0, archivesList.length - 1);
  1095. let article = articleData[HNTOOL.random(0, 18)];
  1096.  
  1097. if (archivesList != false && num != 2) {
  1098.  
  1099. videoAid = archivesList[num].aid;
  1100. videoBvid = archivesList[num].bvid;
  1101. videoCid = archivesList[num].cid;
  1102. videoMid = archivesList[num].owner.mid;
  1103. }
  1104.  
  1105. await HNAPI.playOneVideo(videoBvid, videoMid);
  1106. await HNTOOL.Sleep(2000);
  1107. //await HNAPI.addVideoCoin(videoAid);//视频投币
  1108.  
  1109. await HNAPI.addArticleCoin(article.id, article.author.mid); //专栏投币
  1110. await HNTOOL.Sleep(2000);
  1111.  
  1112.  
  1113. await HNAPI.addShare(videoAid);
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119. });
  1120.  
  1121.  
  1122. $("#dynamicActivity").bind("click", async function() {
  1123.  
  1124. javaex.tip({
  1125. content: "动态转发开始!",
  1126. type: "success"
  1127. });
  1128.  
  1129. let dynamic_id_list = await HNTOOL.getLatestDynamic();
  1130. //let save_dynamic_id = await HNAPI.getSpaceNotice();
  1131. await HNTOOL.Sleep(2000);
  1132.  
  1133. for (let index = 0, len = dynamic_id_list.length; index < len; index++) {
  1134.  
  1135. let value = dynamic_id_list[index];
  1136.  
  1137. let dynamic_data = await HNAPI.getdynamicData(value);
  1138.  
  1139. if (dynamic_data.hasOwnProperty('card') == false) {
  1140. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 失效!!!");
  1141. continue;
  1142. }
  1143. let dynamic_id = dynamic_data.card.desc.dynamic_id_str;
  1144. let dynamic_type = 17;
  1145. await HNTOOL.Sleep(2000);
  1146.  
  1147. if (dynamic_data.card.desc.is_liked == 1) {
  1148. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 已转发,舍弃!!!");
  1149. continue;
  1150. }
  1151. //判断是否过期
  1152. if (dynamic_data.card.desc.type == 2) {
  1153. dynamic_type = 11;
  1154. dynamic_id = dynamic_data.card.desc.rid;
  1155. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1156. await HNTOOL.Sleep(2000);
  1157.  
  1158. if (lNoticeData.lottery_time * 1000 <= (new Date()).getTime()) {
  1159.  
  1160.  
  1161. console.log(
  1162. "【" + index + "已过开奖时间】\n" +
  1163. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1164. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n"
  1165. );
  1166. continue;
  1167. }
  1168.  
  1169. }
  1170. //0.判断是否关注
  1171. /* if (dynamic_data.attentions.uids.indexOf(dynamic_data.card.desc.uid) == -1) {
  1172.  
  1173. HNAPI.batchModify(dynamic_data.card.desc.uid);
  1174. console.log("【" + index + "】" + dynamic_data.card.desc.uid + "无需关注!!!");
  1175. await HNTOOL.Sleep(1000);
  1176. } */
  1177. HNAPI.batchModify(dynamic_data.card.desc.uid);
  1178. console.log("【" + index + "】" + dynamic_data.card.desc.uid + "已关注!!!");
  1179. await HNTOOL.Sleep(1000);
  1180.  
  1181. //1.评论
  1182. await HNAPI.addReply(dynamic_id, dynamic_type);
  1183. await HNTOOL.Sleep(1000);
  1184. //3.点赞
  1185. await HNAPI.likeDynamic(value);
  1186. await HNTOOL.Sleep(1000);
  1187. //2.转发
  1188. let repostCard = HNTOOL.strToJson(dynamic_data.card.card);
  1189. let repostStr = HNTOOL.getRandomWordOfList(replyList);
  1190. if (repostCard["user"]["uname"] != undefined && dynamic_data.card.desc.type == 1) {
  1191. repostStr = HNTOOL.getRandomWordOfList(replyList) + "//@" + repostCard.user.uname + ":" + repostCard.item.content;
  1192. }
  1193. await HNAPI.repostDynamic(value, repostStr);
  1194. await HNTOOL.Sleep(1000);
  1195. console.log("【" + index + "】动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!");
  1196.  
  1197. javaex.tip({
  1198. content: "动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!",
  1199. type: "success"
  1200. });
  1201.  
  1202. //存储标记
  1203. //await HNAPI.setNotice(value);
  1204.  
  1205. //随机延迟120 -240秒
  1206. let sleeptime = HNTOOL.random(12, 24) * 10 * 1000;
  1207. console.log("转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!")
  1208. javaex.tip({
  1209. content: "转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!",
  1210. type: "success"
  1211. });
  1212. await HNTOOL.Sleep(sleeptime);
  1213. }
  1214.  
  1215. alert("今日动态抽奖完成!!!");
  1216.  
  1217. });
  1218.  
  1219. $("#batchFollowOfbastard").bind("click", async function() {
  1220.  
  1221. if (confirm("作者个人需求开发,谨慎使用!!!\n 本功能会取关设定值以下没有认证(官方&&个人)的关注! \n 不确定使用请取消!")) {
  1222.  
  1223. let fansNum = prompt("请输入最低粉丝数量", "50000");
  1224.  
  1225. if (fansNum != null && fansNum != "") {
  1226. //fansNum
  1227.  
  1228. let followList = await HNAPI.getAllFollow();
  1229. console.log(followList);
  1230. await HNTOOL.Sleep(2000);
  1231.  
  1232. for (let fl of followList) {
  1233.  
  1234. if (fl == 99439379) {
  1235. continue;
  1236. }
  1237. let user = await HNAPI.getCardByUID(fl);
  1238. await HNTOOL.Sleep(1000);
  1239. if (user.fans < parseInt(fansNum) && user.official_verify.type == -1) {
  1240.  
  1241. await HNAPI.cancelAtt(fl, 2);
  1242.  
  1243. javaex.tip({
  1244. content: "uid:" + user.mid + "-" + user.name + "---符合条件 取关成功!!!",
  1245. type: "success"
  1246. });
  1247. console.log("uid:" + user.mid + "-" + user.name + "--符合条件 取关成功!!!");
  1248.  
  1249. } else {
  1250. javaex.tip({
  1251. content: "uid:" + user.mid + "-" + user.name + "---不符合条件 取消!!!",
  1252. type: "success"
  1253. });
  1254. console.log("uid:" + user.mid + "-" + user.name + "---不符合条件 取消!!!");
  1255. }
  1256. }
  1257. }
  1258.  
  1259. }
  1260.  
  1261. });
  1262.  
  1263.  
  1264. $("#reserveActivity").bind("click", async function() {
  1265.  
  1266.  
  1267. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSid.json";
  1268. let myjson = await HNAPI.getMyJson(url);
  1269.  
  1270. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1271. if (typeof(lastSid) == "undefined") {
  1272. lastSid = HN_SETUP_CONFIG.Booking_last_sid;
  1273. }
  1274. lastSid = lastSid.split("&")[1];
  1275.  
  1276.  
  1277.  
  1278. for (const sid in myjson) {
  1279.  
  1280. if (lastSid >= sid) {
  1281.  
  1282. continue;
  1283. }
  1284.  
  1285. let siddata = myjson[sid];
  1286. //let sidList = await HNAPI.getDataByLiveSid(sid);
  1287. //await HNTOOL.Sleep(2000);
  1288.  
  1289. //let returnData = await HNAPI.reserveActivity(sid, sidList[sid].total);
  1290. await HNAPI.reserveActivity(sid);
  1291. await HNTOOL.Sleep(2000);
  1292.  
  1293. let tiplog = "\n --预约开始:" + javaex.dateFormat(siddata.livePlanStartTime, 'yyyy-MM-dd HH:mm:ss') +
  1294. //"\n --预约SID:" + siddata.sid +
  1295. //"\n --预约UID:" + siddata.upmid +
  1296. //"\n --预约地址:" + siddata.prizeInfo.jumpUrl +
  1297. "\n --预约人数:" + siddata.total + "人" +
  1298. "\n --预约奖品:" + siddata.prizeInfo.text;
  1299.  
  1300. console.log(tiplog);
  1301.  
  1302. javaex.tip({
  1303. content: tiplog,
  1304. type: "success"
  1305. });
  1306.  
  1307. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + sid;
  1308.  
  1309. HNTOOL.saveConfig();
  1310.  
  1311. }
  1312.  
  1313.  
  1314. alert("预约抽奖结束");
  1315. });
  1316.  
  1317. $("#plateActivity").bind("click", async function() {
  1318.  
  1319. //获取轮盘数据
  1320.  
  1321. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1322. let myjson = await HNAPI.getMyJson(url);
  1323. let lmt = 0;
  1324. let k = 20; //重试次数 防止卡主
  1325. let giftArr = [];
  1326. let endAtion = [];
  1327.  
  1328. javaex.tip({
  1329. content: "开始参加轮盘!!!",
  1330. type: "success"
  1331. });
  1332.  
  1333. await HNAPI.getUserNav();
  1334. await HNTOOL.Sleep(1500);
  1335.  
  1336.  
  1337. for (const json of myjson) {
  1338. //let x = json.name;
  1339. for (let i = 0; i < 20; i++) {
  1340. //结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1341. let resout = await HNAPI.addLotteryTimes(json.sid);
  1342.  
  1343. await HNTOOL.Sleep(200);
  1344. if (resout == 1) {
  1345.  
  1346. endAtion.push(json.name + ":活动已结束!");
  1347. javaex.tip({
  1348. content: json.name + "活动已结束!",
  1349. type: "success"
  1350. });
  1351.  
  1352. break;
  1353. }
  1354. if (resout != 0 && resout != 1) {
  1355.  
  1356. javaex.tip({
  1357. content: json.name + resout,
  1358. type: "error"
  1359. });
  1360.  
  1361. break;
  1362. }
  1363.  
  1364. if (resout == 0) {
  1365.  
  1366. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1367. continue;
  1368. }
  1369.  
  1370. }
  1371.  
  1372. javaex.tip({
  1373. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1374. type: "success"
  1375. });
  1376.  
  1377. await HNTOOL.Sleep(1500);
  1378.  
  1379. for (let i = 0; i < lmt; i++) {
  1380.  
  1381. let gift = await HNAPI.lotteryDo(json.sid);
  1382.  
  1383.  
  1384. if (gift == true) {
  1385.  
  1386. javaex.tip({
  1387. content: "点击过快,9秒后自动重试!!!",
  1388. type: "error"
  1389. });
  1390.  
  1391. i--;
  1392. k--;
  1393. }
  1394.  
  1395. if (gift == false || k == 0) {
  1396. break;
  1397. }
  1398.  
  1399. if (gift != "未中奖0" && gift != true) {
  1400. giftArr.push(json.name + "奖品为:" + gift);
  1401. break;
  1402. } else {
  1403. javaex.tip({
  1404. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  1405. type: "success"
  1406. });
  1407. }
  1408. await HNTOOL.Sleep(9000);
  1409.  
  1410. }
  1411.  
  1412.  
  1413. }
  1414.  
  1415.  
  1416. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1417. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1418.  
  1419. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1420. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1421.  
  1422.  
  1423. });
  1424.  
  1425. $("#addPlay").bind("click", async function() {
  1426.  
  1427.  
  1428. let html = '';
  1429.  
  1430. html += '<div style="padding: 10px 10px 10px 0px;">'
  1431. html += '<form id="getUpMassage_form">'
  1432.  
  1433. html += ' <div class="javaex-unit clear">'
  1434. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  1435. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  1436. html +=
  1437. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  1438. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  1439. html += ' </div>'
  1440. html += ' </div>'
  1441. html += ' <div class="javaex-unit clear">'
  1442. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  1443. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  1444. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  1445. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  1446. html += ' </div>'
  1447. html += ' </div>'
  1448. html += '</form>';
  1449. html += ' <div class="javaex-unit clear tc">'
  1450. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  1451. html += ' </div>'
  1452. html += '<hr class="javaex-divider"></hr>';
  1453. html += '</div>';
  1454.  
  1455.  
  1456. javaex.panel(this, {
  1457. position: "right",
  1458. content: html
  1459. });
  1460.  
  1461. $("#addPlay_bgn").click(async function() {
  1462.  
  1463. let MID = javaex.getSelectVal("#addPlay_uid")
  1464. let BV = javaex.getSelectVal("#addPlay_bv");
  1465. let bvArr = [];
  1466. let bvArr2 = [];
  1467.  
  1468. MID = javaex.ifnull(MID, BiliData.author_uid);
  1469.  
  1470.  
  1471. if (BV == "0") {
  1472.  
  1473. //1.查询up所有视频BV号 2.发送心跳间隔2s
  1474. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  1475. await HNTOOL.Sleep(500);
  1476. bvArr2 = BiliData.BVList;
  1477.  
  1478. for (let i = 1; i > 0; i++) {
  1479.  
  1480. HNAPI.getUpAllBV(MID, i);
  1481.  
  1482. await HNTOOL.Sleep(500);
  1483.  
  1484. if (BiliData.BVList.length == 0) {
  1485. if (bvArr.length == 0) {
  1486. javaex.tip({
  1487. content: "该用户无投稿视频,请确认是否有误!",
  1488. type: "success"
  1489. });
  1490. await HNTOOL.Sleep(2000);
  1491. }
  1492. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  1493. bvArr = bvArr.concat(bvArr2);
  1494. break;
  1495. }
  1496.  
  1497. bvArr = bvArr.concat(BiliData.BVList);
  1498. }
  1499.  
  1500.  
  1501. if (bvArr.length != 0) {
  1502.  
  1503. for (const emt of bvArr) {
  1504.  
  1505. HNAPI.playOneVideo(emt.bvid, MID);
  1506.  
  1507. await HNTOOL.Sleep(2000);
  1508.  
  1509. }
  1510.  
  1511. alert("播放完成!!!");
  1512.  
  1513. }
  1514.  
  1515.  
  1516. } else {
  1517. //1.调用点击播放接口
  1518. //2.发送心跳
  1519.  
  1520. await HNTOOL.Sleep(500);
  1521.  
  1522. HNAPI.playOneVideo(BV);
  1523. }
  1524.  
  1525.  
  1526. });
  1527.  
  1528.  
  1529. });
  1530.  
  1531. }
  1532.  
  1533.  
  1534. let addSetPage = async function() {
  1535.  
  1536. HNTOOL.Sleep(1000);
  1537.  
  1538. $('body').append('' +
  1539. '<div id="left_navbar">' +
  1540. '<div class="javaex-menu-container"> ' +
  1541. ' <div id="menu" class="javaex-menu"> ' +
  1542. ' <ul> ' +
  1543. ' <li class="javaex-menu-item alone hover" > ' +
  1544. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  1545. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  1546. ' </li> ' +
  1547. ' </ul> ' +
  1548. ' <ul> ' +
  1549. ' <li class="javaex-menu-item"> ' +
  1550. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  1551. ' <ul> ' +
  1552. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  1553. ' </ul> ' +
  1554. ' </li> ' +
  1555. ' <li id="chackList" class="javaex-menu-item"> ' +
  1556. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  1557. ' <ul> ' +
  1558. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  1559. //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  1560. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  1561. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  1562. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  1563. ' </ul> ' +
  1564. ' </li> ' +
  1565. ' <li class="javaex-menu-item"> ' +
  1566. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  1567. ' <ul> ' +
  1568. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  1569. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  1570. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  1571. ' <li id="batchFollowOfbastard" class="javaex-hover-pulse"><a href="javaScript:;" >批量取关-慎用</a></li> ' +
  1572. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  1573. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  1574. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  1575. ' </ul> ' +
  1576. ' </li> ' +
  1577. ' <li class="javaex-menu-item"> ' +
  1578. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  1579. ' <ul> ' +
  1580. ' <li id="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
  1581. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  1582. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  1583. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  1584. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  1585. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  1586. ' <li id="dynamicActivity" class="javaex-hover-pulse"><a href="javaScript:;" >动态抽奖</a></li> ' +
  1587. //' <li id="likeInDynamicComments" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  1588. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  1589. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  1590. ' </ul> ' +
  1591. ' </li> ' +
  1592. ' <li class="javaex-menu-item"> ' +
  1593. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  1594. ' <ul> ' +
  1595. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  1596. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  1597. ' </ul> ' +
  1598. ' </li> ' +
  1599.  
  1600. ' </ul> ' +
  1601. ' </div> ' +
  1602. '</div>' +
  1603. '</div>');
  1604. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  1605.  
  1606. javaex.menu({
  1607. id: "menu",
  1608. isShowAll: false
  1609. });
  1610.  
  1611. }
  1612.  
  1613.  
  1614.  
  1615.  
  1616. let showUnreadMsg = function() {
  1617.  
  1618. var html = '';
  1619. html += '<div class="javaex-panel-box" style="width: 250px;">';
  1620. html += ' <ul>';
  1621. html += ` <p style="color: #FFF;">用户消息</p>`;
  1622. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  1623. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  1624. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  1625. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  1626. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  1627. html += ' <hr class="javaex-divider"></hr>';
  1628. html += ' </ul>';
  1629. html += '</div>';
  1630.  
  1631.  
  1632. javaex.panel(document.getElementById("getUnread"), {
  1633. position: "right",
  1634. content: html
  1635. });
  1636.  
  1637. javaex.tip({
  1638. content: "查询用户通知成功!",
  1639. type: "success"
  1640. });
  1641.  
  1642. }
  1643.  
  1644. /**
  1645. * 检查 艾特信息
  1646. * @returns {Promise<void>}
  1647. */
  1648. let chackAtMsg = async function(items) {
  1649.  
  1650. await HNTOOL.Sleep(500);
  1651.  
  1652. if (items != false && typeof(items) != "undefined") {
  1653.  
  1654.  
  1655. var html = '';
  1656. html += '<div class="javaex-panel-box" style="width: auto;">';
  1657. html += ' <ul>';
  1658. html += ` <p style="color: #FFF;">@信息</p>`;
  1659. items.forEach(function(item) {
  1660.  
  1661. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  1662. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  1663. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  1664.  
  1665. html +=
  1666. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  1667. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  1668. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  1669. html += ' <hr class="javaex-divider"></hr>';
  1670. });
  1671. html += ' </ul>';
  1672. html += '</div>';
  1673.  
  1674.  
  1675. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  1676. javaex.panel(document.getElementById("getAtMsg"), {
  1677. position: "right",
  1678. content: html
  1679. });
  1680. } else {
  1681. javaex.panel(document.getElementById("chackList"), {
  1682. position: "right",
  1683. content: html
  1684. });
  1685. }
  1686.  
  1687.  
  1688. }
  1689.  
  1690. }
  1691.  
  1692.  
  1693. let addStyle = function() {
  1694. const animate = GM_getResourceText('animate');
  1695. const common = GM_getResourceText('common');
  1696. const defaultCss = GM_getResourceText('defaultCss');
  1697. //const icomoonex = GM_getResourceText('icomoonex');
  1698. //const AllCss = animate + common + defaultCss + icomoonex;
  1699. const AllCss = animate + common + defaultCss;
  1700. const style = document.createElement('style');
  1701. style.innerHTML = AllCss;
  1702. return document.getElementsByTagName('head')[0].appendChild(style);
  1703. }
  1704.  
  1705. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  1706.  
  1707.  
  1708. /*-----------------------------------------------常用API--------------------------------------------------*/
  1709.  
  1710. let HNAPI = {
  1711.  
  1712.  
  1713. getLotteryNotice: async function(dynamic_id) {
  1714. return new Promise((resolve) => {
  1715. Ajax.get({
  1716. url: BILIBLI_PATH.vcapi + '/lottery_svr/v1/lottery_svr/lottery_notice',
  1717. queryStringsObj: {
  1718. "dynamic_id": dynamic_id
  1719. },
  1720. hasCookies: true,
  1721. success: responseText => {
  1722. let res = HNTOOL.strToJson(responseText);
  1723. if (res.code === 0) {
  1724.  
  1725. resolve(res.data);
  1726.  
  1727. } else {
  1728. console.log("获取开奖信息失败:" + res.message);
  1729. resolve(false);
  1730. }
  1731. }
  1732. })
  1733. });
  1734. },
  1735.  
  1736.  
  1737. likeDynamic: async function(dynamic_id) {
  1738.  
  1739. return new Promise((resolve) => {
  1740. Ajax.post({
  1741. url: BILIBLI_PATH.vcapi + '/dynamic_like/v1/dynamic_like/thumb',
  1742. hasCookies: true,
  1743. dataType: 'application/x-www-form-urlencoded',
  1744. data: {
  1745. uid: Live_info.uid,
  1746. dynamic_id: dynamic_id,
  1747. up: 1,
  1748. csrf: Live_info.csrf_token
  1749. },
  1750. success: responseText => {
  1751. let res = HNTOOL.strToJson(responseText);
  1752. if (res.code === 0) {
  1753.  
  1754. javaex.tip({
  1755. content: "动态点赞成功!",
  1756. type: "success"
  1757. });
  1758.  
  1759. resolve(true);
  1760. } else {
  1761.  
  1762. console.log("动态点赞发生错误!" + res.message);
  1763.  
  1764. javaex.tip({
  1765. content: "动态点赞发生错误!" + res.message,
  1766. type: "error"
  1767. });
  1768.  
  1769. resolve(false);
  1770. }
  1771. }
  1772. })
  1773. });
  1774. },
  1775.  
  1776. repostDynamic: async function(dynamic_id, content) {
  1777.  
  1778. return new Promise((resolve) => {
  1779. Ajax.post({
  1780. url: BILIBLI_PATH.vcapi + '/dynamic_repost/v1/dynamic_repost/repost',
  1781. dataType: 'application/x-www-form-urlencoded',
  1782. hasCookies: true,
  1783. data: {
  1784. uid: Live_info.uid,
  1785. dynamic_id: dynamic_id,
  1786. content: content,
  1787. csrf: Live_info.csrf_token
  1788. },
  1789. success: responseText => {
  1790. let res = HNTOOL.strToJson(responseText);
  1791. if (res.code === 0) {
  1792.  
  1793. javaex.tip({
  1794. content: "动态转发成功!",
  1795. type: "success"
  1796. });
  1797.  
  1798. resolve(true);
  1799. } else {
  1800.  
  1801. console.log("动态转发发生错误!" + res.message);
  1802.  
  1803. javaex.tip({
  1804. content: "动态转发发生错误!" + res.message,
  1805. type: "error"
  1806. });
  1807.  
  1808. resolve(false);
  1809. }
  1810. }
  1811. })
  1812. });
  1813. },
  1814.  
  1815. addReply: async function(oid, type) {
  1816.  
  1817. return new Promise((resolve) => {
  1818. Ajax.post({
  1819. url: BILIBLI_PATH.api + '/x/v2/reply/add',
  1820. dataType: 'application/x-www-form-urlencoded',
  1821. hasCookies: true,
  1822. data: {
  1823. "oid": oid,
  1824. "type": type, //11官方 17 加码
  1825. "ordering": 'heat',
  1826. "message": HNTOOL.getRandomWordOfList(replyList),
  1827. "jsonp": 'jsonp',
  1828. "csrf": Live_info.csrf_token
  1829. },
  1830. success: responseText => {
  1831. let res = HNTOOL.strToJson(responseText);
  1832. if (res.code === 0) {
  1833. console.log('自动评论成功');
  1834. resolve(0);
  1835. } else if (res.code === -404) {
  1836. console.log('自动评论原动态已删除');
  1837. resolve(0);
  1838. } else if (res.code === 12002) {
  1839. console.log('自动评论评论区已关闭');
  1840. resolve(0);
  1841. } else if (res.code === 12015) {
  1842. console.log('自动评论需要输入验证码');
  1843. resolve(1);
  1844. } else {
  1845. console.log('自动评论', `评论失败\n${responseText}`);
  1846. resolve(0);
  1847. }
  1848. }
  1849. })
  1850. });
  1851. },
  1852.  
  1853.  
  1854. setNotice: async function(notice) {
  1855.  
  1856. return new Promise((resolve) => {
  1857. Ajax.post({
  1858. url: BILIBLI_PATH.api + '/x/space/notice/set',
  1859. hasCookies: true,
  1860. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1861. data: {
  1862. notice: notice,
  1863. jsonp: 'jsonp',
  1864. csrf: Live_info.csrf_token
  1865. },
  1866. success: responseText => {
  1867. let res = HNTOOL.strToJson(responseText);
  1868. if (res.code === 0) {
  1869.  
  1870. javaex.tip({
  1871. content: "动态标记保存到个人公告成功!",
  1872. type: "success"
  1873. });
  1874.  
  1875. resolve(true);
  1876. } else {
  1877.  
  1878. javaex.tip({
  1879. content: res.message,
  1880. type: "error"
  1881. });
  1882.  
  1883. resolve(false);
  1884. }
  1885. }
  1886. })
  1887. });
  1888. },
  1889.  
  1890. getSpaceNotice: async function() {
  1891. return new Promise((resolve) => {
  1892. Ajax.get({
  1893. url: BILIBLI_PATH.api + '/x/space/notice',
  1894. queryStringsObj: {
  1895. "mid": Live_info.uid
  1896. },
  1897. hasCookies: true,
  1898. success: responseText => {
  1899. let res = HNTOOL.strToJson(responseText);
  1900. if (res.code === 0) {
  1901.  
  1902. resolve(res.data);
  1903.  
  1904. } else {
  1905. console.log("获取公告信息失败:" + res.message);
  1906. resolve(false);
  1907. }
  1908. }
  1909. })
  1910. });
  1911. },
  1912.  
  1913. getdynamicData: async function(dynamic_id_str) {
  1914. return new Promise((resolve) => {
  1915. Ajax.get({
  1916.  
  1917. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
  1918. queryStringsObj: {
  1919. "dynamic_id": dynamic_id_str
  1920. },
  1921. hasCookies: true,
  1922. success: responseText => {
  1923. let res = HNTOOL.strToJson(responseText);
  1924. if (res.code === 0) {
  1925.  
  1926. resolve(res.data);
  1927.  
  1928. } else {
  1929. console.log("获取动态信息失败:" + res.message);
  1930. resolve(false);
  1931. }
  1932. }
  1933. })
  1934. });
  1935. },
  1936.  
  1937. getAllFollow: async function() {
  1938. return new Promise((resolve) => {
  1939. Ajax.get({
  1940.  
  1941. url: BILIBLI_PATH.vcapi + '/feed/v1/feed/get_attention_list',
  1942. queryStringsObj: {
  1943. "uid": Live_info.uid
  1944. },
  1945. hasCookies: true,
  1946. success: responseText => {
  1947. let res = HNTOOL.strToJson(responseText);
  1948. if (res.code === 0) {
  1949.  
  1950. resolve(res.data.list);
  1951.  
  1952. } else {
  1953. console.log("查询失败!" + res.message);
  1954. resolve(false);
  1955. }
  1956. }
  1957. })
  1958. });
  1959. },
  1960.  
  1961. getCardByUID: async function(UID) {
  1962. return new Promise((resolve) => {
  1963. Ajax.get({
  1964.  
  1965. url: BILIBLI_PATH.api + '/x/web-interface/card',
  1966. queryStringsObj: {
  1967. "mid": UID
  1968. },
  1969. hasCookies: true,
  1970. success: responseText => {
  1971. let res = HNTOOL.strToJson(responseText);
  1972. if (res.code === 0) {
  1973.  
  1974. resolve(res.data.card);
  1975.  
  1976. } else {
  1977. console.log("查询失败!" + res.message);
  1978. resolve(false);
  1979. }
  1980. }
  1981. })
  1982. });
  1983. },
  1984.  
  1985.  
  1986. /**
  1987. *
  1988. *
  1989. */
  1990.  
  1991. getTodayDynamicList: async function(mid, indexStr) {
  1992. return new Promise((resolve) => {
  1993. Ajax.get({
  1994.  
  1995. url: BILIBLI_PATH.api + '/x/space/article',
  1996. queryStringsObj: {
  1997. "mid": 226257459,
  1998. "pn": 1,
  1999. "ps": 12,
  2000. "sort": 'publish_time'
  2001. },
  2002. hasCookies: true,
  2003. success: responseText => {
  2004. let res = HNTOOL.strToJson(responseText);
  2005. if (res.code === 0) {
  2006. let artlist = [];
  2007.  
  2008. for (let art of res.data.articles) {
  2009.  
  2010. //if (art.title.indexOf("抽奖合集") > -1) {
  2011. if (art.title.indexOf(indexStr) > -1) {
  2012.  
  2013. resolve(art);
  2014. break;
  2015. }
  2016. }
  2017. } else {
  2018.  
  2019.  
  2020. console.log("查询失败!" + res.message);
  2021. resolve(false);
  2022. }
  2023. }
  2024. })
  2025. });
  2026. },
  2027.  
  2028. getDataByLiveSid: async function(ids) {
  2029. return new Promise((resolve) => {
  2030. Ajax.get({
  2031.  
  2032. url: BILIBLI_PATH.api + '/x/activity/up/reserve/relation/info',
  2033. queryStringsObj: {
  2034. "ids": ids
  2035. },
  2036. hasCookies: true,
  2037. success: responseText => {
  2038. let res = HNTOOL.strToJson(responseText);
  2039. if (res.code === 0 && Object.keys(res.data.list).length != 0) {
  2040.  
  2041. resolve(res.data.list);
  2042. } else {
  2043.  
  2044. /* javaex.tip({
  2045. content: "查询失败!" + res.message,
  2046. type: "error"
  2047. }); */
  2048. console.log("查询失败!" + res.message);
  2049.  
  2050. resolve(false);
  2051. }
  2052. }
  2053. })
  2054. });
  2055. },
  2056.  
  2057. /**
  2058. * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
  2059. */
  2060. clickNow: async function() {
  2061. return new Promise((resolve) => {
  2062. Ajax.get({
  2063.  
  2064. url: BILIBLI_PATH.api + '/x/report/click/now',
  2065. queryStringsObj: {
  2066. jsonp: "jsonp"
  2067. },
  2068. hasCookies: true,
  2069. success: responseText => {
  2070. let res = HNTOOL.strToJson(responseText);
  2071. if (res.code === 0) {
  2072.  
  2073. javaex.tip({
  2074. content: "每日登录" + res.data.text,
  2075. type: "success"
  2076. });
  2077. resolve(true);
  2078.  
  2079. } else {
  2080.  
  2081. javaex.tip({
  2082. content: res.message,
  2083. type: "error"
  2084. });
  2085.  
  2086. resolve(false);
  2087. }
  2088. }
  2089. })
  2090. });
  2091. },
  2092.  
  2093. /**
  2094. * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
  2095. * @param {number} videoAid
  2096. */
  2097. addShare: async function(videoAid) {
  2098. return new Promise((resolve) => {
  2099. Ajax.post({
  2100. url: BILIBLI_PATH.api + '/x/web-interface/share/add',
  2101. hasCookies: true,
  2102. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2103. data: {
  2104. aid: videoAid,
  2105. csrf: Live_info.csrf_token
  2106. },
  2107. success: responseText => {
  2108. let res = HNTOOL.strToJson(responseText);
  2109. if (res.code === 0) {
  2110.  
  2111. javaex.tip({
  2112. content: "每日分享视频成功",
  2113. type: "success"
  2114. });
  2115.  
  2116. resolve(true);
  2117. } else {
  2118.  
  2119. javaex.tip({
  2120. content: res.message,
  2121. type: "error"
  2122. });
  2123.  
  2124. resolve(false);
  2125. }
  2126. }
  2127. })
  2128. });
  2129. },
  2130.  
  2131.  
  2132.  
  2133. /**
  2134. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  2135. * @param {number} videoAid
  2136. */
  2137. addArticleCoin: async function(cvID, mid) {
  2138. return new Promise((resolve) => {
  2139. Ajax.post({
  2140. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  2141. hasCookies: true,
  2142. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2143. data: {
  2144. aid: cvID,
  2145. upid: mid,
  2146. multiply: 2,
  2147. avtype: 2,
  2148. csrf: Live_info.csrf_token
  2149. },
  2150. success: responseText => {
  2151. let res = HNTOOL.strToJson(responseText);
  2152. if (res.code === 0) {
  2153.  
  2154. javaex.tip({
  2155. content: '专栏:' + cvID + "投币成功",
  2156. type: "success"
  2157. });
  2158.  
  2159. resolve(true);
  2160. } else {
  2161.  
  2162. javaex.tip({
  2163. content: res.message,
  2164. type: "error"
  2165. });
  2166.  
  2167. console.log('专栏投币失败:' + cvID + res.message);
  2168.  
  2169. resolve(false);
  2170. }
  2171. }
  2172. })
  2173. });
  2174. },
  2175.  
  2176. /**
  2177. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  2178. * @param {number} videoAid
  2179. */
  2180. addVideoCoin: async function(videoAid) {
  2181. return new Promise((resolve) => {
  2182. Ajax.post({
  2183. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  2184. hasCookies: true,
  2185. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2186. data: {
  2187. aid: videoAid,
  2188. multiply: 2,
  2189. select_like: 0,
  2190. cross_domain: true,
  2191. csrf: Live_info.csrf_token
  2192. },
  2193. success: responseText => {
  2194. let res = HNTOOL.strToJson(responseText);
  2195. if (res.code === 0) {
  2196.  
  2197. javaex.tip({
  2198. content: "投币成功",
  2199. type: "success"
  2200. });
  2201.  
  2202. resolve(true);
  2203. } else {
  2204.  
  2205. javaex.tip({
  2206. content: res.message,
  2207. type: "error"
  2208. });
  2209.  
  2210. resolve(false);
  2211. }
  2212. }
  2213. })
  2214. });
  2215. },
  2216.  
  2217.  
  2218. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  2219.  
  2220. DoSign: async function() {
  2221. return new Promise((resolve) => {
  2222. Ajax.get({
  2223.  
  2224. url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
  2225. queryStringsObj: {
  2226.  
  2227. },
  2228. hasCookies: true,
  2229. success: responseText => {
  2230. let res = HNTOOL.strToJson(responseText);
  2231. if (res.code === 0) {
  2232.  
  2233. javaex.tip({
  2234. content: "签到成功:" + res.data.text,
  2235. type: "success"
  2236. });
  2237. resolve(true);
  2238.  
  2239. } else if (res.code === 1011040) {
  2240.  
  2241. javaex.tip({
  2242. content: res.message,
  2243. type: "success"
  2244. });
  2245.  
  2246. resolve(true);
  2247. } else {
  2248.  
  2249. javaex.tip({
  2250. content: res.message,
  2251. type: "error"
  2252. });
  2253.  
  2254. resolve(false);
  2255. }
  2256. }
  2257. })
  2258. });
  2259. },
  2260.  
  2261.  
  2262. /**
  2263. * // 获取分区最新专栏列表 https://api.bilibili.com/x/article/recommends?cid=0&pn=1
  2264. */
  2265. getArticleRecommends: async function() {
  2266. return new Promise((resolve) => {
  2267. Ajax.get({
  2268.  
  2269. url: BILIBLI_PATH.api + '/x/article/recommends',
  2270. queryStringsObj: {
  2271. "cid": 0,
  2272. "pn": 1
  2273. },
  2274. hasCookies: true,
  2275. success: responseText => {
  2276. let res = HNTOOL.strToJson(responseText);
  2277. if (res.code === 0) {
  2278.  
  2279. javaex.tip({
  2280. content: "获取最新专栏成功!",
  2281. type: "success"
  2282. });
  2283. resolve(res.data);
  2284.  
  2285. } else {
  2286.  
  2287. javaex.tip({
  2288. content: "获取最新专栏失败!" + res.message,
  2289. type: "error"
  2290. });
  2291.  
  2292. console.log(res.message);
  2293.  
  2294. resolve(false);
  2295. }
  2296. }
  2297. })
  2298. });
  2299. },
  2300. /**
  2301. * // 获取分区最新视频列表
  2302. */
  2303. getDynamicRegion: async function() {
  2304. return new Promise((resolve) => {
  2305. Ajax.get({
  2306.  
  2307. url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
  2308. queryStringsObj: {
  2309. "pn": 1,
  2310. "ps": 20,
  2311. "rid": 21
  2312. },
  2313. hasCookies: true,
  2314. success: responseText => {
  2315. let res = HNTOOL.strToJson(responseText);
  2316. if (res.code === 0) {
  2317.  
  2318. javaex.tip({
  2319. content: "获取分区最新视频成功",
  2320. type: "success"
  2321. });
  2322. resolve(res.data.archives);
  2323.  
  2324. } else {
  2325.  
  2326. javaex.tip({
  2327. content: "获取分区最新视频失败" + res.message,
  2328. type: "error"
  2329. });
  2330.  
  2331. resolve(false);
  2332. }
  2333. }
  2334. })
  2335. });
  2336. },
  2337.  
  2338. /*
  2339. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  2340. * @param {Object} sid
  2341. */
  2342. reserveActivity: async function(sid) {
  2343. return new Promise((resolve) => {
  2344. Ajax.post({
  2345. url: BILIBLI_PATH.api + '/x/space/reserve',
  2346. hasCookies: true,
  2347. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2348. data: {
  2349. sid: sid, //当前用户
  2350. jsonp: "jsonp",
  2351. csrf: Live_info.csrf_token
  2352. },
  2353. success: responseText => {
  2354. let res = HNTOOL.strToJson(responseText);
  2355. if (res.code === 0) {
  2356.  
  2357. resolve(true);
  2358. } else {
  2359. javaex.tip({
  2360. content: res.message,
  2361. type: "error"
  2362. });
  2363. resolve(false);
  2364. }
  2365. }
  2366. })
  2367. });
  2368. },
  2369. /**
  2370. reserveActivity: async function(sid, reserve_total) {
  2371. return new Promise((resolve) => {
  2372. Ajax.post({
  2373. url: BILIBLI_PATH.vcapi + '/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
  2374. hasCookies: true,
  2375. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2376. data: {
  2377. reserve_id: sid,
  2378. cur_btn_status: 1,
  2379. reserve_total: reserve_total,
  2380. csrf: Live_info.csrf_token
  2381. },
  2382. success: responseText => {
  2383. let res = HNTOOL.strToJson(responseText);
  2384. if (res.code === 0) {
  2385.  
  2386. resolve(res.data);
  2387. } else {
  2388.  
  2389. javaex.tip({
  2390. content: res.message,
  2391. type: "error"
  2392. });
  2393.  
  2394. resolve(false);
  2395. }
  2396. }
  2397. })
  2398. });
  2399. }, */
  2400.  
  2401. getGiftList: async function(room) {
  2402. return new Promise((resolve) => {
  2403. Ajax.get({
  2404.  
  2405. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  2406. queryStringsObj: {
  2407. "room_id": room
  2408. },
  2409. hasCookies: true,
  2410. success: responseText => {
  2411. let res = HNTOOL.strToJson(responseText);
  2412. if (res.code === 0) {
  2413.  
  2414. resolve(res.data.list);
  2415. } else {
  2416.  
  2417. javaex.tip({
  2418. content: "查询包裹失败!" + res.message,
  2419. type: "error"
  2420. });
  2421.  
  2422. resolve(false)
  2423. }
  2424. }
  2425. })
  2426. });
  2427. },
  2428.  
  2429. /**
  2430. * 送银B克拉
  2431. * @param {Object} ruid
  2432. * @param {Object} roomid
  2433. */
  2434. bagSendGift: async function(ruid, roomid, bag_id) {
  2435. return new Promise((resolve) => {
  2436. Ajax.post({
  2437. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  2438. hasCookies: true,
  2439. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2440. data: {
  2441. uid: Live_info.uid, //当前用户
  2442. gift_id: 3,
  2443. ruid: ruid,
  2444. send_ruid: 0,
  2445. gift_num: 1,
  2446. bag_id: bag_id,
  2447. //rnd: Math.round(new Date() / 1000); //时间戳,
  2448. platform: 'pc',
  2449. biz_code: 'Live',
  2450. biz_id: roomid,
  2451. storm_beat_id: 0,
  2452. price: 0,
  2453. csrf_token: Live_info.csrf_token,
  2454. csrf: Live_info.csrf_token
  2455.  
  2456. },
  2457. success: responseText => {
  2458. let res = HNTOOL.strToJson(responseText);
  2459. if (res.code === 0) {
  2460.  
  2461. javaex.tip({
  2462. content: roomid + "赠送b克拉成功!" + res.message,
  2463. type: "success"
  2464. });
  2465.  
  2466. resolve(true);
  2467. } else {
  2468.  
  2469. javaex.tip({
  2470. content: res.message,
  2471. type: "error"
  2472. });
  2473.  
  2474. resolve(false);
  2475. }
  2476. }
  2477. })
  2478. });
  2479. },
  2480.  
  2481.  
  2482. /**
  2483. * 判断是否有勋章
  2484. * @param {Object} uid
  2485. * @param {Object} room
  2486. */
  2487.  
  2488. getFansMedalInfo: async function(uid, room) {
  2489. return new Promise((resolve) => {
  2490. Ajax.get({
  2491.  
  2492. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  2493. queryStringsObj: {
  2494. "target_id": uid,
  2495. "room_id": room
  2496. },
  2497. //dataType:'application/json, text/plain, */*',
  2498. hasCookies: true,
  2499. success: responseText => {
  2500. let res = HNTOOL.strToJson(responseText);
  2501. if (res.code === 0) {
  2502.  
  2503. if (res.data.my_fans_medal.level == 0) {
  2504. resolve(false)
  2505. } else {
  2506. resolve(true)
  2507. }
  2508.  
  2509. } else {
  2510.  
  2511. javaex.tip({
  2512. content: "查询勋章失败!" + res.message,
  2513. type: "error"
  2514. });
  2515.  
  2516. resolve(false)
  2517. }
  2518. }
  2519. })
  2520. });
  2521. },
  2522.  
  2523.  
  2524.  
  2525.  
  2526. getDisuidList: async function(re_version, pn) {
  2527. return new Promise((resolve) => {
  2528. Ajax.get({
  2529.  
  2530. url: BILIBLI_PATH.api + '/x/relation/blacks',
  2531. queryStringsObj: {
  2532. "re_version": re_version,
  2533. "pn": pn
  2534. },
  2535. hasCookies: true,
  2536. success: responseText => {
  2537. let res = HNTOOL.strToJson(responseText);
  2538. if (res.code === 0) {
  2539. resolve(res.data.list)
  2540. } else {
  2541.  
  2542. javaex.tip({
  2543. content: "查询黑名单失败!" + res.message,
  2544. type: "error"
  2545. });
  2546.  
  2547. resolve(null)
  2548. }
  2549. }
  2550. })
  2551. });
  2552. },
  2553.  
  2554. /**
  2555. * @param {Object} uid
  2556. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  2557. */
  2558. cancelAtt: async function(uid, act, re_src) {
  2559. return new Promise((resolve) => {
  2560. Ajax.post({
  2561. url: BILIBLI_PATH.api + '/x/relation/modify',
  2562. hasCookies: true,
  2563. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2564. data: {
  2565. fid: uid,
  2566. act: act,
  2567. re_src: re_src == undefined ? 11 : 116,
  2568. jsonp: "jsonp",
  2569. csrf: Live_info.csrf_token,
  2570. },
  2571. success: responseText => {
  2572. let res = HNTOOL.strToJson(responseText);
  2573. if (res.code === 0) {
  2574.  
  2575. //HNAPI.cancelAtt(uid, 6);
  2576.  
  2577. javaex.tip({
  2578. content: "取关成功!" + res.message,
  2579. type: "success"
  2580. });
  2581.  
  2582. resolve(true);
  2583. } else if (res.code === 22003) {
  2584.  
  2585. HNAPI.cancelAtt(uid, 6);
  2586.  
  2587. javaex.tip({
  2588. content: "取消拉黑" + res.message,
  2589. type: "success"
  2590. });
  2591. resolve(true);
  2592. } else {
  2593.  
  2594. javaex.tip({
  2595. content: res.message,
  2596. type: "error"
  2597. });
  2598.  
  2599. resolve(false);
  2600. }
  2601. }
  2602. })
  2603. });
  2604. },
  2605.  
  2606. getRoomMsg: async function(roomid) {
  2607. return new Promise((resolve) => {
  2608. Ajax.get({
  2609.  
  2610. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  2611. queryStringsObj: {
  2612. "roomid": roomid
  2613. },
  2614. hasCookies: true,
  2615. success: responseText => {
  2616. let res = HNTOOL.strToJson(responseText);
  2617. if (res.code === 0) {
  2618. resolve(res.data.info.uid)
  2619. } else {
  2620. resolve(false)
  2621. }
  2622. }
  2623. })
  2624. });
  2625. },
  2626.  
  2627. /**
  2628. *
  2629. * @param sid
  2630. * @returns {Promise<unknown>}
  2631. */
  2632. lotteryDo: async function(sid) {
  2633. return new Promise((resolve) => {
  2634. Ajax.post({
  2635. url: BILIBLI_PATH.api + '/x/activity/lottery/do',
  2636. hasCookies: true,
  2637. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2638. data: {
  2639.  
  2640. sid: sid,
  2641. type: 1,
  2642. csrf: Live_info.csrf_token,
  2643. },
  2644. success: responseText => {
  2645. let res = HNTOOL.strToJson(responseText);
  2646. if (res.code === 0) {
  2647. resolve((res.data)[0].gift_name);
  2648.  
  2649. } else if (res.code === 75400) {
  2650.  
  2651. resolve(true);
  2652. } else {
  2653. javaex.tip({
  2654. content: "本次抽奖失败!" + res.message,
  2655. type: "error"
  2656. });
  2657. resolve(false);
  2658. }
  2659. }
  2660. })
  2661. });
  2662. },
  2663.  
  2664.  
  2665. getLotteryMytimes: async function(sid) {
  2666. return new Promise((resolve) => {
  2667. Ajax.get({
  2668. url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
  2669. queryStringsObj: {
  2670. sid: sid
  2671. },
  2672. hasCookies: true,
  2673. success: responseText => {
  2674. let res = HNTOOL.strToJson(responseText);
  2675. if (res.code === 0) {
  2676. resolve(res.data.times)
  2677. } else {
  2678. resolve(0)
  2679. }
  2680. }
  2681. })
  2682. });
  2683. },
  2684.  
  2685. /**
  2686. * 增加抽奖次数一般是分享
  2687. * @param sid 活动sid
  2688. * @returns {Promise<unknown>} 0 成功 1:活动结束
  2689. */
  2690. addLotteryTimes: async function(sid) {
  2691. return new Promise((resolve) => {
  2692. Ajax.post({
  2693. url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
  2694. hasCookies: true,
  2695. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2696. data: {
  2697.  
  2698. sid: sid,
  2699. action_type: 3,
  2700. csrf: Live_info.csrf_token,
  2701. },
  2702. success: responseText => {
  2703. let res = HNTOOL.strToJson(responseText);
  2704. if (res.code === 0) {
  2705.  
  2706. resolve(0)
  2707. } else if (res.code === 75003) {
  2708.  
  2709. resolve(1)
  2710.  
  2711. } else {
  2712.  
  2713. resolve(res.message);
  2714. }
  2715. }
  2716. })
  2717. });
  2718. },
  2719. /**
  2720. * 查询用户关注 默认一次查询50
  2721. * @param vmid 用户uid
  2722. * @param pn 页码
  2723. * @returns {Promise<unknown>}
  2724. */
  2725. getMyFollow: async function(vmid, pn) {
  2726. return new Promise((resolve) => {
  2727. Ajax.get({
  2728. url: BILIBLI_PATH.api + '/x/relation/followings',
  2729. queryStringsObj: {
  2730. vmid: vmid,
  2731. pn: pn
  2732. },
  2733. hasCookies: true,
  2734. success: responseText => {
  2735. let res = HNTOOL.strToJson(responseText);
  2736. if (res.code === 0) {
  2737. resolve(res.data)
  2738. } else {
  2739. resolve(null)
  2740. }
  2741. }
  2742. })
  2743. });
  2744. },
  2745.  
  2746.  
  2747. getMyinfo: function() {
  2748. return new Promise((resolve) => {
  2749. Ajax.get({
  2750. url: BILIBLI_PATH.api + '/x/space/myinfo',
  2751. queryStringsObj: {},
  2752. hasCookies: true,
  2753. success: responseText => {
  2754. let res = HNTOOL.strToJson(responseText);
  2755. if (res.code === 0) {
  2756. resolve(res.data)
  2757. } else {
  2758. resolve(null)
  2759. }
  2760. }
  2761. })
  2762. });
  2763. },
  2764.  
  2765. getMyJson: function(url) {
  2766. return new Promise((resolve) => {
  2767. GM_xmlhttpRequest({
  2768. method: "GET",
  2769. url: url,
  2770. onload: function(response) {
  2771. const res = HNTOOL.strToJson((response || {}).responseText)
  2772. resolve(res);
  2773. }
  2774. });
  2775. })
  2776. },
  2777.  
  2778.  
  2779. userInfo: function(mid) {
  2780.  
  2781. Ajax.get({
  2782. url: BILIBLI_PATH.api + '/x/space/acc/info',
  2783. queryStringsObj: {
  2784. mid: mid
  2785. },
  2786. hasCookies: true,
  2787. success: responseText => {
  2788.  
  2789. var json = JSON.parse(responseText);
  2790.  
  2791. if (json.code != 0) {
  2792.  
  2793.  
  2794. }
  2795. }
  2796. });
  2797.  
  2798. },
  2799.  
  2800. sendQmsg: async function(key, msg) {
  2801.  
  2802. $.ajax({
  2803. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  2804.  
  2805. success: function(result) {
  2806.  
  2807. }
  2808. });
  2809.  
  2810.  
  2811. /*GM_xmlhttpRequest({
  2812. method: "GET",
  2813. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  2814. onload: function (response) {
  2815.  
  2816. let json = JSON.parse(response.response);
  2817. if (json.code == 0) {
  2818.  
  2819. javaex.tip({
  2820. content: "自动动态中奖提醒成功!" + json.reason,
  2821. type: "success"
  2822. });
  2823. } else {
  2824. console.log("自动动态中奖提醒失败!" + json.reason);
  2825. javaex.tip({
  2826. content: "自动动态中奖提醒失败!" + json.reason,
  2827. type: "error"
  2828. });
  2829. }
  2830.  
  2831. }
  2832. });*/
  2833.  
  2834. },
  2835.  
  2836. /**
  2837. * 批量关注和拉黑 batchModify
  2838. *
  2839. * https://api.bilibili.com/x/relation/batch/modify
  2840. * @param uid
  2841. */
  2842.  
  2843. batchModify: function(uids, act) {
  2844.  
  2845.  
  2846. Ajax.post({
  2847. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  2848. hasCookies: true,
  2849. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2850. data: {
  2851.  
  2852. "fids": uids,
  2853. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  2854. "re_src": 151,
  2855. csrf: Live_info.csrf_token,
  2856. },
  2857. success: responseText => {
  2858.  
  2859. let json = JSON.parse(responseText);
  2860.  
  2861. if (/^{"code":0/.test(responseText)) {
  2862.  
  2863. javaex.tip({
  2864. content: `执行成功!---失败(` + json.data.failed_fids.length + `/15)名单:` + json.data.failed_fids,
  2865. type: "success"
  2866. });
  2867.  
  2868. } else {
  2869. javaex.tip({
  2870. content: "关注失败!" + json.message,
  2871. type: "error"
  2872. });
  2873. }
  2874. }
  2875. })
  2876. },
  2877.  
  2878.  
  2879. /**
  2880. * //https://api.bilibili.com/x/relation/modify
  2881. *
  2882. * @param UID
  2883. */
  2884. disUserByUid: function(vmid) {
  2885.  
  2886. Ajax.post({
  2887. url: BILIBLI_PATH.api + '/x/relation/modify',
  2888. data: {
  2889. fid: parseInt(vmid),
  2890. re_src: 11,
  2891. act: 5,
  2892. jsonp: "jsonp",
  2893. csrf: Live_info.csrf_token,
  2894. },
  2895. hasCookies: true,
  2896. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2897. success: responseText => {
  2898.  
  2899. var json = JSON.parse(responseText);
  2900.  
  2901. if (json.code != 0) {
  2902.  
  2903. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  2904. javaex.tip({
  2905. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  2906. type: "error"
  2907. });
  2908.  
  2909. } else {
  2910. console.log("拉黑用户成功 uid:" + vmid);
  2911. javaex.tip({
  2912. content: "拉黑用户成功 uid:" + vmid,
  2913. type: "success"
  2914. });
  2915. }
  2916. }
  2917. });
  2918.  
  2919. },
  2920. /**
  2921. * http://api.bilibili.com/x/web-interface/view
  2922. * @param BV
  2923. * 心跳间隔15秒
  2924. */
  2925. playOneVideo: function(BV, MID) {
  2926.  
  2927. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  2928. Ajax.post({
  2929. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  2930. hasCookies: true,
  2931. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2932. data: {
  2933.  
  2934. "bvid": BV,
  2935. "part": 1,
  2936. "mid": Live_info.uid,
  2937. "lv": 2,
  2938. "jsonp": "jsonp",
  2939. "type": 3,
  2940. "sub_type": 0
  2941. },
  2942. success: responseText => {
  2943.  
  2944. let json = JSON.parse(responseText);
  2945.  
  2946. if (/^{"code":0/.test(responseText)) {
  2947. //发送一次心跳
  2948. HNAPI.sendHeartbeat(BV, MID);
  2949.  
  2950. } else {
  2951. javaex.tip({
  2952. content: "视频" + data.bvid + "播放失败!" + json.message,
  2953. type: "error"
  2954. });
  2955. }
  2956. }
  2957. })
  2958.  
  2959.  
  2960. },
  2961.  
  2962. //上报视频播放心跳(web端)
  2963. /**
  2964. * http://api.bilibili.com/x/click-interface/web/heartbeat
  2965. * @param json
  2966. */
  2967. sendHeartbeat: function(bvid, MID) {
  2968.  
  2969. Ajax.post({
  2970. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  2971. hasCookies: true,
  2972. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2973. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  2974. data: {
  2975. "bvid": bvid,
  2976. "type": 3,
  2977. "dt": 2,
  2978. "played_time": HNTOOL.random(12, 40),
  2979. "realtime": HNTOOL.random(12, 40),
  2980. "play_type": 0
  2981. },
  2982. success: responseText => {
  2983.  
  2984. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  2985.  
  2986. javaex.tip({
  2987. content: "视频BV" + bvid + "播放一次!",
  2988. type: "success"
  2989. });
  2990. }
  2991. }
  2992. })
  2993.  
  2994. },
  2995.  
  2996. //获取up所有投稿视频
  2997. /**
  2998. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  2999. * @param mid
  3000. */
  3001. getUpAllBV: function(mid, pn, ps) {
  3002. ps = (ps === undefined ? 30 : ps); // a默认值为1
  3003. Ajax.get({
  3004. url: BILIBLI_PATH.api + '/x/space/arc/search',
  3005. queryStringsObj: {
  3006. mid: mid,
  3007. tid: 0,
  3008. order: 'pubdate',
  3009. jsonp: 'jsonp',
  3010. pn: pn,
  3011. ps: ps
  3012. },
  3013. hasCookies: true,
  3014. success: responseText => {
  3015.  
  3016. var json = JSON.parse(responseText);
  3017.  
  3018. if (json.code != 0) {
  3019.  
  3020. javaex.tip({
  3021. content: "获取up所有投稿视频失败!" + json.message,
  3022. type: "success"
  3023. });
  3024.  
  3025. } else {
  3026. BiliData.BVList = json.data.list.vlist;
  3027.  
  3028. }
  3029. }
  3030. });
  3031.  
  3032. },
  3033.  
  3034.  
  3035. /**
  3036. *
  3037. * @param path
  3038. * @param data
  3039. * @param saveObj
  3040. * @param Func
  3041. */
  3042. publicGet: function(path, queryStringsObj) {
  3043.  
  3044. if (typeof(queryStringsObj) != "undefined") {
  3045. queryStringsObj = {};
  3046. }
  3047. Ajax.get({
  3048. url: BILIBLI_PATH.api + path,
  3049. queryStringsObj: queryStringsObj,
  3050. hasCookies: true,
  3051. success: responseText => {
  3052.  
  3053. let json = JSON.parse(responseText);
  3054. if (chackCode(json.code) && json.code == 0) {
  3055.  
  3056. return json.data;
  3057. }
  3058.  
  3059. return false;
  3060.  
  3061. }
  3062. })
  3063.  
  3064. },
  3065.  
  3066. /**
  3067. * 导航栏用户信息
  3068. */
  3069. getUserNav: async function() {
  3070.  
  3071. GM_xmlhttpRequest({
  3072. method: "GET",
  3073. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  3074. //timeout:3000,
  3075. onload: function(response) {
  3076.  
  3077. let json = JSON.parse(response.response);
  3078. console.log(json);
  3079. BiliData.login_code = json.code;
  3080. BiliData.login_message = json.message;
  3081. BiliData.LoginData = json.data;
  3082.  
  3083. }
  3084. });
  3085.  
  3086. },
  3087.  
  3088. /**
  3089. * 获取某up详细信息
  3090. * http://api.bilibili.com/x/web-interface/card
  3091. */
  3092. getUpCard: function(mid) {
  3093.  
  3094. Ajax.get({
  3095. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3096. queryStringsObj: {
  3097. mid: mid,
  3098. photo: false
  3099. },
  3100. hasCookies: true,
  3101. success: responseText => {
  3102.  
  3103. var json = JSON.parse(responseText);
  3104.  
  3105. if (json.code != 0) {
  3106.  
  3107. javaex.tip({
  3108. content: "查询失败!" + json.message,
  3109. type: "success"
  3110. });
  3111. return false;
  3112. } else {
  3113. BiliData.upCard = json;
  3114.  
  3115. }
  3116.  
  3117.  
  3118. }
  3119. })
  3120.  
  3121. },
  3122.  
  3123. /**
  3124. *
  3125. * @param uid 用户uid
  3126. * @param ps 每页视频个数 默认30个
  3127. * @param pn 第几页
  3128. */
  3129. getUpAllVideo: function(uid, ps, pn) {
  3130.  
  3131. },
  3132. getChallenge: async function() {
  3133.  
  3134.  
  3135. },
  3136. /**
  3137. * 硬币记录
  3138. * @returns {Promise<void>}
  3139. */
  3140. getCoinLog: async function() {
  3141.  
  3142. GM_xmlhttpRequest({
  3143. method: "GET",
  3144. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  3145. //url: "http://api.bilibili.com/x/member/web/coin/log",
  3146. onload: function(response) {
  3147.  
  3148. let json = JSON.parse(response.response);
  3149. if (json.code == 0) {
  3150.  
  3151. console.log("硬币记录" + json);
  3152. BiliData.CoinLog = json.data;
  3153.  
  3154. return true;
  3155. }
  3156.  
  3157. }
  3158. });
  3159. },
  3160. /**
  3161. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  3162. * @returns {Promise<void>}
  3163. */
  3164. getUnread: async function() {
  3165.  
  3166. Ajax.get({
  3167. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  3168. hasCookies: true,
  3169. success: responseText => {
  3170.  
  3171. let json = JSON.parse(responseText);
  3172. if (chackCode(json.code) && json.code == 0) {
  3173.  
  3174. BiliData.Unread = json.data;
  3175. showUnreadMsg();
  3176. }
  3177.  
  3178. return false;
  3179.  
  3180. }
  3181. })
  3182.  
  3183. /* GM_xmlhttpRequest({
  3184. method: "GET",
  3185. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  3186. onload: function (response) {
  3187.  
  3188. let json = JSON.parse(response.response);
  3189.  
  3190. if (chackCode(json.code) && json.code == 0) {
  3191.  
  3192. BiliData.Unread = json.code;
  3193. showUnreadMsg();
  3194.  
  3195. }
  3196.  
  3197. }
  3198. });*/
  3199. },
  3200. /**
  3201. *
  3202. * @param type reply:回复我的 at @我的
  3203. */
  3204. getMsgfeed: function(type) {
  3205. Ajax.get({
  3206. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  3207. queryStringsObj: {
  3208. build: 0,
  3209. mobi_app: 'web'
  3210. },
  3211. hasCookies: true,
  3212. success: responseText => {
  3213.  
  3214. var json = JSON.parse(responseText);
  3215.  
  3216. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  3217. return false;
  3218. } else {
  3219. chackAtMsg(json.data.items);
  3220.  
  3221. return true;
  3222. }
  3223.  
  3224.  
  3225. }
  3226. })
  3227.  
  3228. },
  3229.  
  3230. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  3231. * @returns {Promise<void>}
  3232. */
  3233. getUnrewad: async function() {
  3234.  
  3235. GM_xmlhttpRequest({
  3236. method: "GET",
  3237. data: {
  3238. "mid": 99439379,
  3239. "pn": 1,
  3240. "ps": 5,
  3241. },
  3242. url: BILIBLI_PATH.api + "/x/space/arc/search",
  3243. onload: function(response) {
  3244.  
  3245. let json = JSON.parse(response.response);
  3246. if (json.code == 0) {
  3247.  
  3248. BiliData.Video = json.data;
  3249. console.log("未读消息数" + json);
  3250. }
  3251.  
  3252. }
  3253. });
  3254. },
  3255.  
  3256. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  3257. * @param {number} oid
  3258. * @param {nbumber} rpid
  3259. * @param {number} action
  3260. * @returns {Promise<void>}
  3261. * type: 11
  3262. * ordering: heat
  3263. * jsonp: jsonp
  3264. * csrf: 54a******* CSRF Token(位于cookie)
  3265. */
  3266.  
  3267. likeInDynamicComments: async function(latestDynamic) {
  3268.  
  3269.  
  3270. Ajax.post({
  3271. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  3272. hasCookies: true,
  3273. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3274. data: {
  3275. "oid": oid,
  3276. "type": 11,
  3277. "rpid": rpid,
  3278. "action": action,
  3279. "ordering": "heat",
  3280. "jsonp": "jsonp",
  3281. "csrf": Live_info.csrf_token,
  3282. },
  3283. success: responseText => {
  3284.  
  3285. if (/^{"code":0/.test(responseText)) {
  3286.  
  3287. BiliData.replyAction = JSON.parse(responseText);
  3288. console.log("点赞成功!" + responseText);
  3289. }
  3290. }
  3291. })
  3292.  
  3293. }
  3294.  
  3295.  
  3296. }
  3297.  
  3298. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  3299. var http_request = null;
  3300.  
  3301. function send_request(url, method) {}
  3302.  
  3303. let HNTOOL = {
  3304.  
  3305. getLatestDynamic: async function() {
  3306.  
  3307. let date = new Date();
  3308. let thisdate = date.getMonth() + 1 + "月" + date.getDate() < 10 ? '0' + date.getDate() : date.getDate() +
  3309. "日";
  3310. let latestDynamic = await HNAPI.getTodayDynamicList(226257459, thisdate);
  3311. let latestDynamic2 = await HNAPI.getTodayDynamicList(226257459, "抽奖合集");
  3312.  
  3313. let ld1 = await HNTOOL.getDynamicIdList(latestDynamic);
  3314. await HNTOOL.Sleep(2000);
  3315. let ld2 = await HNTOOL.getDynamicIdList(latestDynamic2);
  3316.  
  3317. return HNTOOL.arrUnique(ld1.concat(ld2), false);
  3318.  
  3319.  
  3320. },
  3321.  
  3322. getDynamicIdList: async function(latestDynamic) {
  3323.  
  3324.  
  3325. let returnlist = [];
  3326. return new Promise((resolve) => {
  3327. Ajax.get({
  3328. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  3329. queryStringsObj: {},
  3330. dataType: "html",
  3331. hasCookies: false,
  3332. success: responseText => {
  3333. let datalist = HNTOOL.httpString(responseText);
  3334. let dls;
  3335. for (let dl of datalist) {
  3336.  
  3337. let len = dl.indexOf("?");
  3338. if (len == -1) {
  3339. dl += "?tab=2";
  3340. }
  3341. dls = dl.substring(dl.indexOf("?") - 18, dl.indexOf("?"));
  3342. if (returnlist.indexOf(dls) > -1 || dls == null || dl.indexOf("read") > -1 || dl.indexOf("html") > -1) {
  3343. continue;
  3344. }
  3345. /* let len = dl.indexOf("?");
  3346. if (len > -1) {
  3347. dls = dl.substring(len - 18, len);
  3348. }
  3349.  
  3350. if (dl.indexOf("tab") == -1 || returnlist.indexOf(dls) > -1 || dls == null) {
  3351. continue;
  3352. } */
  3353. returnlist.push(dls);
  3354.  
  3355. }
  3356. resolve(HNTOOL.arrUnique(returnlist, false));
  3357.  
  3358. if (datalist.length == 0) {
  3359. resolve(false);
  3360. }
  3361. }
  3362. })
  3363. });
  3364. },
  3365.  
  3366.  
  3367. /* getDynamicIdList: async function() {
  3368.  
  3369.  
  3370. let latestDynamic = await HNAPI.getTodayDynamicList();
  3371. let returnlist = [];
  3372. $.ajax({
  3373. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  3374. dataType: "html",
  3375. success: function(data) {
  3376. let datalist = HNTOOL.httpString(data);
  3377.  
  3378. let dls;
  3379. for (let dl of datalist) {
  3380. let len = dl.indexOf("?");
  3381. if (len > -1) {
  3382. dls = dl.substring(len - 18, len);
  3383. }
  3384.  
  3385. if (dl.indexOf("tab") == -1 || returnlist.indexOf(dls) > -1 || dls == null) {
  3386. continue;
  3387. }
  3388. //https://t.bilibili.com/552091391342505523?tab=22
  3389. returnlist.push(dls);
  3390.  
  3391. }
  3392.  
  3393. return returnlist;
  3394. }
  3395. });
  3396.  
  3397. }, */
  3398.  
  3399.  
  3400.  
  3401. httpString: function(s) {
  3402. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  3403. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  3404. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3405. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3406. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  3407. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  3408. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  3409. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  3410. s = s.match(reg);
  3411. console.log(s)
  3412. return (s)
  3413. },
  3414.  
  3415. saveConfig: function() {
  3416.  
  3417. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  3418. /* javaex.tip({
  3419. content: "配置保存成功!",
  3420. type: "success"
  3421. }); */
  3422.  
  3423. },
  3424.  
  3425. copyText: function(domId) {
  3426. let btn = document.getElementById(domId);
  3427. btn.select();
  3428. if (document.execCommand('copy')) {
  3429. document.execCommand('copy');
  3430. javaex.tip({
  3431. content: "复制成功!",
  3432. type: "success"
  3433. });
  3434. }
  3435.  
  3436. },
  3437. /**
  3438. * s数组去重并排序
  3439. */
  3440.  
  3441. arrUnique: function(ary, isSort) {
  3442.  
  3443. if (isSort == undefined) {
  3444. isSort = true
  3445. }
  3446. let obj = {};
  3447. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  3448. let item = ary[i]
  3449. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  3450. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  3451. // 如果没有 将这个元素添加到对象中
  3452. if (isSort) {
  3453. ary.sort((a, b) => {
  3454. return a - b
  3455. }) // 数组去重后 按升序排列
  3456. }
  3457.  
  3458. obj = null;
  3459.  
  3460. javaex.tip({
  3461. content: "已去重!",
  3462. type: "success"
  3463. });
  3464. return ary;
  3465.  
  3466. },
  3467.  
  3468. split_array: function(arr, len) {
  3469.  
  3470. let arr_length = arr.length;
  3471. let newArr = [];
  3472. for (let i = 0; i < arr_length; i += len) {
  3473. newArr.push(arr.slice(i, i + len));
  3474. }
  3475. return newArr;
  3476. },
  3477. strToJson: function(params) {
  3478. const isJSON = (str => {
  3479. if (typeof str === 'string') {
  3480. try {
  3481. const obj = JSON.parse(str);
  3482. return typeof obj === 'object' ? obj : false
  3483. } catch (_) {
  3484. console.log(str);
  3485. return false;
  3486. }
  3487. } else {
  3488. console.log(`${str}\nIt is not a string!`);
  3489. return false;
  3490. }
  3491. })(params);
  3492. return isJSON ? isJSON : {}
  3493. },
  3494.  
  3495. chackAtMsg: function() {
  3496.  
  3497. let config = HNTOOL.getConfig();
  3498. if (config.qmsg_checked == true && config.qmsg_key) {
  3499.  
  3500. document.getElementById("getAtMsg").click();
  3501.  
  3502. }
  3503.  
  3504. },
  3505.  
  3506. cssChecked: function(id, dom) {
  3507.  
  3508. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  3509.  
  3510.  
  3511. },
  3512. getConfig: function() {
  3513.  
  3514. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  3515.  
  3516. if (CONFIG == null) {
  3517. CONFIG = HN_SETUP_CONFIG;
  3518. }
  3519.  
  3520. return CONFIG;
  3521. },
  3522.  
  3523. /**
  3524. * 获取cookie 中某个键对应的值
  3525. * @param name
  3526. */
  3527.  
  3528. getCookie: function(name) {
  3529. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  3530. if (arr != null) return escape(arr[2]);
  3531. return false;
  3532. },
  3533. /**
  3534. * 得到一个字符串数组的中随机一个
  3535. * @param {List} list
  3536. */
  3537.  
  3538.  
  3539. getRandomWordOfList: function(list) {
  3540. var L = list.length;
  3541. var i = Math.ceil(Math.random() * L);
  3542.  
  3543. return list[i];
  3544. },
  3545. random: function(min, max) {
  3546.  
  3547. return Math.floor(Math.random() * (max - min)) + min;
  3548. },
  3549.  
  3550. Sleep: function(ms) {
  3551. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  3552. }
  3553.  
  3554. }
  3555.  
  3556. let errorMsg = {
  3557. "-1": "应用程序不存在或已被封禁!",
  3558. "-2": "Access Key错误!",
  3559. "-3": "API校验密匙错误!",
  3560. "-4": "调用方对该Method没有权限!",
  3561. "-101": "账号未登录!",
  3562. "-102": "账号被封停!",
  3563. "-103": "积分不足!",
  3564. "-104": "硬币不足!",
  3565. "-105": "验证码错误!",
  3566. "-106": "账号非正式会员或在适应期!",
  3567. "-107": "应用不存在或者被封禁!",
  3568. "-108": "未绑定手机!",
  3569. "-109": "未知!",
  3570. "-110": "未绑定手机!",
  3571. "-111": "csrf 校验失败!",
  3572. "-112": "系统升级中!",
  3573. "-113": "账号尚未实名认证!",
  3574. "-114": "请先绑定手机!",
  3575. "-115": "请先完成实名认证!",
  3576. "-304": "木有改动!",
  3577. "-307": "撞车跳转!",
  3578. "-400": "请求错误!",
  3579. "-401": "未认证!",
  3580. "-403": "访问权限不足!",
  3581. "-404": "啥都木有!",
  3582. }
  3583.  
  3584. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  3585. /**
  3586. *
  3587. * @param code
  3588. * @constructor
  3589. */
  3590. let chackCode = function(code) {
  3591.  
  3592. let emsg = errorMsg[code + ""];
  3593. if (emsg != null) {
  3594. javaex.tip({
  3595. content: emsg,
  3596. type: "error"
  3597. });
  3598.  
  3599. return false;
  3600. }
  3601.  
  3602. return true;
  3603. }
  3604.  
  3605.  
  3606. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  3607. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  3608.  
  3609. /*window.onbeforeunload = function() {
  3610. if (!canLeavePage()) {
  3611. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  3612. }
  3613. };*/
  3614.  
  3615.  
  3616. /**
  3617. * Ajax请求对象
  3618. */
  3619. const Ajax = (() => {
  3620. /**
  3621. * 检查options是否符合要求
  3622. * @param {object} options
  3623. * @returns {boolean}
  3624. */
  3625. function checkOptions(options) {
  3626. let result = false;
  3627. if (typeof options !== 'object') {
  3628. console.warn('类型错误: typeof Options !== Object');
  3629. return result;
  3630. } else {
  3631. if (typeof options.url !== 'string') {
  3632. console.warn('类型错误: typeof Link !== Strings');
  3633. return result;
  3634. } else {
  3635. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  3636. if (!reg.test(options.url)) {
  3637. console.warn('url字符串须为完整http链接');
  3638. return result;
  3639. }
  3640. result = true;
  3641. }
  3642. }
  3643. return result;
  3644. }
  3645.  
  3646. /**
  3647. * 对象转URL编码
  3648. * @param {object} data
  3649. */
  3650. function objToURLCode(data) {
  3651. var _result = [];
  3652. for (var key in data) {
  3653. var value = data[key];
  3654. if (value instanceof Array) {
  3655. value.forEach(function(_value) {
  3656. _result.push(key + "=" + _value);
  3657. });
  3658. } else {
  3659. _result.push(key + '=' + value);
  3660. }
  3661. }
  3662. return _result.join('&');
  3663. }
  3664.  
  3665. /**
  3666. * 请求
  3667. * @param {string} method
  3668. * @param {object} options
  3669. */
  3670. function request(method, options) {
  3671. if (checkOptions(options)) {
  3672. let xhr = new XMLHttpRequest();
  3673. const {
  3674. url: _url,
  3675. queryStringsObj,
  3676. data,
  3677. dataType,
  3678. hasCookies
  3679. } = options, url = typeof queryStringsObj === 'object' ?
  3680. _url + '?' + objToURLCode(queryStringsObj) : _url;
  3681. switch (method) {
  3682. case 'GET':
  3683. xhr.open("GET", url);
  3684. break;
  3685. case 'POST':
  3686. xhr.open("POST", url);
  3687. xhr.setRequestHeader('Content-Type', dataType);
  3688. break;
  3689. default:
  3690. break;
  3691. }
  3692. if (hasCookies) xhr.withCredentials = true;
  3693. xhr.timeout = 3000;
  3694. xhr.addEventListener('load', () => {
  3695. if (xhr.status === 200) {
  3696. options.success(xhr.responseText)
  3697. } else {
  3698. console.error(`status:${xhr.status}`);
  3699. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  3700. }
  3701. })
  3702. xhr.addEventListener('error', () => {
  3703. console.error('ajax请求出错')
  3704. options.success('{"code":-1,"msg":"ajax请求出错"}');
  3705. })
  3706. xhr.addEventListener('timeout', () => {
  3707. console.error('请求超时')
  3708. options.success('{"code":-1,"msg":"请求超时"}');
  3709. })
  3710. switch (method) {
  3711. case 'GET':
  3712. xhr.send()
  3713. break;
  3714. case 'POST':
  3715. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  3716. break;
  3717. default:
  3718. break;
  3719. }
  3720. }
  3721. }
  3722.  
  3723. return {
  3724. /**
  3725. * 发送Get请求
  3726. * @param {Object} options
  3727. */
  3728. get(options) {
  3729. request("GET", options);
  3730. },
  3731. /**
  3732. * 发送Post请求
  3733. * @param {object} options
  3734. */
  3735. post(options) {
  3736. request("POST", options);
  3737. }
  3738. }
  3739. })()