-哔哩猫-(试用版)

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

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

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