-哔哩猫-(试用版)

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

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

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