-哔哩猫-(试用版)

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

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

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