-哔哩猫-(试用版)

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

目前為 2021-08-02 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/422731/956636/-%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.91
  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_type = 17;
  1144. await HNTOOL.Sleep(2000);
  1145.  
  1146. if (dynamic_data.card.desc.is_liked == 1) {
  1147. continue;
  1148. }
  1149. //判断是否过期
  1150. if (dynamic_data.card.desc.type == 2) {
  1151. dynamic_type = 11;
  1152. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1153. await HNTOOL.Sleep(2000);
  1154.  
  1155. if (lNoticeData.lottery_time * 1000 <= (new Date()).getTime()) {
  1156.  
  1157.  
  1158. console.log(
  1159. "【" + index + "已过开奖时间】\n" +
  1160. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1161. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n"
  1162. );
  1163. continue;
  1164. }
  1165.  
  1166. }
  1167. //0.判断是否关注
  1168. if (dynamic_data.attentions.uids.indexOf(dynamic_data.card.desc.uid) == -1) {
  1169.  
  1170. HNAPI.batchModify(dynamic_data.card.desc.uid);
  1171. console.log("【" + index + "】" + dynamic_data.card.desc.uid + "无需关注!!!");
  1172. await HNTOOL.Sleep(1000);
  1173. }
  1174.  
  1175. //1.评论
  1176. await HNAPI.addReply(dynamic_data.card.desc.rid, dynamic_type);
  1177. await HNTOOL.Sleep(1000);
  1178. //3.点赞
  1179. await HNAPI.likeDynamic(value);
  1180. await HNTOOL.Sleep(1000);
  1181. //2.转发
  1182. await HNAPI.repostDynamic(value);
  1183. await HNTOOL.Sleep(1000);
  1184. console.log("【" + index + "】动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!");
  1185.  
  1186. javaex.tip({
  1187. content: "动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!",
  1188. type: "success"
  1189. });
  1190.  
  1191. //存储标记
  1192. //await HNAPI.setNotice(value);
  1193.  
  1194. //随机延迟120 -240秒
  1195. let sleeptime = HNTOOL.random(12, 24) * 10 * 1000;
  1196. console.log("转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!")
  1197. javaex.tip({
  1198. content: "转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!",
  1199. type: "success"
  1200. });
  1201. await HNTOOL.Sleep(sleeptime);
  1202. }
  1203. alert("今日动态抽奖完成!!!");
  1204.  
  1205. });
  1206.  
  1207. $("#batchFollowOfbastard").bind("click", async function() {
  1208.  
  1209. if (confirm("作者个人需求开发,谨慎使用!!!\n 本功能会取关设定值以下没有认证(官方&&个人)的关注! \n 不确定使用请取消!")) {
  1210.  
  1211. let fansNum = prompt("请输入最低粉丝数量", "50000");
  1212.  
  1213. if (fansNum != null && fansNum != "") {
  1214. //fansNum
  1215.  
  1216. let followList = await HNAPI.getAllFollow();
  1217. console.log(followList);
  1218. await HNTOOL.Sleep(2000);
  1219.  
  1220. for (let fl of followList) {
  1221.  
  1222. if (fl == 99439379) {
  1223. continue;
  1224. }
  1225. let user = await HNAPI.getCardByUID(fl);
  1226. await HNTOOL.Sleep(1000);
  1227. if (user.fans < parseInt(fansNum) && user.official_verify.type == -1) {
  1228.  
  1229. await HNAPI.cancelAtt(fl, 2);
  1230.  
  1231. javaex.tip({
  1232. content: "uid:" + user.mid + "-" + user.name + "---符合条件 取关成功!!!",
  1233. type: "success"
  1234. });
  1235. console.log("uid:" + user.mid + "-" + user.name + "--符合条件 取关成功!!!");
  1236.  
  1237. } else {
  1238. javaex.tip({
  1239. content: "uid:" + user.mid + "-" + user.name + "---不符合条件 取消!!!",
  1240. type: "success"
  1241. });
  1242. console.log("uid:" + user.mid + "-" + user.name + "---不符合条件 取消!!!");
  1243. }
  1244. }
  1245. }
  1246.  
  1247. }
  1248.  
  1249. });
  1250.  
  1251.  
  1252. $("#reserveActivity").bind("click", async function() {
  1253.  
  1254.  
  1255. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSid.json";
  1256. let myjson = await HNAPI.getMyJson(url);
  1257.  
  1258. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1259. if (typeof(lastSid) == "undefined") {
  1260. lastSid = HN_SETUP_CONFIG.Booking_last_sid;
  1261. }
  1262. lastSid = lastSid.split("&")[1];
  1263.  
  1264.  
  1265.  
  1266. for (const sid in myjson) {
  1267.  
  1268. if (lastSid >= sid) {
  1269.  
  1270. continue;
  1271. }
  1272.  
  1273. let siddata = myjson[sid];
  1274. //let sidList = await HNAPI.getDataByLiveSid(sid);
  1275. //await HNTOOL.Sleep(2000);
  1276.  
  1277. //let returnData = await HNAPI.reserveActivity(sid, sidList[sid].total);
  1278. await HNAPI.reserveActivity(sid);
  1279. await HNTOOL.Sleep(2000);
  1280.  
  1281. let tiplog = "\n --预约开始:" + javaex.dateFormat(siddata.livePlanStartTime, 'yyyy-MM-dd HH:mm:ss') +
  1282. //"\n --预约SID:" + siddata.sid +
  1283. //"\n --预约UID:" + siddata.upmid +
  1284. //"\n --预约地址:" + siddata.prizeInfo.jumpUrl +
  1285. "\n --预约人数:" + siddata.total + "人" +
  1286. "\n --预约奖品:" + siddata.prizeInfo.text;
  1287.  
  1288. console.log(tiplog);
  1289.  
  1290. javaex.tip({
  1291. content: tiplog,
  1292. type: "success"
  1293. });
  1294.  
  1295. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + sid;
  1296.  
  1297. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  1298.  
  1299. }
  1300.  
  1301. HNTOOL.saveConfig();
  1302. alert("预约抽奖结束");
  1303. });
  1304.  
  1305. $("#plateActivity").bind("click", async function() {
  1306.  
  1307. //获取轮盘数据
  1308.  
  1309. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1310. let myjson = await HNAPI.getMyJson(url);
  1311. let lmt = 0;
  1312. let k = 20; //重试次数 防止卡主
  1313. let giftArr = [];
  1314. let endAtion = [];
  1315.  
  1316. javaex.tip({
  1317. content: "开始参加轮盘!!!",
  1318. type: "success"
  1319. });
  1320.  
  1321. await HNAPI.getUserNav();
  1322. await HNTOOL.Sleep(1500);
  1323.  
  1324.  
  1325. for (const json of myjson) {
  1326. //let x = json.name;
  1327. for (let i = 0; i < 20; i++) {
  1328. //结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1329. let resout = await HNAPI.addLotteryTimes(json.sid);
  1330.  
  1331. await HNTOOL.Sleep(200);
  1332. if (resout == 1) {
  1333.  
  1334. endAtion.push(json.name + ":活动已结束!");
  1335. javaex.tip({
  1336. content: json.name + "活动已结束!",
  1337. type: "success"
  1338. });
  1339.  
  1340. break;
  1341. }
  1342. if (resout != 0 && resout != 1) {
  1343.  
  1344. javaex.tip({
  1345. content: json.name + resout,
  1346. type: "error"
  1347. });
  1348.  
  1349. break;
  1350. }
  1351.  
  1352. if (resout == 0) {
  1353.  
  1354. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1355. continue;
  1356. }
  1357.  
  1358. }
  1359.  
  1360. javaex.tip({
  1361. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1362. type: "success"
  1363. });
  1364.  
  1365. await HNTOOL.Sleep(1500);
  1366.  
  1367. for (let i = 0; i < lmt; i++) {
  1368.  
  1369. let gift = await HNAPI.lotteryDo(json.sid);
  1370.  
  1371.  
  1372. if (gift == true) {
  1373.  
  1374. javaex.tip({
  1375. content: "点击过快,9秒后自动重试!!!",
  1376. type: "error"
  1377. });
  1378.  
  1379. i--;
  1380. k--;
  1381. }
  1382.  
  1383. if (gift == false || k == 0) {
  1384. break;
  1385. }
  1386.  
  1387. if (gift != "未中奖0" && gift != true) {
  1388. giftArr.push(json.name + "奖品为:" + gift);
  1389. break;
  1390. } else {
  1391. javaex.tip({
  1392. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  1393. type: "success"
  1394. });
  1395. }
  1396. await HNTOOL.Sleep(9000);
  1397.  
  1398. }
  1399.  
  1400.  
  1401. }
  1402.  
  1403.  
  1404. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1405. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1406.  
  1407. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1408. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1409.  
  1410.  
  1411. });
  1412.  
  1413. $("#addPlay").bind("click", async function() {
  1414.  
  1415.  
  1416. let html = '';
  1417.  
  1418. html += '<div style="padding: 10px 10px 10px 0px;">'
  1419. html += '<form id="getUpMassage_form">'
  1420.  
  1421. html += ' <div class="javaex-unit clear">'
  1422. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  1423. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  1424. html +=
  1425. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  1426. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  1427. html += ' </div>'
  1428. html += ' </div>'
  1429. html += ' <div class="javaex-unit clear">'
  1430. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  1431. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  1432. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  1433. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  1434. html += ' </div>'
  1435. html += ' </div>'
  1436. html += '</form>';
  1437. html += ' <div class="javaex-unit clear tc">'
  1438. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  1439. html += ' </div>'
  1440. html += '<hr class="javaex-divider"></hr>';
  1441. html += '</div>';
  1442.  
  1443.  
  1444. javaex.panel(this, {
  1445. position: "right",
  1446. content: html
  1447. });
  1448.  
  1449. $("#addPlay_bgn").click(async function() {
  1450.  
  1451. let MID = javaex.getSelectVal("#addPlay_uid")
  1452. let BV = javaex.getSelectVal("#addPlay_bv");
  1453. let bvArr = [];
  1454. let bvArr2 = [];
  1455.  
  1456. MID = javaex.ifnull(MID, BiliData.author_uid);
  1457.  
  1458.  
  1459. if (BV == "0") {
  1460.  
  1461. //1.查询up所有视频BV号 2.发送心跳间隔2s
  1462. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  1463. await HNTOOL.Sleep(500);
  1464. bvArr2 = BiliData.BVList;
  1465.  
  1466. for (let i = 1; i > 0; i++) {
  1467.  
  1468. HNAPI.getUpAllBV(MID, i);
  1469.  
  1470. await HNTOOL.Sleep(500);
  1471.  
  1472. if (BiliData.BVList.length == 0) {
  1473. if (bvArr.length == 0) {
  1474. javaex.tip({
  1475. content: "该用户无投稿视频,请确认是否有误!",
  1476. type: "success"
  1477. });
  1478. await HNTOOL.Sleep(2000);
  1479. }
  1480. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  1481. bvArr = bvArr.concat(bvArr2);
  1482. break;
  1483. }
  1484.  
  1485. bvArr = bvArr.concat(BiliData.BVList);
  1486. }
  1487.  
  1488.  
  1489. if (bvArr.length != 0) {
  1490.  
  1491. for (const emt of bvArr) {
  1492.  
  1493. HNAPI.playOneVideo(emt.bvid, MID);
  1494.  
  1495. await HNTOOL.Sleep(2000);
  1496.  
  1497. }
  1498.  
  1499. alert("播放完成!!!");
  1500.  
  1501. }
  1502.  
  1503.  
  1504. } else {
  1505. //1.调用点击播放接口
  1506. //2.发送心跳
  1507.  
  1508. await HNTOOL.Sleep(500);
  1509.  
  1510. HNAPI.playOneVideo(BV);
  1511. }
  1512.  
  1513.  
  1514. });
  1515.  
  1516.  
  1517. });
  1518.  
  1519. }
  1520.  
  1521.  
  1522. let addSetPage = async function() {
  1523.  
  1524. HNTOOL.Sleep(1000);
  1525.  
  1526. $('body').append('' +
  1527. '<div id="left_navbar">' +
  1528. '<div class="javaex-menu-container"> ' +
  1529. ' <div id="menu" class="javaex-menu"> ' +
  1530. ' <ul> ' +
  1531. ' <li class="javaex-menu-item alone hover" > ' +
  1532. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  1533. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  1534. ' </li> ' +
  1535. ' </ul> ' +
  1536. ' <ul> ' +
  1537. ' <li class="javaex-menu-item"> ' +
  1538. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  1539. ' <ul> ' +
  1540. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  1541. ' </ul> ' +
  1542. ' </li> ' +
  1543. ' <li id="chackList" class="javaex-menu-item"> ' +
  1544. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  1545. ' <ul> ' +
  1546. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  1547. //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  1548. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  1549. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  1550. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  1551. ' </ul> ' +
  1552. ' </li> ' +
  1553. ' <li class="javaex-menu-item"> ' +
  1554. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  1555. ' <ul> ' +
  1556. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  1557. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  1558. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  1559. ' <li id="batchFollowOfbastard" class="javaex-hover-pulse"><a href="javaScript:;" >批量取关-慎用</a></li> ' +
  1560. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  1561. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  1562. //' <li 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="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
  1569. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  1570. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  1571. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  1572. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  1573. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  1574. ' <li id="dynamicActivity" class="javaex-hover-pulse"><a href="javaScript:;" >动态抽奖</a></li> ' +
  1575. //' <li id="likeInDynamicComments" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  1576. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  1577. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  1578. ' </ul> ' +
  1579. ' </li> ' +
  1580. ' <li class="javaex-menu-item"> ' +
  1581. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  1582. ' <ul> ' +
  1583. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  1584. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  1585. ' </ul> ' +
  1586. ' </li> ' +
  1587.  
  1588. ' </ul> ' +
  1589. ' </div> ' +
  1590. '</div>' +
  1591. '</div>');
  1592. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  1593.  
  1594. javaex.menu({
  1595. id: "menu",
  1596. isShowAll: false
  1597. });
  1598.  
  1599. }
  1600.  
  1601.  
  1602.  
  1603.  
  1604. let showUnreadMsg = function() {
  1605.  
  1606. var html = '';
  1607. html += '<div class="javaex-panel-box" style="width: 250px;">';
  1608. html += ' <ul>';
  1609. html += ` <p style="color: #FFF;">用户消息</p>`;
  1610. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  1611. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  1612. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  1613. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  1614. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  1615. html += ' <hr class="javaex-divider"></hr>';
  1616. html += ' </ul>';
  1617. html += '</div>';
  1618.  
  1619.  
  1620. javaex.panel(document.getElementById("getUnread"), {
  1621. position: "right",
  1622. content: html
  1623. });
  1624.  
  1625. javaex.tip({
  1626. content: "查询用户通知成功!",
  1627. type: "success"
  1628. });
  1629.  
  1630. }
  1631.  
  1632. /**
  1633. * 检查 艾特信息
  1634. * @returns {Promise<void>}
  1635. */
  1636. let chackAtMsg = async function(items) {
  1637.  
  1638. await HNTOOL.Sleep(500);
  1639.  
  1640. if (items != false && typeof(items) != "undefined") {
  1641.  
  1642.  
  1643. var html = '';
  1644. html += '<div class="javaex-panel-box" style="width: auto;">';
  1645. html += ' <ul>';
  1646. html += ` <p style="color: #FFF;">@信息</p>`;
  1647. items.forEach(function(item) {
  1648.  
  1649. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  1650. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  1651. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  1652.  
  1653. html +=
  1654. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  1655. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  1656. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  1657. html += ' <hr class="javaex-divider"></hr>';
  1658. });
  1659. html += ' </ul>';
  1660. html += '</div>';
  1661.  
  1662.  
  1663. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  1664. javaex.panel(document.getElementById("getAtMsg"), {
  1665. position: "right",
  1666. content: html
  1667. });
  1668. } else {
  1669. javaex.panel(document.getElementById("chackList"), {
  1670. position: "right",
  1671. content: html
  1672. });
  1673. }
  1674.  
  1675.  
  1676. }
  1677.  
  1678. }
  1679.  
  1680.  
  1681. let addStyle = function() {
  1682. const animate = GM_getResourceText('animate');
  1683. const common = GM_getResourceText('common');
  1684. const defaultCss = GM_getResourceText('defaultCss');
  1685. //const icomoonex = GM_getResourceText('icomoonex');
  1686. //const AllCss = animate + common + defaultCss + icomoonex;
  1687. const AllCss = animate + common + defaultCss;
  1688. const style = document.createElement('style');
  1689. style.innerHTML = AllCss;
  1690. return document.getElementsByTagName('head')[0].appendChild(style);
  1691. }
  1692.  
  1693. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  1694.  
  1695.  
  1696. /*-----------------------------------------------常用API--------------------------------------------------*/
  1697.  
  1698. let HNAPI = {
  1699.  
  1700.  
  1701. getLotteryNotice: async function(dynamic_id) {
  1702. return new Promise((resolve) => {
  1703. Ajax.get({
  1704. url: BILIBLI_PATH.vcapi + '/lottery_svr/v1/lottery_svr/lottery_notice',
  1705. queryStringsObj: {
  1706. "dynamic_id": dynamic_id
  1707. },
  1708. hasCookies: true,
  1709. success: responseText => {
  1710. let res = HNTOOL.strToJson(responseText);
  1711. if (res.code === 0) {
  1712.  
  1713. resolve(res.data);
  1714.  
  1715. } else {
  1716. console.log("获取开奖信息失败:" + res.message);
  1717. resolve(false);
  1718. }
  1719. }
  1720. })
  1721. });
  1722. },
  1723.  
  1724.  
  1725. likeDynamic: async function(dynamic_id) {
  1726.  
  1727. return new Promise((resolve) => {
  1728. Ajax.post({
  1729. url: BILIBLI_PATH.vcapi + '/dynamic_like/v1/dynamic_like/thumb',
  1730. hasCookies: true,
  1731. dataType: 'application/x-www-form-urlencoded',
  1732. data: {
  1733. uid: Live_info.uid,
  1734. dynamic_id: dynamic_id,
  1735. up: 1,
  1736. csrf: Live_info.csrf_token
  1737. },
  1738. success: responseText => {
  1739. let res = HNTOOL.strToJson(responseText);
  1740. if (res.code === 0) {
  1741.  
  1742. javaex.tip({
  1743. content: "动态点赞成功!",
  1744. type: "success"
  1745. });
  1746.  
  1747. resolve(true);
  1748. } else {
  1749.  
  1750. console.log("动态点赞发生错误!" + res.message);
  1751.  
  1752. javaex.tip({
  1753. content: "动态点赞发生错误!" + res.message,
  1754. type: "error"
  1755. });
  1756.  
  1757. resolve(false);
  1758. }
  1759. }
  1760. })
  1761. });
  1762. },
  1763.  
  1764. repostDynamic: async function(dynamic_id) {
  1765.  
  1766. return new Promise((resolve) => {
  1767. Ajax.post({
  1768. url: BILIBLI_PATH.vcapi + '/dynamic_repost/v1/dynamic_repost/repost',
  1769. dataType: 'application/x-www-form-urlencoded',
  1770. hasCookies: true,
  1771. data: {
  1772. uid: Live_info.uid,
  1773. dynamic_id: dynamic_id,
  1774. content: HNTOOL.getRandomWordOfList(replyList),
  1775.  
  1776. csrf: Live_info.csrf_token
  1777. },
  1778. success: responseText => {
  1779. let res = HNTOOL.strToJson(responseText);
  1780. if (res.code === 0) {
  1781.  
  1782. javaex.tip({
  1783. content: "动态转发成功!",
  1784. type: "success"
  1785. });
  1786.  
  1787. resolve(true);
  1788. } else {
  1789.  
  1790. console.log("动态转发发生错误!" + res.message);
  1791.  
  1792. javaex.tip({
  1793. content: "动态转发发生错误!" + res.message,
  1794. type: "error"
  1795. });
  1796.  
  1797. resolve(false);
  1798. }
  1799. }
  1800. })
  1801. });
  1802. },
  1803.  
  1804. addReply: async function(oid, type) {
  1805.  
  1806. return new Promise((resolve) => {
  1807. Ajax.post({
  1808. url: BILIBLI_PATH.api + '/x/v2/reply/add',
  1809. dataType: 'application/x-www-form-urlencoded',
  1810. hasCookies: true,
  1811. data: {
  1812. "oid": oid,
  1813. "type": type, //11官方 17 加码
  1814. "ordering": 'heat',
  1815. "message": HNTOOL.getRandomWordOfList(replyList),
  1816. "jsonp": 'jsonp',
  1817. "csrf": Live_info.csrf_token
  1818. },
  1819. success: responseText => {
  1820. let res = HNTOOL.strToJson(responseText);
  1821. if (res.code === 0) {
  1822. console.log('自动评论成功');
  1823. resolve(0);
  1824. } else if (res.code === -404) {
  1825. console.log('自动评论原动态已删除');
  1826. resolve(0);
  1827. } else if (res.code === 12002) {
  1828. console.log('自动评论评论区已关闭');
  1829. resolve(0);
  1830. } else if (res.code === 12015) {
  1831. console.log('自动评论需要输入验证码');
  1832. resolve(1);
  1833. } else {
  1834. console.log('自动评论', `评论失败\n${responseText}`);
  1835. resolve(0);
  1836. }
  1837. }
  1838. })
  1839. });
  1840. },
  1841.  
  1842.  
  1843. setNotice: async function(notice) {
  1844.  
  1845. return new Promise((resolve) => {
  1846. Ajax.post({
  1847. url: BILIBLI_PATH.api + '/x/space/notice/set',
  1848. hasCookies: true,
  1849. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1850. data: {
  1851. notice: notice,
  1852. jsonp: 'jsonp',
  1853. csrf: Live_info.csrf_token
  1854. },
  1855. success: responseText => {
  1856. let res = HNTOOL.strToJson(responseText);
  1857. if (res.code === 0) {
  1858.  
  1859. javaex.tip({
  1860. content: "动态标记保存到个人公告成功!",
  1861. type: "success"
  1862. });
  1863.  
  1864. resolve(true);
  1865. } else {
  1866.  
  1867. javaex.tip({
  1868. content: res.message,
  1869. type: "error"
  1870. });
  1871.  
  1872. resolve(false);
  1873. }
  1874. }
  1875. })
  1876. });
  1877. },
  1878.  
  1879. getSpaceNotice: async function() {
  1880. return new Promise((resolve) => {
  1881. Ajax.get({
  1882. url: BILIBLI_PATH.api + '/x/space/notice',
  1883. queryStringsObj: {
  1884. "mid": Live_info.uid
  1885. },
  1886. hasCookies: true,
  1887. success: responseText => {
  1888. let res = HNTOOL.strToJson(responseText);
  1889. if (res.code === 0) {
  1890.  
  1891. resolve(res.data);
  1892.  
  1893. } else {
  1894. console.log("获取公告信息失败:" + res.message);
  1895. resolve(false);
  1896. }
  1897. }
  1898. })
  1899. });
  1900. },
  1901.  
  1902. getdynamicData: async function(dynamic_id_str) {
  1903. return new Promise((resolve) => {
  1904. Ajax.get({
  1905.  
  1906. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
  1907. queryStringsObj: {
  1908. "dynamic_id": dynamic_id_str
  1909. },
  1910. hasCookies: true,
  1911. success: responseText => {
  1912. let res = HNTOOL.strToJson(responseText);
  1913. if (res.code === 0) {
  1914.  
  1915. resolve(res.data);
  1916.  
  1917. } else {
  1918. console.log("获取动态信息失败:" + res.message);
  1919. resolve(false);
  1920. }
  1921. }
  1922. })
  1923. });
  1924. },
  1925.  
  1926. getAllFollow: async function() {
  1927. return new Promise((resolve) => {
  1928. Ajax.get({
  1929.  
  1930. url: BILIBLI_PATH.vcapi + '/feed/v1/feed/get_attention_list',
  1931. queryStringsObj: {
  1932. "uid": Live_info.uid
  1933. },
  1934. hasCookies: true,
  1935. success: responseText => {
  1936. let res = HNTOOL.strToJson(responseText);
  1937. if (res.code === 0) {
  1938.  
  1939. resolve(res.data.list);
  1940.  
  1941. } else {
  1942. console.log("查询失败!" + res.message);
  1943. resolve(false);
  1944. }
  1945. }
  1946. })
  1947. });
  1948. },
  1949.  
  1950. getCardByUID: async function(UID) {
  1951. return new Promise((resolve) => {
  1952. Ajax.get({
  1953.  
  1954. url: BILIBLI_PATH.api + '/x/web-interface/card',
  1955. queryStringsObj: {
  1956. "mid": UID
  1957. },
  1958. hasCookies: true,
  1959. success: responseText => {
  1960. let res = HNTOOL.strToJson(responseText);
  1961. if (res.code === 0) {
  1962.  
  1963. resolve(res.data.card);
  1964.  
  1965. } else {
  1966. console.log("查询失败!" + res.message);
  1967. resolve(false);
  1968. }
  1969. }
  1970. })
  1971. });
  1972. },
  1973.  
  1974.  
  1975. /**
  1976. *
  1977. *
  1978. */
  1979.  
  1980. getTodayDynamicList: async function(mid, indexStr) {
  1981. return new Promise((resolve) => {
  1982. Ajax.get({
  1983.  
  1984. url: BILIBLI_PATH.api + '/x/space/article',
  1985. queryStringsObj: {
  1986. "mid": 226257459,
  1987. "pn": 1,
  1988. "ps": 12,
  1989. "sort": 'publish_time'
  1990. },
  1991. hasCookies: true,
  1992. success: responseText => {
  1993. let res = HNTOOL.strToJson(responseText);
  1994. if (res.code === 0) {
  1995. let artlist = [];
  1996.  
  1997. for (let art of res.data.articles) {
  1998.  
  1999. //if (art.title.indexOf("抽奖合集") > -1) {
  2000. if (art.title.indexOf(indexStr) > -1) {
  2001.  
  2002. resolve(art);
  2003. break;
  2004. }
  2005. }
  2006. } else {
  2007.  
  2008.  
  2009. console.log("查询失败!" + res.message);
  2010. resolve(false);
  2011. }
  2012. }
  2013. })
  2014. });
  2015. },
  2016.  
  2017. getDataByLiveSid: async function(ids) {
  2018. return new Promise((resolve) => {
  2019. Ajax.get({
  2020.  
  2021. url: BILIBLI_PATH.api + '/x/activity/up/reserve/relation/info',
  2022. queryStringsObj: {
  2023. "ids": ids
  2024. },
  2025. hasCookies: true,
  2026. success: responseText => {
  2027. let res = HNTOOL.strToJson(responseText);
  2028. if (res.code === 0 && Object.keys(res.data.list).length != 0) {
  2029.  
  2030. resolve(res.data.list);
  2031. } else {
  2032.  
  2033. /* javaex.tip({
  2034. content: "查询失败!" + res.message,
  2035. type: "error"
  2036. }); */
  2037. console.log("查询失败!" + res.message);
  2038.  
  2039. resolve(false);
  2040. }
  2041. }
  2042. })
  2043. });
  2044. },
  2045.  
  2046. /**
  2047. * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
  2048. */
  2049. clickNow: async function() {
  2050. return new Promise((resolve) => {
  2051. Ajax.get({
  2052.  
  2053. url: BILIBLI_PATH.api + '/x/report/click/now',
  2054. queryStringsObj: {
  2055. jsonp: "jsonp"
  2056. },
  2057. hasCookies: true,
  2058. success: responseText => {
  2059. let res = HNTOOL.strToJson(responseText);
  2060. if (res.code === 0) {
  2061.  
  2062. javaex.tip({
  2063. content: "每日登录" + res.data.text,
  2064. type: "success"
  2065. });
  2066. resolve(true);
  2067.  
  2068. } else {
  2069.  
  2070. javaex.tip({
  2071. content: res.message,
  2072. type: "error"
  2073. });
  2074.  
  2075. resolve(false);
  2076. }
  2077. }
  2078. })
  2079. });
  2080. },
  2081.  
  2082. /**
  2083. * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
  2084. * @param {number} videoAid
  2085. */
  2086. addShare: async function(videoAid) {
  2087. return new Promise((resolve) => {
  2088. Ajax.post({
  2089. url: BILIBLI_PATH.api + '/x/web-interface/share/add',
  2090. hasCookies: true,
  2091. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2092. data: {
  2093. aid: videoAid,
  2094. csrf: Live_info.csrf_token
  2095. },
  2096. success: responseText => {
  2097. let res = HNTOOL.strToJson(responseText);
  2098. if (res.code === 0) {
  2099.  
  2100. javaex.tip({
  2101. content: "每日分享视频成功",
  2102. type: "success"
  2103. });
  2104.  
  2105. resolve(true);
  2106. } else {
  2107.  
  2108. javaex.tip({
  2109. content: res.message,
  2110. type: "error"
  2111. });
  2112.  
  2113. resolve(false);
  2114. }
  2115. }
  2116. })
  2117. });
  2118. },
  2119.  
  2120.  
  2121.  
  2122. /**
  2123. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  2124. * @param {number} videoAid
  2125. */
  2126. addArticleCoin: async function(cvID, mid) {
  2127. return new Promise((resolve) => {
  2128. Ajax.post({
  2129. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  2130. hasCookies: true,
  2131. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2132. data: {
  2133. aid: cvID,
  2134. upid: mid,
  2135. multiply: 2,
  2136. avtype: 2,
  2137. csrf: Live_info.csrf_token
  2138. },
  2139. success: responseText => {
  2140. let res = HNTOOL.strToJson(responseText);
  2141. if (res.code === 0) {
  2142.  
  2143. javaex.tip({
  2144. content: '专栏:' + cvID + "投币成功",
  2145. type: "success"
  2146. });
  2147.  
  2148. resolve(true);
  2149. } else {
  2150.  
  2151. javaex.tip({
  2152. content: res.message,
  2153. type: "error"
  2154. });
  2155.  
  2156. console.log('专栏投币失败:' + cvID + res.message);
  2157.  
  2158. resolve(false);
  2159. }
  2160. }
  2161. })
  2162. });
  2163. },
  2164.  
  2165. /**
  2166. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  2167. * @param {number} videoAid
  2168. */
  2169. addVideoCoin: async function(videoAid) {
  2170. return new Promise((resolve) => {
  2171. Ajax.post({
  2172. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  2173. hasCookies: true,
  2174. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2175. data: {
  2176. aid: videoAid,
  2177. multiply: 2,
  2178. select_like: 0,
  2179. cross_domain: true,
  2180. csrf: Live_info.csrf_token
  2181. },
  2182. success: responseText => {
  2183. let res = HNTOOL.strToJson(responseText);
  2184. if (res.code === 0) {
  2185.  
  2186. javaex.tip({
  2187. content: "投币成功",
  2188. type: "success"
  2189. });
  2190.  
  2191. resolve(true);
  2192. } else {
  2193.  
  2194. javaex.tip({
  2195. content: res.message,
  2196. type: "error"
  2197. });
  2198.  
  2199. resolve(false);
  2200. }
  2201. }
  2202. })
  2203. });
  2204. },
  2205.  
  2206.  
  2207. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  2208.  
  2209. DoSign: async function() {
  2210. return new Promise((resolve) => {
  2211. Ajax.get({
  2212.  
  2213. url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
  2214. queryStringsObj: {
  2215.  
  2216. },
  2217. hasCookies: true,
  2218. success: responseText => {
  2219. let res = HNTOOL.strToJson(responseText);
  2220. if (res.code === 0) {
  2221.  
  2222. javaex.tip({
  2223. content: "签到成功:" + res.data.text,
  2224. type: "success"
  2225. });
  2226. resolve(true);
  2227.  
  2228. } else if (res.code === 1011040) {
  2229.  
  2230. javaex.tip({
  2231. content: res.message,
  2232. type: "success"
  2233. });
  2234.  
  2235. resolve(true);
  2236. } else {
  2237.  
  2238. javaex.tip({
  2239. content: res.message,
  2240. type: "error"
  2241. });
  2242.  
  2243. resolve(false);
  2244. }
  2245. }
  2246. })
  2247. });
  2248. },
  2249.  
  2250.  
  2251. /**
  2252. * // 获取分区最新专栏列表 https://api.bilibili.com/x/article/recommends?cid=0&pn=1
  2253. */
  2254. getArticleRecommends: async function() {
  2255. return new Promise((resolve) => {
  2256. Ajax.get({
  2257.  
  2258. url: BILIBLI_PATH.api + '/x/article/recommends',
  2259. queryStringsObj: {
  2260. "cid": 0,
  2261. "pn": 1
  2262. },
  2263. hasCookies: true,
  2264. success: responseText => {
  2265. let res = HNTOOL.strToJson(responseText);
  2266. if (res.code === 0) {
  2267.  
  2268. javaex.tip({
  2269. content: "获取最新专栏成功!",
  2270. type: "success"
  2271. });
  2272. resolve(res.data);
  2273.  
  2274. } else {
  2275.  
  2276. javaex.tip({
  2277. content: "获取最新专栏失败!" + res.message,
  2278. type: "error"
  2279. });
  2280.  
  2281. console.log(res.message);
  2282.  
  2283. resolve(false);
  2284. }
  2285. }
  2286. })
  2287. });
  2288. },
  2289. /**
  2290. * // 获取分区最新视频列表
  2291. */
  2292. getDynamicRegion: async function() {
  2293. return new Promise((resolve) => {
  2294. Ajax.get({
  2295.  
  2296. url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
  2297. queryStringsObj: {
  2298. "pn": 1,
  2299. "ps": 20,
  2300. "rid": 21
  2301. },
  2302. hasCookies: true,
  2303. success: responseText => {
  2304. let res = HNTOOL.strToJson(responseText);
  2305. if (res.code === 0) {
  2306.  
  2307. javaex.tip({
  2308. content: "获取分区最新视频成功",
  2309. type: "success"
  2310. });
  2311. resolve(res.data.archives);
  2312.  
  2313. } else {
  2314.  
  2315. javaex.tip({
  2316. content: "获取分区最新视频失败" + res.message,
  2317. type: "error"
  2318. });
  2319.  
  2320. resolve(false);
  2321. }
  2322. }
  2323. })
  2324. });
  2325. },
  2326.  
  2327. /*
  2328. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  2329. * @param {Object} sid
  2330. */
  2331. reserveActivity: async function(sid) {
  2332. return new Promise((resolve) => {
  2333. Ajax.post({
  2334. url: BILIBLI_PATH.api + '/x/space/reserve',
  2335. hasCookies: true,
  2336. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2337. data: {
  2338. sid: sid, //当前用户
  2339. jsonp: "jsonp",
  2340. csrf: Live_info.csrf_token
  2341. },
  2342. success: responseText => {
  2343. let res = HNTOOL.strToJson(responseText);
  2344. if (res.code === 0) {
  2345.  
  2346. resolve(true);
  2347. } else {
  2348. javaex.tip({
  2349. content: res.message,
  2350. type: "error"
  2351. });
  2352. resolve(false);
  2353. }
  2354. }
  2355. })
  2356. });
  2357. },
  2358. /**
  2359. reserveActivity: async function(sid, reserve_total) {
  2360. return new Promise((resolve) => {
  2361. Ajax.post({
  2362. url: BILIBLI_PATH.vcapi + '/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
  2363. hasCookies: true,
  2364. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2365. data: {
  2366. reserve_id: sid,
  2367. cur_btn_status: 1,
  2368. reserve_total: reserve_total,
  2369. csrf: Live_info.csrf_token
  2370. },
  2371. success: responseText => {
  2372. let res = HNTOOL.strToJson(responseText);
  2373. if (res.code === 0) {
  2374.  
  2375. resolve(res.data);
  2376. } else {
  2377.  
  2378. javaex.tip({
  2379. content: res.message,
  2380. type: "error"
  2381. });
  2382.  
  2383. resolve(false);
  2384. }
  2385. }
  2386. })
  2387. });
  2388. }, */
  2389.  
  2390. getGiftList: async function(room) {
  2391. return new Promise((resolve) => {
  2392. Ajax.get({
  2393.  
  2394. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  2395. queryStringsObj: {
  2396. "room_id": room
  2397. },
  2398. hasCookies: true,
  2399. success: responseText => {
  2400. let res = HNTOOL.strToJson(responseText);
  2401. if (res.code === 0) {
  2402.  
  2403. resolve(res.data.list);
  2404. } else {
  2405.  
  2406. javaex.tip({
  2407. content: "查询包裹失败!" + res.message,
  2408. type: "error"
  2409. });
  2410.  
  2411. resolve(false)
  2412. }
  2413. }
  2414. })
  2415. });
  2416. },
  2417.  
  2418. /**
  2419. * 送银B克拉
  2420. * @param {Object} ruid
  2421. * @param {Object} roomid
  2422. */
  2423. bagSendGift: async function(ruid, roomid, bag_id) {
  2424. return new Promise((resolve) => {
  2425. Ajax.post({
  2426. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  2427. hasCookies: true,
  2428. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2429. data: {
  2430. uid: Live_info.uid, //当前用户
  2431. gift_id: 3,
  2432. ruid: ruid,
  2433. send_ruid: 0,
  2434. gift_num: 1,
  2435. bag_id: bag_id,
  2436. //rnd: Math.round(new Date() / 1000); //时间戳,
  2437. platform: 'pc',
  2438. biz_code: 'Live',
  2439. biz_id: roomid,
  2440. storm_beat_id: 0,
  2441. price: 0,
  2442. csrf_token: Live_info.csrf_token,
  2443. csrf: Live_info.csrf_token
  2444.  
  2445. },
  2446. success: responseText => {
  2447. let res = HNTOOL.strToJson(responseText);
  2448. if (res.code === 0) {
  2449.  
  2450. javaex.tip({
  2451. content: roomid + "赠送b克拉成功!" + res.message,
  2452. type: "success"
  2453. });
  2454.  
  2455. resolve(true);
  2456. } else {
  2457.  
  2458. javaex.tip({
  2459. content: res.message,
  2460. type: "error"
  2461. });
  2462.  
  2463. resolve(false);
  2464. }
  2465. }
  2466. })
  2467. });
  2468. },
  2469.  
  2470.  
  2471. /**
  2472. * 判断是否有勋章
  2473. * @param {Object} uid
  2474. * @param {Object} room
  2475. */
  2476.  
  2477. getFansMedalInfo: async function(uid, room) {
  2478. return new Promise((resolve) => {
  2479. Ajax.get({
  2480.  
  2481. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  2482. queryStringsObj: {
  2483. "target_id": uid,
  2484. "room_id": room
  2485. },
  2486. //dataType:'application/json, text/plain, */*',
  2487. hasCookies: true,
  2488. success: responseText => {
  2489. let res = HNTOOL.strToJson(responseText);
  2490. if (res.code === 0) {
  2491.  
  2492. if (res.data.my_fans_medal.level == 0) {
  2493. resolve(false)
  2494. } else {
  2495. resolve(true)
  2496. }
  2497.  
  2498. } else {
  2499.  
  2500. javaex.tip({
  2501. content: "查询勋章失败!" + res.message,
  2502. type: "error"
  2503. });
  2504.  
  2505. resolve(false)
  2506. }
  2507. }
  2508. })
  2509. });
  2510. },
  2511.  
  2512.  
  2513.  
  2514.  
  2515. getDisuidList: async function(re_version, pn) {
  2516. return new Promise((resolve) => {
  2517. Ajax.get({
  2518.  
  2519. url: BILIBLI_PATH.api + '/x/relation/blacks',
  2520. queryStringsObj: {
  2521. "re_version": re_version,
  2522. "pn": pn
  2523. },
  2524. hasCookies: true,
  2525. success: responseText => {
  2526. let res = HNTOOL.strToJson(responseText);
  2527. if (res.code === 0) {
  2528. resolve(res.data.list)
  2529. } else {
  2530.  
  2531. javaex.tip({
  2532. content: "查询黑名单失败!" + res.message,
  2533. type: "error"
  2534. });
  2535.  
  2536. resolve(null)
  2537. }
  2538. }
  2539. })
  2540. });
  2541. },
  2542.  
  2543. /**
  2544. * @param {Object} uid
  2545. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  2546. */
  2547. cancelAtt: async function(uid, act, re_src) {
  2548. return new Promise((resolve) => {
  2549. Ajax.post({
  2550. url: BILIBLI_PATH.api + '/x/relation/modify',
  2551. hasCookies: true,
  2552. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2553. data: {
  2554. fid: uid,
  2555. act: act,
  2556. re_src: re_src == undefined ? 11 : 116,
  2557. jsonp: "jsonp",
  2558. csrf: Live_info.csrf_token,
  2559. },
  2560. success: responseText => {
  2561. let res = HNTOOL.strToJson(responseText);
  2562. if (res.code === 0) {
  2563.  
  2564. //HNAPI.cancelAtt(uid, 6);
  2565.  
  2566. javaex.tip({
  2567. content: "取关成功!" + res.message,
  2568. type: "success"
  2569. });
  2570.  
  2571. resolve(true);
  2572. } else if (res.code === 22003) {
  2573.  
  2574. HNAPI.cancelAtt(uid, 6);
  2575.  
  2576. javaex.tip({
  2577. content: "取消拉黑" + res.message,
  2578. type: "success"
  2579. });
  2580. resolve(true);
  2581. } else {
  2582.  
  2583. javaex.tip({
  2584. content: res.message,
  2585. type: "error"
  2586. });
  2587.  
  2588. resolve(false);
  2589. }
  2590. }
  2591. })
  2592. });
  2593. },
  2594.  
  2595. getRoomMsg: async function(roomid) {
  2596. return new Promise((resolve) => {
  2597. Ajax.get({
  2598.  
  2599. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  2600. queryStringsObj: {
  2601. "roomid": roomid
  2602. },
  2603. hasCookies: true,
  2604. success: responseText => {
  2605. let res = HNTOOL.strToJson(responseText);
  2606. if (res.code === 0) {
  2607. resolve(res.data.info.uid)
  2608. } else {
  2609. resolve(false)
  2610. }
  2611. }
  2612. })
  2613. });
  2614. },
  2615.  
  2616. /**
  2617. *
  2618. * @param sid
  2619. * @returns {Promise<unknown>}
  2620. */
  2621. lotteryDo: async function(sid) {
  2622. return new Promise((resolve) => {
  2623. Ajax.post({
  2624. url: BILIBLI_PATH.api + '/x/activity/lottery/do',
  2625. hasCookies: true,
  2626. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2627. data: {
  2628.  
  2629. sid: sid,
  2630. type: 1,
  2631. csrf: Live_info.csrf_token,
  2632. },
  2633. success: responseText => {
  2634. let res = HNTOOL.strToJson(responseText);
  2635. if (res.code === 0) {
  2636. resolve((res.data)[0].gift_name);
  2637.  
  2638. } else if (res.code === 75400) {
  2639.  
  2640. resolve(true);
  2641. } else {
  2642. javaex.tip({
  2643. content: "本次抽奖失败!" + res.message,
  2644. type: "error"
  2645. });
  2646. resolve(false);
  2647. }
  2648. }
  2649. })
  2650. });
  2651. },
  2652.  
  2653.  
  2654. getLotteryMytimes: async function(sid) {
  2655. return new Promise((resolve) => {
  2656. Ajax.get({
  2657. url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
  2658. queryStringsObj: {
  2659. sid: sid
  2660. },
  2661. hasCookies: true,
  2662. success: responseText => {
  2663. let res = HNTOOL.strToJson(responseText);
  2664. if (res.code === 0) {
  2665. resolve(res.data.times)
  2666. } else {
  2667. resolve(0)
  2668. }
  2669. }
  2670. })
  2671. });
  2672. },
  2673.  
  2674. /**
  2675. * 增加抽奖次数一般是分享
  2676. * @param sid 活动sid
  2677. * @returns {Promise<unknown>} 0 成功 1:活动结束
  2678. */
  2679. addLotteryTimes: async function(sid) {
  2680. return new Promise((resolve) => {
  2681. Ajax.post({
  2682. url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
  2683. hasCookies: true,
  2684. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2685. data: {
  2686.  
  2687. sid: sid,
  2688. action_type: 3,
  2689. csrf: Live_info.csrf_token,
  2690. },
  2691. success: responseText => {
  2692. let res = HNTOOL.strToJson(responseText);
  2693. if (res.code === 0) {
  2694.  
  2695. resolve(0)
  2696. } else if (res.code === 75003) {
  2697.  
  2698. resolve(1)
  2699.  
  2700. } else {
  2701.  
  2702. resolve(res.message);
  2703. }
  2704. }
  2705. })
  2706. });
  2707. },
  2708. /**
  2709. * 查询用户关注 默认一次查询50
  2710. * @param vmid 用户uid
  2711. * @param pn 页码
  2712. * @returns {Promise<unknown>}
  2713. */
  2714. getMyFollow: async function(vmid, pn) {
  2715. return new Promise((resolve) => {
  2716. Ajax.get({
  2717. url: BILIBLI_PATH.api + '/x/relation/followings',
  2718. queryStringsObj: {
  2719. vmid: vmid,
  2720. pn: pn
  2721. },
  2722. hasCookies: true,
  2723. success: responseText => {
  2724. let res = HNTOOL.strToJson(responseText);
  2725. if (res.code === 0) {
  2726. resolve(res.data)
  2727. } else {
  2728. resolve(null)
  2729. }
  2730. }
  2731. })
  2732. });
  2733. },
  2734.  
  2735.  
  2736. getMyinfo: function() {
  2737. return new Promise((resolve) => {
  2738. Ajax.get({
  2739. url: BILIBLI_PATH.api + '/x/space/myinfo',
  2740. queryStringsObj: {},
  2741. hasCookies: true,
  2742. success: responseText => {
  2743. let res = HNTOOL.strToJson(responseText);
  2744. if (res.code === 0) {
  2745. resolve(res.data)
  2746. } else {
  2747. resolve(null)
  2748. }
  2749. }
  2750. })
  2751. });
  2752. },
  2753.  
  2754. getMyJson: function(url) {
  2755. return new Promise((resolve) => {
  2756. GM_xmlhttpRequest({
  2757. method: "GET",
  2758. url: url,
  2759. onload: function(response) {
  2760. const res = HNTOOL.strToJson((response || {}).responseText)
  2761. resolve(res);
  2762. }
  2763. });
  2764. })
  2765. },
  2766.  
  2767.  
  2768. userInfo: function(mid) {
  2769.  
  2770. Ajax.get({
  2771. url: BILIBLI_PATH.api + '/x/space/acc/info',
  2772. queryStringsObj: {
  2773. mid: mid
  2774. },
  2775. hasCookies: true,
  2776. success: responseText => {
  2777.  
  2778. var json = JSON.parse(responseText);
  2779.  
  2780. if (json.code != 0) {
  2781.  
  2782.  
  2783. }
  2784. }
  2785. });
  2786.  
  2787. },
  2788.  
  2789. sendQmsg: async function(key, msg) {
  2790.  
  2791. $.ajax({
  2792. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  2793.  
  2794. success: function(result) {
  2795.  
  2796. }
  2797. });
  2798.  
  2799.  
  2800. /*GM_xmlhttpRequest({
  2801. method: "GET",
  2802. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  2803. onload: function (response) {
  2804.  
  2805. let json = JSON.parse(response.response);
  2806. if (json.code == 0) {
  2807.  
  2808. javaex.tip({
  2809. content: "自动动态中奖提醒成功!" + json.reason,
  2810. type: "success"
  2811. });
  2812. } else {
  2813. console.log("自动动态中奖提醒失败!" + json.reason);
  2814. javaex.tip({
  2815. content: "自动动态中奖提醒失败!" + json.reason,
  2816. type: "error"
  2817. });
  2818. }
  2819.  
  2820. }
  2821. });*/
  2822.  
  2823. },
  2824.  
  2825. /**
  2826. * 批量关注和拉黑 batchModify
  2827. *
  2828. * https://api.bilibili.com/x/relation/batch/modify
  2829. * @param uid
  2830. */
  2831.  
  2832. batchModify: function(uids, act) {
  2833.  
  2834.  
  2835. Ajax.post({
  2836. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  2837. hasCookies: true,
  2838. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2839. data: {
  2840.  
  2841. "fids": uids,
  2842. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  2843. "re_src": 151,
  2844. csrf: Live_info.csrf_token,
  2845. },
  2846. success: responseText => {
  2847.  
  2848. let json = JSON.parse(responseText);
  2849.  
  2850. if (/^{"code":0/.test(responseText)) {
  2851.  
  2852. javaex.tip({
  2853. content: `执行成功!---失败(` + json.data.failed_fids.length + `/15)名单:` + json.data.failed_fids,
  2854. type: "success"
  2855. });
  2856.  
  2857. } else {
  2858. javaex.tip({
  2859. content: "关注失败!" + json.message,
  2860. type: "error"
  2861. });
  2862. }
  2863. }
  2864. })
  2865. },
  2866.  
  2867.  
  2868. /**
  2869. * //https://api.bilibili.com/x/relation/modify
  2870. *
  2871. * @param UID
  2872. */
  2873. disUserByUid: function(vmid) {
  2874.  
  2875. Ajax.post({
  2876. url: BILIBLI_PATH.api + '/x/relation/modify',
  2877. data: {
  2878. fid: parseInt(vmid),
  2879. re_src: 11,
  2880. act: 5,
  2881. jsonp: "jsonp",
  2882. csrf: Live_info.csrf_token,
  2883. },
  2884. hasCookies: true,
  2885. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2886. success: responseText => {
  2887.  
  2888. var json = JSON.parse(responseText);
  2889.  
  2890. if (json.code != 0) {
  2891.  
  2892. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  2893. javaex.tip({
  2894. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  2895. type: "error"
  2896. });
  2897.  
  2898. } else {
  2899. console.log("拉黑用户成功 uid:" + vmid);
  2900. javaex.tip({
  2901. content: "拉黑用户成功 uid:" + vmid,
  2902. type: "success"
  2903. });
  2904. }
  2905. }
  2906. });
  2907.  
  2908. },
  2909. /**
  2910. * http://api.bilibili.com/x/web-interface/view
  2911. * @param BV
  2912. * 心跳间隔15秒
  2913. */
  2914. playOneVideo: function(BV, MID) {
  2915.  
  2916. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  2917. Ajax.post({
  2918. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  2919. hasCookies: true,
  2920. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2921. data: {
  2922.  
  2923. "bvid": BV,
  2924. "part": 1,
  2925. "mid": Live_info.uid,
  2926. "lv": 2,
  2927. "jsonp": "jsonp",
  2928. "type": 3,
  2929. "sub_type": 0
  2930. },
  2931. success: responseText => {
  2932.  
  2933. let json = JSON.parse(responseText);
  2934.  
  2935. if (/^{"code":0/.test(responseText)) {
  2936. //发送一次心跳
  2937. HNAPI.sendHeartbeat(BV, MID);
  2938.  
  2939. } else {
  2940. javaex.tip({
  2941. content: "视频" + data.bvid + "播放失败!" + json.message,
  2942. type: "error"
  2943. });
  2944. }
  2945. }
  2946. })
  2947.  
  2948.  
  2949. },
  2950.  
  2951. //上报视频播放心跳(web端)
  2952. /**
  2953. * http://api.bilibili.com/x/click-interface/web/heartbeat
  2954. * @param json
  2955. */
  2956. sendHeartbeat: function(bvid, MID) {
  2957.  
  2958. Ajax.post({
  2959. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  2960. hasCookies: true,
  2961. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2962. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  2963. data: {
  2964. "bvid": bvid,
  2965. "type": 3,
  2966. "dt": 2,
  2967. "played_time": HNTOOL.random(12, 40),
  2968. "realtime": HNTOOL.random(12, 40),
  2969. "play_type": 0
  2970. },
  2971. success: responseText => {
  2972.  
  2973. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  2974.  
  2975. javaex.tip({
  2976. content: "视频BV" + bvid + "播放一次!",
  2977. type: "success"
  2978. });
  2979. }
  2980. }
  2981. })
  2982.  
  2983. },
  2984.  
  2985. //获取up所有投稿视频
  2986. /**
  2987. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  2988. * @param mid
  2989. */
  2990. getUpAllBV: function(mid, pn, ps) {
  2991. ps = (ps === undefined ? 30 : ps); // a默认值为1
  2992. Ajax.get({
  2993. url: BILIBLI_PATH.api + '/x/space/arc/search',
  2994. queryStringsObj: {
  2995. mid: mid,
  2996. tid: 0,
  2997. order: 'pubdate',
  2998. jsonp: 'jsonp',
  2999. pn: pn,
  3000. ps: ps
  3001. },
  3002. hasCookies: true,
  3003. success: responseText => {
  3004.  
  3005. var json = JSON.parse(responseText);
  3006.  
  3007. if (json.code != 0) {
  3008.  
  3009. javaex.tip({
  3010. content: "获取up所有投稿视频失败!" + json.message,
  3011. type: "success"
  3012. });
  3013.  
  3014. } else {
  3015. BiliData.BVList = json.data.list.vlist;
  3016.  
  3017. }
  3018. }
  3019. });
  3020.  
  3021. },
  3022.  
  3023.  
  3024. /**
  3025. *
  3026. * @param path
  3027. * @param data
  3028. * @param saveObj
  3029. * @param Func
  3030. */
  3031. publicGet: function(path, queryStringsObj) {
  3032.  
  3033. if (typeof(queryStringsObj) != "undefined") {
  3034. queryStringsObj = {};
  3035. }
  3036. Ajax.get({
  3037. url: BILIBLI_PATH.api + path,
  3038. queryStringsObj: queryStringsObj,
  3039. hasCookies: true,
  3040. success: responseText => {
  3041.  
  3042. let json = JSON.parse(responseText);
  3043. if (chackCode(json.code) && json.code == 0) {
  3044.  
  3045. return json.data;
  3046. }
  3047.  
  3048. return false;
  3049.  
  3050. }
  3051. })
  3052.  
  3053. },
  3054.  
  3055. /**
  3056. * 导航栏用户信息
  3057. */
  3058. getUserNav: async function() {
  3059.  
  3060. GM_xmlhttpRequest({
  3061. method: "GET",
  3062. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  3063. //timeout:3000,
  3064. onload: function(response) {
  3065.  
  3066. let json = JSON.parse(response.response);
  3067. console.log(json);
  3068. BiliData.login_code = json.code;
  3069. BiliData.login_message = json.message;
  3070. BiliData.LoginData = json.data;
  3071.  
  3072. }
  3073. });
  3074.  
  3075. },
  3076.  
  3077. /**
  3078. * 获取某up详细信息
  3079. * http://api.bilibili.com/x/web-interface/card
  3080. */
  3081. getUpCard: function(mid) {
  3082.  
  3083. Ajax.get({
  3084. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3085. queryStringsObj: {
  3086. mid: mid,
  3087. photo: false
  3088. },
  3089. hasCookies: true,
  3090. success: responseText => {
  3091.  
  3092. var json = JSON.parse(responseText);
  3093.  
  3094. if (json.code != 0) {
  3095.  
  3096. javaex.tip({
  3097. content: "查询失败!" + json.message,
  3098. type: "success"
  3099. });
  3100. return false;
  3101. } else {
  3102. BiliData.upCard = json;
  3103.  
  3104. }
  3105.  
  3106.  
  3107. }
  3108. })
  3109.  
  3110. },
  3111.  
  3112. /**
  3113. *
  3114. * @param uid 用户uid
  3115. * @param ps 每页视频个数 默认30个
  3116. * @param pn 第几页
  3117. */
  3118. getUpAllVideo: function(uid, ps, pn) {
  3119.  
  3120. },
  3121. getChallenge: async function() {
  3122.  
  3123.  
  3124. },
  3125. /**
  3126. * 硬币记录
  3127. * @returns {Promise<void>}
  3128. */
  3129. getCoinLog: async function() {
  3130.  
  3131. GM_xmlhttpRequest({
  3132. method: "GET",
  3133. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  3134. //url: "http://api.bilibili.com/x/member/web/coin/log",
  3135. onload: function(response) {
  3136.  
  3137. let json = JSON.parse(response.response);
  3138. if (json.code == 0) {
  3139.  
  3140. console.log("硬币记录" + json);
  3141. BiliData.CoinLog = json.data;
  3142.  
  3143. return true;
  3144. }
  3145.  
  3146. }
  3147. });
  3148. },
  3149. /**
  3150. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  3151. * @returns {Promise<void>}
  3152. */
  3153. getUnread: async function() {
  3154.  
  3155. Ajax.get({
  3156. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  3157. hasCookies: true,
  3158. success: responseText => {
  3159.  
  3160. let json = JSON.parse(responseText);
  3161. if (chackCode(json.code) && json.code == 0) {
  3162.  
  3163. BiliData.Unread = json.data;
  3164. showUnreadMsg();
  3165. }
  3166.  
  3167. return false;
  3168.  
  3169. }
  3170. })
  3171.  
  3172. /* GM_xmlhttpRequest({
  3173. method: "GET",
  3174. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  3175. onload: function (response) {
  3176.  
  3177. let json = JSON.parse(response.response);
  3178.  
  3179. if (chackCode(json.code) && json.code == 0) {
  3180.  
  3181. BiliData.Unread = json.code;
  3182. showUnreadMsg();
  3183.  
  3184. }
  3185.  
  3186. }
  3187. });*/
  3188. },
  3189. /**
  3190. *
  3191. * @param type reply:回复我的 at @我的
  3192. */
  3193. getMsgfeed: function(type) {
  3194. Ajax.get({
  3195. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  3196. queryStringsObj: {
  3197. build: 0,
  3198. mobi_app: 'web'
  3199. },
  3200. hasCookies: true,
  3201. success: responseText => {
  3202.  
  3203. var json = JSON.parse(responseText);
  3204.  
  3205. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  3206. return false;
  3207. } else {
  3208. chackAtMsg(json.data.items);
  3209.  
  3210. return true;
  3211. }
  3212.  
  3213.  
  3214. }
  3215. })
  3216.  
  3217. },
  3218.  
  3219. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  3220. * @returns {Promise<void>}
  3221. */
  3222. getUnrewad: async function() {
  3223.  
  3224. GM_xmlhttpRequest({
  3225. method: "GET",
  3226. data: {
  3227. "mid": 99439379,
  3228. "pn": 1,
  3229. "ps": 5,
  3230. },
  3231. url: BILIBLI_PATH.api + "/x/space/arc/search",
  3232. onload: function(response) {
  3233.  
  3234. let json = JSON.parse(response.response);
  3235. if (json.code == 0) {
  3236.  
  3237. BiliData.Video = json.data;
  3238. console.log("未读消息数" + json);
  3239. }
  3240.  
  3241. }
  3242. });
  3243. },
  3244.  
  3245. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  3246. * @param {number} oid
  3247. * @param {nbumber} rpid
  3248. * @param {number} action
  3249. * @returns {Promise<void>}
  3250. * type: 11
  3251. * ordering: heat
  3252. * jsonp: jsonp
  3253. * csrf: 54a******* CSRF Token(位于cookie)
  3254. */
  3255.  
  3256. likeInDynamicComments: async function(latestDynamic) {
  3257.  
  3258.  
  3259. Ajax.post({
  3260. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  3261. hasCookies: true,
  3262. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3263. data: {
  3264. "oid": oid,
  3265. "type": 11,
  3266. "rpid": rpid,
  3267. "action": action,
  3268. "ordering": "heat",
  3269. "jsonp": "jsonp",
  3270. "csrf": Live_info.csrf_token,
  3271. },
  3272. success: responseText => {
  3273.  
  3274. if (/^{"code":0/.test(responseText)) {
  3275.  
  3276. BiliData.replyAction = JSON.parse(responseText);
  3277. console.log("点赞成功!" + responseText);
  3278. }
  3279. }
  3280. })
  3281.  
  3282. }
  3283.  
  3284.  
  3285. }
  3286.  
  3287. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  3288. var http_request = null;
  3289.  
  3290. function send_request(url, method) {}
  3291.  
  3292. let HNTOOL = {
  3293.  
  3294. getLatestDynamic: async function() {
  3295.  
  3296. let date = new Date();
  3297. let thisdate = date.getMonth() + 1 + "月" + date.getDate() < 10 ? '0' + date.getDate() : date.getDate() +
  3298. "日";
  3299. let latestDynamic = await HNAPI.getTodayDynamicList(226257459, thisdate);
  3300. let latestDynamic2 = await HNAPI.getTodayDynamicList(226257459, "抽奖合集");
  3301.  
  3302. let ld1 = await HNTOOL.getDynamicIdList(latestDynamic);
  3303. let ld2 = await HNTOOL.getDynamicIdList(latestDynamic2);
  3304.  
  3305. return HNTOOL.arrUnique(ld1.concat(ld2), false);
  3306.  
  3307.  
  3308. },
  3309.  
  3310. getDynamicIdList: async function(latestDynamic) {
  3311.  
  3312.  
  3313. let returnlist = [];
  3314. return new Promise((resolve) => {
  3315. Ajax.get({
  3316. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  3317. queryStringsObj: {},
  3318. dataType: "html",
  3319. hasCookies: false,
  3320. success: responseText => {
  3321. let datalist = HNTOOL.httpString(responseText);
  3322. let dls;
  3323. for (let dl of datalist) {
  3324.  
  3325. let len = dl.indexOf("?");
  3326. if (len == -1) {
  3327. dl += "?tab=2";
  3328. }
  3329. dls = dl.substring(dl.indexOf("?") - 18, dl.indexOf("?"));
  3330. if (returnlist.indexOf(dls) > -1 || dls == null || dl.indexOf("read") > -1 || dl.indexOf("html") > -1) {
  3331. continue;
  3332. }
  3333. /* let len = dl.indexOf("?");
  3334. if (len > -1) {
  3335. dls = dl.substring(len - 18, len);
  3336. }
  3337.  
  3338. if (dl.indexOf("tab") == -1 || returnlist.indexOf(dls) > -1 || dls == null) {
  3339. continue;
  3340. } */
  3341. returnlist.push(dls);
  3342.  
  3343. }
  3344. resolve(HNTOOL.arrUnique(returnlist, false));
  3345.  
  3346. if (datalist.length == 0) {
  3347. resolve(false);
  3348. }
  3349. }
  3350. })
  3351. });
  3352. },
  3353.  
  3354.  
  3355. /* getDynamicIdList: async function() {
  3356.  
  3357.  
  3358. let latestDynamic = await HNAPI.getTodayDynamicList();
  3359. let returnlist = [];
  3360. $.ajax({
  3361. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  3362. dataType: "html",
  3363. success: function(data) {
  3364. let datalist = HNTOOL.httpString(data);
  3365.  
  3366. let dls;
  3367. for (let dl of datalist) {
  3368. let len = dl.indexOf("?");
  3369. if (len > -1) {
  3370. dls = dl.substring(len - 18, len);
  3371. }
  3372.  
  3373. if (dl.indexOf("tab") == -1 || returnlist.indexOf(dls) > -1 || dls == null) {
  3374. continue;
  3375. }
  3376. //https://t.bilibili.com/552091391342505523?tab=22
  3377. returnlist.push(dls);
  3378.  
  3379. }
  3380.  
  3381. return returnlist;
  3382. }
  3383. });
  3384.  
  3385. }, */
  3386.  
  3387.  
  3388.  
  3389. httpString: function(s) {
  3390. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  3391. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  3392. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3393. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3394. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  3395. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  3396. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  3397. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  3398. s = s.match(reg);
  3399. console.log(s)
  3400. return (s)
  3401. },
  3402.  
  3403. saveConfig: function() {
  3404.  
  3405. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  3406. javaex.tip({
  3407. content: "配置保存成功!",
  3408. type: "success"
  3409. });
  3410.  
  3411. },
  3412.  
  3413. copyText: function(domId) {
  3414. let btn = document.getElementById(domId);
  3415. btn.select();
  3416. if (document.execCommand('copy')) {
  3417. document.execCommand('copy');
  3418. javaex.tip({
  3419. content: "复制成功!",
  3420. type: "success"
  3421. });
  3422. }
  3423.  
  3424. },
  3425. /**
  3426. * s数组去重并排序
  3427. */
  3428.  
  3429. arrUnique: function(ary, isSort) {
  3430.  
  3431. if (isSort == undefined) {
  3432. isSort = true
  3433. }
  3434. let obj = {};
  3435. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  3436. let item = ary[i]
  3437. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  3438. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  3439. // 如果没有 将这个元素添加到对象中
  3440. if (isSort) {
  3441. ary.sort((a, b) => {
  3442. return a - b
  3443. }) // 数组去重后 按升序排列
  3444. }
  3445.  
  3446. obj = null;
  3447.  
  3448. javaex.tip({
  3449. content: "已去重!",
  3450. type: "success"
  3451. });
  3452. return ary;
  3453.  
  3454. },
  3455.  
  3456. split_array: function(arr, len) {
  3457.  
  3458. let arr_length = arr.length;
  3459. let newArr = [];
  3460. for (let i = 0; i < arr_length; i += len) {
  3461. newArr.push(arr.slice(i, i + len));
  3462. }
  3463. return newArr;
  3464. },
  3465. strToJson: function(params) {
  3466. const isJSON = (str => {
  3467. if (typeof str === 'string') {
  3468. try {
  3469. const obj = JSON.parse(str);
  3470. return typeof obj === 'object' ? obj : false
  3471. } catch (_) {
  3472. console.log(str);
  3473. return false;
  3474. }
  3475. } else {
  3476. console.log(`${str}\nIt is not a string!`);
  3477. return false;
  3478. }
  3479. })(params);
  3480. return isJSON ? isJSON : {}
  3481. },
  3482.  
  3483. chackAtMsg: function() {
  3484.  
  3485. let config = HNTOOL.getConfig();
  3486. if (config.qmsg_checked == true && config.qmsg_key) {
  3487.  
  3488. document.getElementById("getAtMsg").click();
  3489.  
  3490. }
  3491.  
  3492. },
  3493.  
  3494. cssChecked: function(id, dom) {
  3495.  
  3496. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  3497.  
  3498.  
  3499. },
  3500. getConfig: function() {
  3501.  
  3502. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  3503.  
  3504. if (CONFIG == null) {
  3505. CONFIG = HN_SETUP_CONFIG;
  3506. }
  3507.  
  3508. return CONFIG;
  3509. },
  3510.  
  3511. /**
  3512. * 获取cookie 中某个键对应的值
  3513. * @param name
  3514. */
  3515.  
  3516. getCookie: function(name) {
  3517. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  3518. if (arr != null) return escape(arr[2]);
  3519. return false;
  3520. },
  3521. /**
  3522. * 得到一个字符串数组的中随机一个
  3523. * @param {List} list
  3524. */
  3525.  
  3526.  
  3527. getRandomWordOfList: function(list) {
  3528. var L = list.length;
  3529. var i = Math.ceil(Math.random() * L);
  3530.  
  3531. return list[i];
  3532. },
  3533. random: function(min, max) {
  3534.  
  3535. return Math.floor(Math.random() * (max - min)) + min;
  3536. },
  3537.  
  3538. Sleep: function(ms) {
  3539. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  3540. }
  3541.  
  3542. }
  3543.  
  3544. let errorMsg = {
  3545. "-1": "应用程序不存在或已被封禁!",
  3546. "-2": "Access Key错误!",
  3547. "-3": "API校验密匙错误!",
  3548. "-4": "调用方对该Method没有权限!",
  3549. "-101": "账号未登录!",
  3550. "-102": "账号被封停!",
  3551. "-103": "积分不足!",
  3552. "-104": "硬币不足!",
  3553. "-105": "验证码错误!",
  3554. "-106": "账号非正式会员或在适应期!",
  3555. "-107": "应用不存在或者被封禁!",
  3556. "-108": "未绑定手机!",
  3557. "-109": "未知!",
  3558. "-110": "未绑定手机!",
  3559. "-111": "csrf 校验失败!",
  3560. "-112": "系统升级中!",
  3561. "-113": "账号尚未实名认证!",
  3562. "-114": "请先绑定手机!",
  3563. "-115": "请先完成实名认证!",
  3564. "-304": "木有改动!",
  3565. "-307": "撞车跳转!",
  3566. "-400": "请求错误!",
  3567. "-401": "未认证!",
  3568. "-403": "访问权限不足!",
  3569. "-404": "啥都木有!",
  3570. }
  3571.  
  3572. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  3573. /**
  3574. *
  3575. * @param code
  3576. * @constructor
  3577. */
  3578. let chackCode = function(code) {
  3579.  
  3580. let emsg = errorMsg[code + ""];
  3581. if (emsg != null) {
  3582. javaex.tip({
  3583. content: emsg,
  3584. type: "error"
  3585. });
  3586.  
  3587. return false;
  3588. }
  3589.  
  3590. return true;
  3591. }
  3592.  
  3593.  
  3594. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  3595. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  3596.  
  3597. /*window.onbeforeunload = function() {
  3598. if (!canLeavePage()) {
  3599. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  3600. }
  3601. };*/
  3602.  
  3603.  
  3604. /**
  3605. * Ajax请求对象
  3606. */
  3607. const Ajax = (() => {
  3608. /**
  3609. * 检查options是否符合要求
  3610. * @param {object} options
  3611. * @returns {boolean}
  3612. */
  3613. function checkOptions(options) {
  3614. let result = false;
  3615. if (typeof options !== 'object') {
  3616. console.warn('类型错误: typeof Options !== Object');
  3617. return result;
  3618. } else {
  3619. if (typeof options.url !== 'string') {
  3620. console.warn('类型错误: typeof Link !== Strings');
  3621. return result;
  3622. } else {
  3623. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  3624. if (!reg.test(options.url)) {
  3625. console.warn('url字符串须为完整http链接');
  3626. return result;
  3627. }
  3628. result = true;
  3629. }
  3630. }
  3631. return result;
  3632. }
  3633.  
  3634. /**
  3635. * 对象转URL编码
  3636. * @param {object} data
  3637. */
  3638. function objToURLCode(data) {
  3639. var _result = [];
  3640. for (var key in data) {
  3641. var value = data[key];
  3642. if (value instanceof Array) {
  3643. value.forEach(function(_value) {
  3644. _result.push(key + "=" + _value);
  3645. });
  3646. } else {
  3647. _result.push(key + '=' + value);
  3648. }
  3649. }
  3650. return _result.join('&');
  3651. }
  3652.  
  3653. /**
  3654. * 请求
  3655. * @param {string} method
  3656. * @param {object} options
  3657. */
  3658. function request(method, options) {
  3659. if (checkOptions(options)) {
  3660. let xhr = new XMLHttpRequest();
  3661. const {
  3662. url: _url,
  3663. queryStringsObj,
  3664. data,
  3665. dataType,
  3666. hasCookies
  3667. } = options, url = typeof queryStringsObj === 'object' ?
  3668. _url + '?' + objToURLCode(queryStringsObj) : _url;
  3669. switch (method) {
  3670. case 'GET':
  3671. xhr.open("GET", url);
  3672. break;
  3673. case 'POST':
  3674. xhr.open("POST", url);
  3675. xhr.setRequestHeader('Content-Type', dataType);
  3676. break;
  3677. default:
  3678. break;
  3679. }
  3680. if (hasCookies) xhr.withCredentials = true;
  3681. xhr.timeout = 3000;
  3682. xhr.addEventListener('load', () => {
  3683. if (xhr.status === 200) {
  3684. options.success(xhr.responseText)
  3685. } else {
  3686. console.error(`status:${xhr.status}`);
  3687. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  3688. }
  3689. })
  3690. xhr.addEventListener('error', () => {
  3691. console.error('ajax请求出错')
  3692. options.success('{"code":-1,"msg":"ajax请求出错"}');
  3693. })
  3694. xhr.addEventListener('timeout', () => {
  3695. console.error('请求超时')
  3696. options.success('{"code":-1,"msg":"请求超时"}');
  3697. })
  3698. switch (method) {
  3699. case 'GET':
  3700. xhr.send()
  3701. break;
  3702. case 'POST':
  3703. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  3704. break;
  3705. default:
  3706. break;
  3707. }
  3708. }
  3709. }
  3710.  
  3711. return {
  3712. /**
  3713. * 发送Get请求
  3714. * @param {Object} options
  3715. */
  3716. get(options) {
  3717. request("GET", options);
  3718. },
  3719. /**
  3720. * 发送Post请求
  3721. * @param {object} options
  3722. */
  3723. post(options) {
  3724. request("POST", options);
  3725. }
  3726. }
  3727. })()