-哔哩猫-(试用版)

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

当前为 2021-08-03 提交的版本,查看 最新版本

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