-哔哩猫-(试用版)

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

目前為 2021-07-22 提交的版本,檢視 最新版本

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