Greasy Fork is available in English.

-哔哩猫-(试用版)

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

Verze ze dne 25. 07. 2021. Zobrazit nejnovější verzi.

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