-哔哩猫-(试用版)

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

当前为 2021-04-12 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/422731/921072/-%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.5.90
  6. // @iconURL https://gitee.com/java_cn/BILIBLI_RES/raw/master/PIC/PC_1606377718.gif
  7. // @author 荒年(QQ:2019676120)
  8. // @match *://space.bilibili.com/*
  9. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
  10. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex.min.js
  11. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex-formVerify.js
  12. // @resource animate http://cdn.javaex.cn/javaex/pc/css/animate.css
  13. // @resource common http://cdn.javaex.cn/javaex/pc/css/common.css
  14. // @resource defaultCss http://cdn.javaex.cn/javaex/pc/css/skin/default.css
  15. // @grant unsafeWindow
  16. // @grant GM_getValue
  17. // @grant GM_setValue
  18. // @grant GM_xmlhttpRequest
  19. // @grant GM_getResourceText
  20. // @grant GM_openInTab
  21. // @grant GM_addStyle
  22. // @run-at document-idle
  23. // @license MIT License
  24. // @connect github.com
  25. // @connect gitee.com
  26. // @connect api.bilibili.com
  27. // @connect qmsg.zendee.cn
  28. // @connect passport.bilibili.com
  29. // @connect api.live.bilibili.com
  30. // @namespace http://tampermonkey.net/
  31. // ==/UserScript==
  32.  
  33.  
  34. GM_addStyle(
  35. `
  36.  
  37. #switch-qsmg:before {
  38. content: "开关";
  39. letter-spacing: 16px;
  40. top: 4px;
  41. left: 10px;
  42. }
  43. #left_navbar{
  44. z-index: 1000;
  45. position: absolute;
  46. top: 100px;
  47. left: 5px;
  48. }
  49. button[hnBtn="btn_open"] {
  50. z-index: 1001;
  51. z-index: 1000px;
  52. position: absolute;
  53. top: 58px;
  54. left: 220px;
  55. }
  56. .javaex-panel.javaex-panel-right.javaex-animated-zoom-in {
  57. top: 60px;
  58. }
  59. .javaex-menu-container {
  60. border: 1px solid #eee;
  61. }
  62. .javaex-panel-box p {
  63. text-align: center;
  64. background: #fb7299;
  65. }
  66. .fontbold{
  67. color: #00a1d6;
  68. font-weight: bold;
  69. cursor: pointer;
  70. }
  71. `
  72. );
  73.  
  74.  
  75. let HN_SETUP_CONFIG = {
  76.  
  77. qmsg_key: null, //后期改为kull 存储到本地
  78. qmsg_checked: false,
  79.  
  80.  
  81. }
  82.  
  83. let Live_info = {
  84. room_id: undefined,
  85. uid: undefined,
  86. blocked: undefined,
  87. csrf_token: undefined,
  88. visit_id: undefined,
  89. rnd: undefined,
  90. ruid: undefined,
  91. uname: undefined,
  92. user_level: undefined,
  93. ruid: undefined,
  94. };
  95.  
  96. let BILIBLI_PATH = {
  97.  
  98. "live": "https://api.live.bilibili.com",
  99. "passport": "https://passport.bilibili.com",
  100. "api": "https://api.bilibili.com",
  101. "video": "https://www.bilibili.com/video/",
  102. "single_unread": "http://api.vc.bilibili.com/"
  103. }
  104.  
  105. let BILIBILI_URL = {
  106. // 导航栏用户信息
  107. "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
  108. }
  109.  
  110. let BiliData = {
  111.  
  112. this_uid: window.location.href.split("/")[3], //当前页面uid
  113. author_uid: 99439379,
  114. login_code: null,
  115. login_message: "",
  116. LoginData: {},
  117. CoinLog: {},
  118. Unread: null,
  119. Video: {},
  120. replyAction: {},
  121. upCard: {},
  122. BVList: [],
  123. }
  124.  
  125. window.onload = function() {
  126.  
  127.  
  128. //界面显示
  129. init();
  130.  
  131.  
  132. }
  133.  
  134.  
  135. function init() {
  136.  
  137. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  138. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  139.  
  140. addStyle();
  141. addSetPage();
  142.  
  143. HNTOOL.chackAtMsg();
  144.  
  145. $("#getCoinLog").bind("click", async function() {
  146.  
  147.  
  148. if (HNAPI.getCoinLog()) {
  149.  
  150. await HNTOOL.Sleep(500);
  151. let html = '';
  152. html += '<div class="javaex-panel-box" style="width: 250px;">';
  153. html += ' <ul>';
  154. html += ` <p style="color: #FFF;">硬币使用记录</p>`;
  155.  
  156. BiliData.CoinLog.list.forEach(function(item) {
  157.  
  158. let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
  159. if (BV.indexOf("BV") != -1) {
  160. html += `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
  161. }
  162. html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
  163.  
  164.  
  165. });
  166. html += ' <hr class="javaex-divider"></hr>';
  167. html += ' </ul>';
  168. html += '</div>';
  169.  
  170. javaex.panel(this, {
  171. position: "right",
  172. //offsetTop: "104",
  173. content: html
  174. });
  175. javaex.tip({
  176. content: "获取用户成功!",
  177. type: "success"
  178. });
  179.  
  180. } else {
  181. javaex.tip({
  182. content: "获取硬币记录失败,请稍后重试!",
  183. type: "error"
  184. });
  185. }
  186.  
  187.  
  188. });
  189.  
  190. $("#getUnread").bind("click", async function() {
  191.  
  192. javaex.tip({
  193. content: "获取中,请稍候...",
  194. type: "submit"
  195. });
  196. HNAPI.getUnread();
  197.  
  198.  
  199. });
  200.  
  201.  
  202. $("#likeInDynamicComments").bind("click", async function() {
  203.  
  204. let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get("likeInDynamic_PRID");
  205. let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get("likeInDynamic_OID");
  206.  
  207. let html = '';
  208.  
  209. html += '<div style="padding: 10px 10px 10px 0px;">'
  210. html += '<form id="likeInDynamic_form">'
  211. html += ' <div class="javaex-unit clear">'
  212. html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
  213. html += ' <div class="javaex-unit-right">'
  214. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
  215. html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
  216. html += ' </div>'
  217. html += ' </div>'
  218. html += ' <div class="javaex-unit clear">'
  219. html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
  220. html += ' <div class="javaex-unit-right">'
  221. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
  222. html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
  223. html += ' </div>'
  224. html += ' </div>'
  225. html += ' <div class="javaex-unit clear tc">'
  226. html +=
  227. ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
  228. html +=
  229. ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
  230. html += ' </div>'
  231. html += '</form>';
  232. html += '<hr class="javaex-divider"></hr>';
  233. html += '</div>';
  234.  
  235.  
  236. javaex.panel(this, {
  237. position: "right",
  238. content: html
  239. });
  240.  
  241.  
  242. // 监听点击保存按钮事件
  243. $("#likeInDynamic_yes").click(async function() {
  244. // 表单验证函数
  245. if (javaexVerify()) {
  246.  
  247. HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex.getSelectVal(
  248. "#likeInDynamic_PRID"), 1);
  249. await HNTOOL.Sleep(1000);
  250.  
  251. if (BiliData.replyAction.code == 0) {
  252.  
  253. LocalData.set("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  254. LocalData.set("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  255.  
  256. javaex.tip({
  257. content: "评论区点赞成功!",
  258. type: "success"
  259. });
  260. } else {
  261. javaex.tip({
  262. content: "评论区点赞失败!",
  263. type: "error"
  264. });
  265. }
  266. if (BiliData.replyAction.code == 65006) {
  267. javaex.tip({
  268. content: "请勿重复点赞!",
  269. type: "error"
  270. });
  271. }
  272. }
  273. });
  274.  
  275. // 监听点击返回按钮事件
  276. $("#likeInDynamic_no").click(async function() {
  277.  
  278. if (javaexVerify()) {
  279.  
  280. HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +javaex.getLocalStorage(
  281. "#likeInDynamic_PRID"), 0);
  282. await HNTOOL.Sleep(500);
  283.  
  284. if (BiliData.replyAction.code == 0) {
  285.  
  286. javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  287. javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  288.  
  289. javaex.tip({
  290. content: "评论区取消点赞成功!",
  291. type: "success"
  292. });
  293. } else {
  294. javaex.tip({
  295. content: "评论区取消点赞失败!",
  296. type: "error"
  297. });
  298. }
  299. if (BiliData.replyAction.code == 65006) {
  300. javaex.tip({
  301. content: "请勿重复取消点赞!",
  302. type: "error"
  303. });
  304. }
  305. }
  306. });
  307.  
  308. });
  309.  
  310. $("#biliUserMsg").bind("click", async function() {
  311.  
  312.  
  313. //刷新信息
  314. HNAPI.getUserNav();
  315. await HNTOOL.Sleep(500);
  316.  
  317. let isLogin = "未登录";
  318. let vipType = "无";
  319. //判断是否成功
  320. if (BiliData.login_code == 0) {
  321.  
  322.  
  323. if (BiliData.LoginData.isLogin) {
  324. isLogin = "已登录";
  325. }
  326.  
  327. if (BiliData.LoginData.vipType == 1) {
  328. vipType = "月度大会员";
  329. } else if (BiliData.LoginData.vipType == 2) {
  330. vipType = "年度大会员";
  331. }
  332.  
  333. let html = '';
  334. html += '<div class="javaex-panel-box" style="width: 250px;">';
  335. html += ' <ul>';
  336. html += ` <p style="color: #FFF;">用户信息</p>`;
  337. html += ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
  338. html += ` <li>用户状态:${isLogin} </li> `;
  339. html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
  340. html +=
  341. ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
  342. html += ` <li>UID${BiliData.LoginData.mid} </li> `;
  343. html += ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
  344. html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
  345. html += ` <li>会员:${vipType} </li> `;
  346. html += ' <hr class="javaex-divider"></hr>';
  347. html += ' </ul>';
  348. html += '</div>';
  349.  
  350.  
  351. javaex.panel(this, {
  352. position: "right",
  353. content: html
  354. });
  355.  
  356. javaex.tip({
  357. content: "获取用户成功!",
  358. type: "success"
  359. });
  360.  
  361. } else {
  362. javaex.tip({
  363. content: "获取用户信息失败!",
  364. type: "error"
  365. });
  366. }
  367.  
  368.  
  369. });
  370.  
  371. $("#getAtMsg").bind("click", async function() {
  372.  
  373. if (HNAPI.getMsgfeed("at") && typeof(HNAPI.getMsgfeed("at")) != "undefined") {
  374.  
  375. javaex.tip({
  376. content: "可能中奖了!!!",
  377. type: "success"
  378. });
  379. }
  380. });
  381.  
  382.  
  383. $("#disUser").bind("click", async function() {
  384.  
  385. let html = '';
  386. html += '<div class="javaex-panel-box" style="width: 500px;">';
  387. html += ' <div class="javaex-unit clear">';
  388. html += ' <div class="javaex-unit-left ml-10 mt-10">*UID列表</div>';
  389. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  390. html +=
  391. ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
  392. html += ' </div>';
  393. html += ' </div>';
  394. html += ' <div class="javaex-unit clear tc">';
  395. html += ' <input type="button" id="disUser_block" class="javaex-btn yes" value="拉黑" />';
  396. html += ' <input type="button" id="disUser_cancelAtt_uid" class="javaex-btn yes" value="UID取关" />';
  397. html += ' <input type="button" id="disUser_cancelAtt_room" class="javaex-btn yes" value="房间号取关" />';
  398. html += ' </div>';
  399. html += '</div>';
  400.  
  401. javaex.panel(this, {
  402. position: "right",
  403. content: html
  404. });
  405.  
  406. let disUser_str;
  407. //拉黑
  408. $("#disUser_beg").bind("click", async function() {
  409.  
  410. disUser_str = javaex.getSelectVal("#disUser_uidList");
  411. disUser_uidList = disUser_str.split(",");
  412. let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
  413.  
  414. for (const vmid of disUserStr) {
  415.  
  416. HNAPI.batchModify(vmid.toString(), 5);
  417. await HNTOOL.Sleep(6000);
  418. }
  419. });
  420. //取关uid
  421. $("#disUser_cancelAtt_uid").bind("click", async function() {
  422. disUser_str = javaex.getSelectVal("#disUser_uidList");
  423. disUser_uidList = disUser_str.split(",");
  424.  
  425. javaex.tip({
  426. content: "根据uid批量取关开始!!!",
  427. type: "success"
  428. });
  429.  
  430. let disuidList = [];
  431. let PN = 100;
  432. PN = disUser_roomList.length == 1 ? 0 : PN;
  433.  
  434. for (var i = 0; i < PN; i++) {
  435.  
  436. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  437. javaex.tip({
  438. content: "获取第" + i + "页黑名单成功!",
  439. type: "success"
  440. });
  441. await HNTOOL.Sleep(1000);
  442.  
  443. if (uidList.length == 0) {
  444. break;
  445. }
  446. if (uidList == null) {
  447. continue;
  448. }
  449.  
  450. for (let disuid of uidList) {
  451. if (disuidList.indexOf(disuid.mid) == -1) {
  452. disuidList.push(disuid.mid + "");
  453. }
  454. }
  455.  
  456.  
  457. }
  458.  
  459. for (let uid of disUser_uidList) {
  460.  
  461. let uidType = "未在黑名单";
  462. if (disuidList.indexOf(uid) == -1) {
  463.  
  464. await HNAPI.cancelAtt(uid, 2);
  465. } else {
  466.  
  467. await HNAPI.cancelAtt(uid, 6, 116);
  468. uidType = "黑名单用户";
  469. }
  470.  
  471. javaex.tip({
  472. content: "【UID:" + uid + "】" + uidType + "取关成功!",
  473. type: "success"
  474. });
  475. await HNTOOL.Sleep(4000);
  476. }
  477.  
  478.  
  479. alert("根据uid批量取关完成!");
  480.  
  481. /* javaex.alert({
  482. content: "根据uid批量取关完成!",
  483. confirm: function() {
  484.  
  485. //return false;
  486. }
  487. }); */
  488.  
  489. });
  490. //取关room
  491. $("#disUser_cancelAtt_room").bind("click", async function() {
  492.  
  493. javaex.tip({
  494. content: "根据房间号批量取关开始!!!",
  495. type: "success"
  496. });
  497.  
  498. disUser_str = javaex.getSelectVal("#disUser_uidList");
  499. disUser_roomList = disUser_str.split(",");
  500. let disuidList = [];
  501. let PN = 100;
  502. PN = disUser_roomList.length == 1 ? 0 : PN;
  503.  
  504. for (var i = 0; i < PN; i++) {
  505.  
  506. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  507. javaex.tip({
  508. content: "获取第" + i + "页黑名单成功!",
  509. type: "success"
  510. });
  511. await HNTOOL.Sleep(1000);
  512.  
  513. if (uidList.length == 0) {
  514. break;
  515. }
  516. if (uidList == null) {
  517. continue;
  518. }
  519.  
  520. for (let disuid of uidList) {
  521.  
  522. if (disuidList.indexOf(disuid.mid) == -1) {
  523. disuidList.push(disuid.mid);
  524. }
  525.  
  526. }
  527.  
  528.  
  529. }
  530.  
  531. for (let room of disUser_roomList) {
  532.  
  533. let uid = await HNAPI.getRoomMsg(room);
  534.  
  535. await HNTOOL.Sleep(1000);
  536.  
  537. if (uid == false) {
  538. javaex.tip({
  539. content: "uid查询失败跳过!",
  540. type: "error"
  541. });
  542. continue;
  543. }
  544. let uidType = "未在黑名单";
  545. if (disuidList.indexOf(uid) == -1) {
  546.  
  547. await HNAPI.cancelAtt(uid, 2);
  548. } else {
  549.  
  550. await HNAPI.cancelAtt(uid, 6, 116);
  551. uidType = "黑名单用户";
  552. }
  553.  
  554. javaex.tip({
  555. content: "Room:" + room + "-【UID:" + uid + "】" + uidType + "取关成功!",
  556. type: "success"
  557. });
  558. await HNTOOL.Sleep(4000);
  559.  
  560.  
  561. }
  562. alert("根据房间号批量取关完成!");
  563. /* javaex.alert({
  564. content: ,
  565. confirm: function() {
  566.  
  567. return false;
  568. }
  569. }); */
  570.  
  571. });
  572.  
  573. });
  574.  
  575. $("#arrUnique").bind("click", async function() {
  576.  
  577. let html = '';
  578. html += '<div class="javaex-panel-box" style="width: 500px;">';
  579. html += ' <div class="javaex-unit clear">';
  580. html += ' <div id="arrNub" class="javaex-unit-left ml-10 mt-10">*数组0</div>';
  581. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  582. html += ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  583. html += ' </div>';
  584. html += ' </div>';
  585. html += ' <div class="javaex-unit clear tc">';
  586. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="去重" />';
  587. //html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="粘贴" />';
  588. html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="复制" />';
  589. html += ' </div>';
  590. html += '</div>';
  591.  
  592. javaex.panel(this, {
  593. position: "right",
  594. content: html
  595. });
  596.  
  597. $('#arrUnique_str').bind('input propertychange', function() {
  598.  
  599. $('#arrNub').text("*数组" + $(this).val().split(",").length);
  600.  
  601. });
  602. $('#arrUnique_copy').bind('click', function() {
  603.  
  604. HNTOOL.copyText("arrUnique_str");
  605.  
  606. });
  607.  
  608.  
  609.  
  610.  
  611. $("#arrUnique_beg").bind("click", async function() {
  612.  
  613. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  614. let arrUnique_uidList = arrUnique_str.split(",");
  615.  
  616. let arrUniqueStr = HNTOOL.arrUnique(arrUnique_uidList).toString();
  617.  
  618. document.getElementById("arrUnique_str").value = arrUniqueStr;
  619.  
  620. });
  621.  
  622. });
  623.  
  624. $("#batchFollow").bind("click", async function() {
  625.  
  626. var thisUPName = $("#h-name").text();
  627.  
  628.  
  629. let html = '';
  630. html += '<div class="javaex-panel-box" style="width: 600px;">';
  631. html += ' <div class="javaex-unit clear">';
  632. html += ' <div id="followNub" class="javaex-unit-left ml-10 mt-10">*关注列表0</div>';
  633. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  634. html +=
  635. ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
  636. html += ' </div>';
  637. html += ' </div>';
  638. html += ' <div class="javaex-unit clear tc" >';
  639. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  640. html += ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="爬取关注" />';
  641. html += ` <input type="button" id="Follow_thisUp" class="javaex-btn yes tc" value="关注${thisUPName}" />`;
  642. html += ` <input type="button" id="disFollow_thisUp" class="javaex-btn yes tc" value="拉黑${thisUPName}" /> `;
  643. html += ' </div>';
  644. html += '</div>';
  645.  
  646. javaex.panel(this, {
  647. position: "right",
  648. content: html
  649. });
  650.  
  651. $('#batchFollow_uidList').bind('input propertychange', function() {
  652.  
  653. $('#followNub').text("*关注列表" + $(this).val().split(",").length);
  654.  
  655. });
  656.  
  657. $("#disFollow_thisUp").bind("click", async function() {
  658.  
  659. HNAPI.batchModify(BiliData.this_uid, 5);
  660.  
  661. });
  662.  
  663. $("#Follow_thisUp").bind("click", async function() {
  664.  
  665. HNAPI.batchModify(BiliData.this_uid);
  666.  
  667. });
  668.  
  669. $("#batchFollow_beg").bind("click", async function() {
  670.  
  671. let mid_str = javaex.getSelectVal("#batchFollow_uidList");
  672. mid_list = mid_str.split(",");
  673.  
  674. let mid_Lists = HNTOOL.split_array(mid_list, 15);
  675. for (const mids of mid_Lists) {
  676.  
  677. HNAPI.batchModify(mids.toString());
  678. await HNTOOL.Sleep(8000);
  679. }
  680.  
  681.  
  682. });
  683.  
  684. $("#crawler_follow").bind("click", async function() {
  685.  
  686. //x/space/myinfo
  687. let myinfoData = await HNAPI.getMyinfo();
  688. await HNAPI.getUpCard(myinfoData.mid);
  689. await HNTOOL.Sleep(1000);
  690. let len = parseInt(BiliData.upCard.data.card.attention / 20);
  691. let followData = [];
  692.  
  693. for (let i = 0; i < len; i++) {
  694. if (BiliData.upCard.code != 0) {
  695. javaex.tip({
  696. content: `爬取关注出现异常 终止爬取!{BiliData.upCard.message}`,
  697. type: "error"
  698. });
  699. break;
  700. }
  701.  
  702. javaex.tip({
  703. content: `正在爬取` + myinfoData.mid + `的` + i + `页的关注!!!`,
  704. type: "success"
  705. });
  706.  
  707. let followList = await HNAPI.getMyFollow(myinfoData.mid, i);
  708. if (followList != null) {
  709. for (const fl of followList.list) {
  710.  
  711. if (fl.official_verify.type != 1 || fl.vip.vipType == 0) {
  712. //continue;
  713. }
  714.  
  715. followData.push(fl.mid);
  716.  
  717. }
  718. }
  719.  
  720.  
  721. await HNTOOL.Sleep(3000);
  722. }
  723.  
  724. document.getElementById("batchFollow_uidList").value = followData.toString();
  725.  
  726. });
  727.  
  728.  
  729. });
  730.  
  731.  
  732. $("#HNSetup").bind("click", async function() {
  733.  
  734. var CONFIG = HNTOOL.getConfig();
  735.  
  736.  
  737. let html = '';
  738.  
  739. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  740. html += '<form id="HNGG_SETUP">'
  741. html += ' <div class="javaex-unit clear">'
  742. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Qmsg-key</p></div>'
  743. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  744. html += ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  745. html += ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  746. html += ' </div>'
  747. html += ' <div class="javaex-unit-left mr-10">'
  748. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  749. html += ' </div>'
  750. html += ' </div>'
  751. html += '</form>';
  752. html += '<div class="javaex-unit clear tc">';
  753. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  754. html += '</div>';
  755. html += '<hr class="javaex-divider"></hr>';
  756. html += '</div>';
  757.  
  758. javaex.panel(this, {
  759. position: "right",
  760. content: html
  761. });
  762.  
  763.  
  764. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  765.  
  766. $("#switch-qsmg").bind("click", function() {
  767.  
  768. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  769.  
  770. })
  771.  
  772.  
  773. $("#HNSetup_save").bind("click", async function() {
  774.  
  775.  
  776. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  777.  
  778. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  779.  
  780. javaex.tip({
  781. content: "设置成功!",
  782. type: "success"
  783. });
  784.  
  785. });
  786.  
  787. });
  788.  
  789. //
  790. $("#getUpMassage").bind("click", async function() {
  791.  
  792.  
  793. let html = '';
  794.  
  795. html += '<div style="padding: 10px 10px 10px 0px;">'
  796. html += '<form id="getUpMassage_form">'
  797. html += ' <div class="javaex-unit clear">'
  798. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  799. html += ' <div class="javaex-unit-left mr-10">'
  800. html +=
  801. ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  802. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  803. html += ' </div>'
  804. html += ' <div class="javaex-unit-right mr-10">'
  805. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  806. html += ' </div>'
  807. html += ' </div>'
  808. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  809. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  810. html += ' <thead>'
  811. html += ' <tr><th>内容</th><th>详情</th></tr>'
  812. html += ' </thead>'
  813. html += ' <tbody id="upMsgTbody">'
  814.  
  815. html += ' </tbody>'
  816. html += '</table> '
  817. html += '</div>'
  818. html += '</form>';
  819. html += '<hr class="javaex-divider"></hr>';
  820. html += '</div>';
  821.  
  822.  
  823. javaex.panel(this, {
  824. position: "right",
  825. content: html
  826. });
  827.  
  828. javaex.table({
  829. id: "upMsgTable",
  830. isDragColWidth: true, // 是否允许拖动改变列宽
  831. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  832. leftFixedColNum: 2, // 左侧固定列数
  833. rightFixedColNum: 1, // 右侧固定列数
  834. sort: {
  835. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  836. "2": "update_time"
  837. },
  838. sortCallback: function(rtn) {
  839. //console.log(rtn.sortArr);
  840. }
  841. });
  842.  
  843. //
  844. $("#getUpMsg").click(async function() {
  845.  
  846. let thismid = javaex.getSelectVal("#up_uid");
  847. await HNAPI.userInfo(thismid)
  848.  
  849. let temp = await HNAPI.getUpCard(thismid);
  850.  
  851.  
  852. await HNTOOL.Sleep(500);
  853.  
  854.  
  855. if (temp != false) {
  856. let data = BiliData.upCard.data;
  857.  
  858. let html = ``;
  859. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  860. html += `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  861. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  862. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  863. html +=
  864. `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  865. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  866. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  867. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  868. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  869. html +=
  870. `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  871. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  872. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  873.  
  874.  
  875. $("#upMsgTbody").empty();
  876. $("#upMsgTbody").append(html);
  877. }
  878.  
  879.  
  880. });
  881. //点击放大
  882. /* $("img").click(function() {
  883. javaex.dialog({
  884. type : "image", // 弹出层类型
  885. url : $(this).attr("src") // 图片地址
  886. });
  887. });*/
  888.  
  889. });
  890.  
  891.  
  892. $("#plateActivity").bind("click", async function() {
  893.  
  894. //获取轮盘数据
  895.  
  896. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/plateActivity.json";
  897. let myjson = await HNAPI.getMyJson(url);
  898. let lmt = 0;
  899. let giftArr = [];
  900. let endAtion = [];
  901.  
  902. javaex.tip({
  903. content: "开始参加轮盘!!!",
  904. type: "success"
  905. });
  906.  
  907. await HNAPI.getUserNav();
  908. await HNTOOL.Sleep(1500);
  909.  
  910.  
  911. for (const json of myjson) {
  912. //let x = json.name;
  913. for (let i = 0; i < 20; i++) {
  914. //结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  915. let resout = await HNAPI.addLotteryTimes(json.sid);
  916.  
  917. await HNTOOL.Sleep(200);
  918. if (resout == 1) {
  919. endAtion.push(json.name + ":活动已结束!");
  920. javaex.tip({
  921. content: json.name + "活动已结束!",
  922. type: "success"
  923. });
  924.  
  925. break;
  926. }
  927. if (resout == 2) {
  928. javaex.tip({
  929. content: json.name + "增加次数发生错误!",
  930. type: "error"
  931. });
  932. break;
  933. }
  934.  
  935. if (resout == 0) {
  936.  
  937. lmt = await HNAPI.getLotteryMytimes(json.sid);
  938.  
  939. javaex.tip({
  940. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  941. type: "success"
  942. });
  943. break;
  944. }
  945.  
  946. }
  947. await HNTOOL.Sleep(1500);
  948. let k = 20; //重试次数 防止卡主
  949.  
  950. for (let i = 0; i < lmt; i++) {
  951.  
  952. let gift = await HNAPI.lotteryDo(json.sid);
  953.  
  954.  
  955. if (gift == true) {
  956.  
  957. javaex.tip({
  958. content: "点击过快,9秒后自动重试!!!",
  959. type: "error"
  960. });
  961.  
  962. i--;
  963. k--;
  964. }
  965.  
  966. if (gift == false || k == 0) {
  967. break;
  968. }
  969.  
  970. if (gift != "未中奖0" && gift != true) {
  971. giftArr.push(json.name + "奖品为:" + gift);
  972. break;
  973. } else {
  974. javaex.tip({
  975. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  976. type: "success"
  977. });
  978. }
  979. await HNTOOL.Sleep(9000);
  980.  
  981. }
  982.  
  983.  
  984. }
  985.  
  986.  
  987. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  988. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  989.  
  990. alert(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  991. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  992.  
  993.  
  994. });
  995.  
  996. $("#addPlay").bind("click", async function() {
  997.  
  998.  
  999. let html = '';
  1000.  
  1001. html += '<div style="padding: 10px 10px 10px 0px;">'
  1002. html += '<form id="getUpMassage_form">'
  1003.  
  1004. html += ' <div class="javaex-unit clear">'
  1005. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  1006. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  1007. html +=
  1008. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  1009. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  1010. html += ' </div>'
  1011. html += ' </div>'
  1012. html += ' <div class="javaex-unit clear">'
  1013. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  1014. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  1015. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  1016. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  1017. html += ' </div>'
  1018. html += ' </div>'
  1019. html += '</form>';
  1020. html += ' <div class="javaex-unit clear tc">'
  1021. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  1022. html += ' </div>'
  1023. html += '<hr class="javaex-divider"></hr>';
  1024. html += '</div>';
  1025.  
  1026.  
  1027. javaex.panel(this, {
  1028. position: "right",
  1029. content: html
  1030. });
  1031.  
  1032. $("#addPlay_bgn").click(async function() {
  1033.  
  1034. let MID = javaex.getSelectVal("#addPlay_uid")
  1035. let BV = javaex.getSelectVal("#addPlay_bv");
  1036. let bvArr = [];
  1037. let bvArr2 = [];
  1038.  
  1039. MID = javaex.ifnull(MID, BiliData.author_uid);
  1040.  
  1041.  
  1042. if (BV == "0") {
  1043.  
  1044. //1.查询up所有视频BV号 2.发送心跳间隔2s
  1045. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  1046. await HNTOOL.Sleep(500);
  1047. bvArr2 = BiliData.BVList;
  1048.  
  1049. for (let i = 1; i > 0; i++) {
  1050.  
  1051. HNAPI.getUpAllBV(MID, i);
  1052.  
  1053. await HNTOOL.Sleep(500);
  1054.  
  1055. if (BiliData.BVList.length == 0) {
  1056. if (bvArr.length == 0) {
  1057. javaex.tip({
  1058. content: "该用户无投稿视频,请确认是否有误!",
  1059. type: "success"
  1060. });
  1061. await HNTOOL.Sleep(2000);
  1062. }
  1063. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  1064. bvArr = bvArr.concat(bvArr2);
  1065. break;
  1066. }
  1067.  
  1068. bvArr = bvArr.concat(BiliData.BVList);
  1069. }
  1070.  
  1071.  
  1072. if (bvArr.length != 0) {
  1073.  
  1074. for (const emt of bvArr) {
  1075.  
  1076. HNAPI.playOneVideo(emt.bvid, MID);
  1077.  
  1078. await HNTOOL.Sleep(2000);
  1079.  
  1080. }
  1081.  
  1082. alert("播放完成!!!");
  1083.  
  1084. }
  1085.  
  1086.  
  1087. } else {
  1088. //1.调用点击播放接口
  1089. //2.发送心跳
  1090.  
  1091. await HNTOOL.Sleep(500);
  1092.  
  1093. HNAPI.playOneVideo(BV);
  1094. }
  1095.  
  1096.  
  1097. });
  1098.  
  1099.  
  1100. });
  1101.  
  1102. }
  1103.  
  1104.  
  1105. let addSetPage = async function() {
  1106.  
  1107. HNTOOL.Sleep(1000);
  1108.  
  1109. $('body').append('' +
  1110. '<div id="left_navbar">' +
  1111. '<div class="javaex-menu-container"> ' +
  1112. ' <div id="menu" class="javaex-menu"> ' +
  1113. ' <ul> ' +
  1114. ' <li class="javaex-menu-item alone hover" > ' +
  1115. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  1116. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  1117. ' </li> ' +
  1118. ' </ul> ' +
  1119. ' <ul> ' +
  1120. ' <li class="javaex-menu-item"> ' +
  1121. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  1122. ' <ul> ' +
  1123. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  1124. ' </ul> ' +
  1125. ' </li> ' +
  1126. ' <li id="chackList" class="javaex-menu-item"> ' +
  1127. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  1128. ' <ul> ' +
  1129. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  1130. ' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  1131. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  1132. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  1133. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  1134. ' </ul> ' +
  1135. ' </li> ' +
  1136. ' <li class="javaex-menu-item"> ' +
  1137. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  1138. ' <ul> ' +
  1139. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  1140. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  1141. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  1142. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  1143. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  1144. ' </ul> ' +
  1145. ' </li> ' +
  1146. ' <li class="javaex-menu-item"> ' +
  1147. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  1148. ' <ul> ' +
  1149. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  1150. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  1151. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  1152. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  1153. ' <li id="" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  1154. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  1155. ' </ul> ' +
  1156. ' </li> ' +
  1157. ' <li class="javaex-menu-item"> ' +
  1158. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  1159. ' <ul> ' +
  1160. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  1161. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  1162. ' </ul> ' +
  1163. ' </li> ' +
  1164.  
  1165. ' </ul> ' +
  1166. ' </div> ' +
  1167. '</div>' +
  1168. '</div>');
  1169. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  1170.  
  1171. javaex.menu({
  1172. id: "menu",
  1173. isShowAll: false
  1174. });
  1175.  
  1176. }
  1177.  
  1178.  
  1179.  
  1180.  
  1181. let showUnreadMsg = function() {
  1182.  
  1183. var html = '';
  1184. html += '<div class="javaex-panel-box" style="width: 250px;">';
  1185. html += ' <ul>';
  1186. html += ` <p style="color: #FFF;">用户消息</p>`;
  1187. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  1188. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  1189. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  1190. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  1191. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  1192. html += ' <hr class="javaex-divider"></hr>';
  1193. html += ' </ul>';
  1194. html += '</div>';
  1195.  
  1196.  
  1197. javaex.panel(document.getElementById("getUnread"), {
  1198. position: "right",
  1199. content: html
  1200. });
  1201.  
  1202. javaex.tip({
  1203. content: "查询用户通知成功!",
  1204. type: "success"
  1205. });
  1206.  
  1207. }
  1208.  
  1209. /**
  1210. * 检查 艾特信息
  1211. * @returns {Promise<void>}
  1212. */
  1213. let chackAtMsg = async function(items) {
  1214.  
  1215. await HNTOOL.Sleep(500);
  1216.  
  1217. if (items != false && typeof(items) != "undefined") {
  1218.  
  1219.  
  1220. var html = '';
  1221. html += '<div class="javaex-panel-box" style="width: auto;">';
  1222. html += ' <ul>';
  1223. html += ` <p style="color: #FFF;">@信息</p>`;
  1224. items.forEach(function(item) {
  1225.  
  1226. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  1227. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  1228. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  1229.  
  1230. html +=
  1231. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  1232. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  1233. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  1234. html += ' <hr class="javaex-divider"></hr>';
  1235. });
  1236. html += ' </ul>';
  1237. html += '</div>';
  1238.  
  1239.  
  1240. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  1241. javaex.panel(document.getElementById("getAtMsg"), {
  1242. position: "right",
  1243. content: html
  1244. });
  1245. } else {
  1246. javaex.panel(document.getElementById("chackList"), {
  1247. position: "right",
  1248. content: html
  1249. });
  1250. }
  1251.  
  1252.  
  1253. }
  1254.  
  1255. }
  1256.  
  1257.  
  1258. let addStyle = function() {
  1259. const animate = GM_getResourceText('animate');
  1260. const common = GM_getResourceText('common');
  1261. const defaultCss = GM_getResourceText('defaultCss');
  1262. //const icomoonex = GM_getResourceText('icomoonex');
  1263. //const AllCss = animate + common + defaultCss + icomoonex;
  1264. const AllCss = animate + common + defaultCss;
  1265. const style = document.createElement('style');
  1266. style.innerHTML = AllCss;
  1267. return document.getElementsByTagName('head')[0].appendChild(style);
  1268. }
  1269.  
  1270. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  1271.  
  1272.  
  1273. /*-----------------------------------------------常用API--------------------------------------------------*/
  1274.  
  1275. let HNAPI = {
  1276.  
  1277.  
  1278.  
  1279. getDisuidList: async function(re_version, pn) {
  1280. return new Promise((resolve) => {
  1281. Ajax.get({
  1282.  
  1283. url: BILIBLI_PATH.api + '/x/relation/blacks',
  1284. queryStringsObj: {
  1285. "re_version": re_version,
  1286. "pn": pn
  1287. },
  1288. hasCookies: true,
  1289. success: responseText => {
  1290. let res = HNTOOL.strToJson(responseText);
  1291. if (res.code === 0) {
  1292. resolve(res.data.list)
  1293. } else {
  1294.  
  1295. javaex.tip({
  1296. content: "查询黑名单失败!" + res.message,
  1297. type: "error"
  1298. });
  1299.  
  1300. resolve(null)
  1301. }
  1302. }
  1303. })
  1304. });
  1305. },
  1306.  
  1307. /**
  1308. * @param {Object} uid
  1309. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  1310. */
  1311. cancelAtt: async function(uid, act, re_src) {
  1312. return new Promise((resolve) => {
  1313. Ajax.post({
  1314. url: BILIBLI_PATH.api + '/x/relation/modify',
  1315. hasCookies: true,
  1316. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1317. data: {
  1318. fid: uid,
  1319. act: act,
  1320. re_src: re_src == undefined ? 11 : 116,
  1321. jsonp: "jsonp",
  1322. csrf: Live_info.csrf_token,
  1323. },
  1324. success: responseText => {
  1325. let res = HNTOOL.strToJson(responseText);
  1326. if (res.code === 0) {
  1327.  
  1328. //HNAPI.cancelAtt(uid, 6);
  1329.  
  1330. javaex.tip({
  1331. content: "取关成功!" + res.message,
  1332. type: "success"
  1333. });
  1334.  
  1335. resolve(true);
  1336. } else if (res.code === 22003) {
  1337.  
  1338. HNAPI.cancelAtt(uid, 6);
  1339.  
  1340. javaex.tip({
  1341. content: "取消拉黑" + res.message,
  1342. type: "success"
  1343. });
  1344. resolve(true);
  1345. } else {
  1346.  
  1347. javaex.tip({
  1348. content: res.message,
  1349. type: "error"
  1350. });
  1351.  
  1352. resolve(false);
  1353. }
  1354. }
  1355. })
  1356. });
  1357. },
  1358.  
  1359. getRoomMsg: async function(roomid) {
  1360. return new Promise((resolve) => {
  1361. Ajax.get({
  1362.  
  1363. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  1364. queryStringsObj: {
  1365. "roomid": roomid
  1366. },
  1367. hasCookies: true,
  1368. success: responseText => {
  1369. let res = HNTOOL.strToJson(responseText);
  1370. if (res.code === 0) {
  1371. resolve(res.data.info.uid)
  1372. } else {
  1373. resolve(false)
  1374. }
  1375. }
  1376. })
  1377. });
  1378. },
  1379.  
  1380. /**
  1381. *
  1382. * @param sid
  1383. * @returns {Promise<unknown>}
  1384. */
  1385. lotteryDo: async function(sid) {
  1386. return new Promise((resolve) => {
  1387. Ajax.post({
  1388. url: BILIBLI_PATH.api + '/x/activity/lottery/do',
  1389. hasCookies: true,
  1390. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1391. data: {
  1392.  
  1393. sid: sid,
  1394. type: 1,
  1395. csrf: Live_info.csrf_token,
  1396. },
  1397. success: responseText => {
  1398. let res = HNTOOL.strToJson(responseText);
  1399. if (res.code === 0) {
  1400. resolve((res.data)[0].gift_name);
  1401.  
  1402. } else if (res.code === 75400) {
  1403.  
  1404. resolve(true);
  1405. } else {
  1406. javaex.tip({
  1407. content: "本次抽奖失败!" + res.message,
  1408. type: "error"
  1409. });
  1410. resolve(false);
  1411. }
  1412. }
  1413. })
  1414. });
  1415. },
  1416.  
  1417.  
  1418. getLotteryMytimes: async function(sid) {
  1419. return new Promise((resolve) => {
  1420. Ajax.get({
  1421. url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
  1422. queryStringsObj: {
  1423. sid: sid
  1424. },
  1425. hasCookies: true,
  1426. success: responseText => {
  1427. let res = HNTOOL.strToJson(responseText);
  1428. if (res.code === 0) {
  1429. resolve(res.data.times)
  1430. } else {
  1431. resolve(0)
  1432. }
  1433. }
  1434. })
  1435. });
  1436. },
  1437.  
  1438. /**
  1439. * 增加抽奖次数一般是分享
  1440. * @param sid 活动sid
  1441. * @returns {Promise<unknown>} 0 成功 1:活动结束 2 发生错误
  1442. */
  1443. addLotteryTimes: async function(sid) {
  1444. return new Promise((resolve) => {
  1445. Ajax.post({
  1446. url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
  1447. hasCookies: true,
  1448. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1449. data: {
  1450.  
  1451. sid: sid,
  1452. action_type: 3,
  1453. csrf: Live_info.csrf_token,
  1454. },
  1455. success: responseText => {
  1456. let res = HNTOOL.strToJson(responseText);
  1457. if (res.code === 0) {
  1458.  
  1459. resolve(0)
  1460. } else if (res.code === 75003) {
  1461.  
  1462. resolve(1)
  1463.  
  1464. } else {
  1465.  
  1466. resolve(2)
  1467. }
  1468. }
  1469. })
  1470. });
  1471. },
  1472. /**
  1473. * 查询用户关注 默认一次查询50
  1474. * @param vmid 用户uid
  1475. * @param pn 页码
  1476. * @returns {Promise<unknown>}
  1477. */
  1478. getMyFollow: async function(vmid, pn) {
  1479. return new Promise((resolve) => {
  1480. Ajax.get({
  1481. url: BILIBLI_PATH.api + '/x/relation/followings',
  1482. queryStringsObj: {
  1483. vmid: vmid,
  1484. pn: pn
  1485. },
  1486. hasCookies: true,
  1487. success: responseText => {
  1488. let res = HNTOOL.strToJson(responseText);
  1489. if (res.code === 0) {
  1490. resolve(res.data)
  1491. } else {
  1492. resolve(null)
  1493. }
  1494. }
  1495. })
  1496. });
  1497. },
  1498.  
  1499.  
  1500. getMyinfo: function() {
  1501. return new Promise((resolve) => {
  1502. Ajax.get({
  1503. url: BILIBLI_PATH.api + '/x/space/myinfo',
  1504. queryStringsObj: {},
  1505. hasCookies: true,
  1506. success: responseText => {
  1507. let res = HNTOOL.strToJson(responseText);
  1508. if (res.code === 0) {
  1509. resolve(res.data)
  1510. } else {
  1511. resolve(null)
  1512. }
  1513. }
  1514. })
  1515. });
  1516. },
  1517.  
  1518. getMyJson: function(url) {
  1519. return new Promise((resolve) => {
  1520. GM_xmlhttpRequest({
  1521. method: "GET",
  1522. url: url,
  1523. onload: function(response) {
  1524. const res = HNTOOL.strToJson((response || {}).responseText)
  1525. resolve(res);
  1526. }
  1527. });
  1528. })
  1529. },
  1530.  
  1531.  
  1532. userInfo: function(mid) {
  1533.  
  1534. Ajax.get({
  1535. url: BILIBLI_PATH.api + '/x/space/acc/info',
  1536. queryStringsObj: {
  1537. mid: mid
  1538. },
  1539. hasCookies: true,
  1540. success: responseText => {
  1541.  
  1542. var json = JSON.parse(responseText);
  1543.  
  1544. if (json.code != 0) {
  1545.  
  1546.  
  1547. }
  1548. }
  1549. });
  1550.  
  1551. },
  1552.  
  1553. sendQmsg: async function(key, msg) {
  1554.  
  1555. $.ajax({
  1556. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  1557.  
  1558. success: function(result) {
  1559.  
  1560. }
  1561. });
  1562.  
  1563.  
  1564. /*GM_xmlhttpRequest({
  1565. method: "GET",
  1566. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  1567. onload: function (response) {
  1568.  
  1569. let json = JSON.parse(response.response);
  1570. if (json.code == 0) {
  1571.  
  1572. javaex.tip({
  1573. content: "自动动态中奖提醒成功!" + json.reason,
  1574. type: "success"
  1575. });
  1576. } else {
  1577. console.log("自动动态中奖提醒失败!" + json.reason);
  1578. javaex.tip({
  1579. content: "自动动态中奖提醒失败!" + json.reason,
  1580. type: "error"
  1581. });
  1582. }
  1583.  
  1584. }
  1585. });*/
  1586.  
  1587. },
  1588.  
  1589. /**
  1590. * 批量关注和拉黑 batchModify
  1591. *
  1592. * https://api.bilibili.com/x/relation/batch/modify
  1593. * @param uid
  1594. */
  1595.  
  1596. batchModify: function(uids, act) {
  1597.  
  1598.  
  1599. Ajax.post({
  1600. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  1601. hasCookies: true,
  1602. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1603. data: {
  1604.  
  1605. "fids": uids,
  1606. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  1607. "re_src": 151,
  1608. csrf: Live_info.csrf_token,
  1609. },
  1610. success: responseText => {
  1611.  
  1612. let json = JSON.parse(responseText);
  1613.  
  1614. if (/^{"code":0/.test(responseText)) {
  1615.  
  1616. javaex.tip({
  1617. content: `执行成功!---失败(` + json.data.failed_fids.length + `/15)名单:` + json.data.failed_fids,
  1618. type: "success"
  1619. });
  1620.  
  1621. } else {
  1622. javaex.tip({
  1623. content: "关注失败!" + json.message,
  1624. type: "error"
  1625. });
  1626. }
  1627. }
  1628. })
  1629. },
  1630.  
  1631.  
  1632. /**
  1633. * //https://api.bilibili.com/x/relation/modify
  1634. *
  1635. * @param UID
  1636. */
  1637. disUserByUid: function(vmid) {
  1638.  
  1639. Ajax.post({
  1640. url: BILIBLI_PATH.api + '/x/relation/modify',
  1641. data: {
  1642. fid: parseInt(vmid),
  1643. re_src: 11,
  1644. act: 5,
  1645. jsonp: "jsonp",
  1646. csrf: Live_info.csrf_token,
  1647. },
  1648. hasCookies: true,
  1649. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1650. success: responseText => {
  1651.  
  1652. var json = JSON.parse(responseText);
  1653.  
  1654. if (json.code != 0) {
  1655.  
  1656. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  1657. javaex.tip({
  1658. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  1659. type: "error"
  1660. });
  1661.  
  1662. } else {
  1663. console.log("拉黑用户成功 uid:" + vmid);
  1664. javaex.tip({
  1665. content: "拉黑用户成功 uid:" + vmid,
  1666. type: "success"
  1667. });
  1668. }
  1669. }
  1670. });
  1671.  
  1672. },
  1673. /**
  1674. * http://api.bilibili.com/x/web-interface/view
  1675. * @param BV
  1676. * 心跳间隔15秒
  1677. */
  1678. playOneVideo: function(BV, MID) {
  1679.  
  1680. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  1681. Ajax.post({
  1682. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  1683. hasCookies: true,
  1684. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1685. data: {
  1686.  
  1687. "bvid": BV,
  1688. "part": 1,
  1689. "mid": Live_info.uid,
  1690. "lv": 2,
  1691. "jsonp": "jsonp",
  1692. "type": 3,
  1693. "sub_type": 0
  1694. },
  1695. success: responseText => {
  1696.  
  1697. let json = JSON.parse(responseText);
  1698.  
  1699. if (/^{"code":0/.test(responseText)) {
  1700. //发送一次心跳
  1701. HNAPI.sendHeartbeat(BV, MID);
  1702.  
  1703. } else {
  1704. javaex.tip({
  1705. content: "视频" + data.bvid + "播放失败!" + json.message,
  1706. type: "error"
  1707. });
  1708. }
  1709. }
  1710. })
  1711.  
  1712.  
  1713. },
  1714.  
  1715. //上报视频播放心跳(web端)
  1716. /**
  1717. * http://api.bilibili.com/x/click-interface/web/heartbeat
  1718. * @param json
  1719. */
  1720. sendHeartbeat: function(bvid, MID) {
  1721.  
  1722. Ajax.post({
  1723. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  1724. hasCookies: true,
  1725. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1726. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  1727. data: {
  1728. "bvid": bvid,
  1729. "type": 3,
  1730. "dt": 2,
  1731. "played_time": HNTOOL.random(12, 40),
  1732. "realtime": HNTOOL.random(12, 40),
  1733. "play_type": 0
  1734. },
  1735. success: responseText => {
  1736.  
  1737. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  1738.  
  1739. javaex.tip({
  1740. content: "视频BV" + bvid + "播放一次!",
  1741. type: "success"
  1742. });
  1743. }
  1744. }
  1745. })
  1746.  
  1747. },
  1748.  
  1749. //获取up所有投稿视频
  1750. /**
  1751. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  1752. * @param mid
  1753. */
  1754. getUpAllBV: function(mid, pn, ps) {
  1755. ps = (ps === undefined ? 30 : ps); // a默认值为1
  1756. Ajax.get({
  1757. url: BILIBLI_PATH.api + '/x/space/arc/search',
  1758. queryStringsObj: {
  1759. mid: mid,
  1760. tid: 0,
  1761. order: 'pubdate',
  1762. jsonp: 'jsonp',
  1763. pn: pn,
  1764. ps: ps
  1765. },
  1766. hasCookies: true,
  1767. success: responseText => {
  1768.  
  1769. var json = JSON.parse(responseText);
  1770.  
  1771. if (json.code != 0) {
  1772.  
  1773. javaex.tip({
  1774. content: "获取up所有投稿视频失败!" + json.message,
  1775. type: "success"
  1776. });
  1777.  
  1778. } else {
  1779. BiliData.BVList = json.data.list.vlist;
  1780.  
  1781. }
  1782. }
  1783. });
  1784.  
  1785. },
  1786.  
  1787.  
  1788. /**
  1789. *
  1790. * @param path
  1791. * @param data
  1792. * @param saveObj
  1793. * @param Func
  1794. */
  1795. publicGet: function(path, queryStringsObj) {
  1796.  
  1797. if (typeof(queryStringsObj) != "undefined") {
  1798. queryStringsObj = {};
  1799. }
  1800. Ajax.get({
  1801. url: BILIBLI_PATH.api + path,
  1802. queryStringsObj: queryStringsObj,
  1803. hasCookies: true,
  1804. success: responseText => {
  1805.  
  1806. let json = JSON.parse(responseText);
  1807. if (chackCode(json.code) && json.code == 0) {
  1808.  
  1809. return json.data;
  1810. }
  1811.  
  1812. return false;
  1813.  
  1814. }
  1815. })
  1816.  
  1817. },
  1818.  
  1819. /**
  1820. * 导航栏用户信息
  1821. */
  1822. getUserNav: async function() {
  1823.  
  1824. GM_xmlhttpRequest({
  1825. method: "GET",
  1826. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  1827. //timeout:3000,
  1828. onload: function(response) {
  1829.  
  1830. let json = JSON.parse(response.response);
  1831. console.log(json);
  1832. BiliData.login_code = json.code;
  1833. BiliData.login_message = json.message;
  1834. BiliData.LoginData = json.data;
  1835.  
  1836. }
  1837. });
  1838.  
  1839. },
  1840.  
  1841. /**
  1842. * 获取某up详细信息
  1843. * http://api.bilibili.com/x/web-interface/card
  1844. */
  1845. getUpCard: function(mid) {
  1846.  
  1847. Ajax.get({
  1848. url: BILIBLI_PATH.api + '/x/web-interface/card',
  1849. queryStringsObj: {
  1850. mid: mid,
  1851. photo: false
  1852. },
  1853. hasCookies: true,
  1854. success: responseText => {
  1855.  
  1856. var json = JSON.parse(responseText);
  1857.  
  1858. if (json.code != 0) {
  1859.  
  1860. javaex.tip({
  1861. content: "查询失败!" + json.message,
  1862. type: "success"
  1863. });
  1864. return false;
  1865. } else {
  1866. BiliData.upCard = json;
  1867.  
  1868. }
  1869.  
  1870.  
  1871. }
  1872. })
  1873.  
  1874. },
  1875.  
  1876. /**
  1877. *
  1878. * @param uid 用户uid
  1879. * @param ps 每页视频个数 默认30个
  1880. * @param pn 第几页
  1881. */
  1882. getUpAllVideo: function(uid, ps, pn) {
  1883.  
  1884. },
  1885. getChallenge: async function() {
  1886.  
  1887.  
  1888. },
  1889. /**
  1890. * 硬币记录
  1891. * @returns {Promise<void>}
  1892. */
  1893. getCoinLog: async function() {
  1894.  
  1895. GM_xmlhttpRequest({
  1896. method: "GET",
  1897. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  1898. //url: "http://api.bilibili.com/x/member/web/coin/log",
  1899. onload: function(response) {
  1900.  
  1901. let json = JSON.parse(response.response);
  1902. if (json.code == 0) {
  1903.  
  1904. console.log("硬币记录" + json);
  1905. BiliData.CoinLog = json.data;
  1906.  
  1907. return true;
  1908. }
  1909.  
  1910. }
  1911. });
  1912. },
  1913. /**
  1914. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  1915. * @returns {Promise<void>}
  1916. */
  1917. getUnread: async function() {
  1918.  
  1919. Ajax.get({
  1920. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1921. hasCookies: true,
  1922. success: responseText => {
  1923.  
  1924. let json = JSON.parse(responseText);
  1925. if (chackCode(json.code) && json.code == 0) {
  1926.  
  1927. BiliData.Unread = json.data;
  1928. showUnreadMsg();
  1929. }
  1930.  
  1931. return false;
  1932.  
  1933. }
  1934. })
  1935.  
  1936. /* GM_xmlhttpRequest({
  1937. method: "GET",
  1938. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1939. onload: function (response) {
  1940.  
  1941. let json = JSON.parse(response.response);
  1942.  
  1943. if (chackCode(json.code) && json.code == 0) {
  1944.  
  1945. BiliData.Unread = json.code;
  1946. showUnreadMsg();
  1947.  
  1948. }
  1949.  
  1950. }
  1951. });*/
  1952. },
  1953. /**
  1954. *
  1955. * @param type reply:回复我的 at @我的
  1956. */
  1957. getMsgfeed: function(type) {
  1958. Ajax.get({
  1959. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  1960. queryStringsObj: {
  1961. build: 0,
  1962. mobi_app: 'web'
  1963. },
  1964. hasCookies: true,
  1965. success: responseText => {
  1966.  
  1967. var json = JSON.parse(responseText);
  1968.  
  1969. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  1970. return false;
  1971. } else {
  1972. chackAtMsg(json.data.items);
  1973.  
  1974. return true;
  1975. }
  1976.  
  1977.  
  1978. }
  1979. })
  1980.  
  1981. },
  1982.  
  1983. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  1984. * @returns {Promise<void>}
  1985. */
  1986. getUnrewad: async function() {
  1987.  
  1988. GM_xmlhttpRequest({
  1989. method: "GET",
  1990. data: {
  1991. "mid": 99439379,
  1992. "pn": 1,
  1993. "ps": 5,
  1994. },
  1995. url: BILIBLI_PATH.api + "/x/space/arc/search",
  1996. onload: function(response) {
  1997.  
  1998. let json = JSON.parse(response.response);
  1999. if (json.code == 0) {
  2000.  
  2001. BiliData.Video = json.data;
  2002. console.log("未读消息数" + json);
  2003. }
  2004.  
  2005. }
  2006. });
  2007. },
  2008.  
  2009. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  2010. * @param {number} oid
  2011. * @param {nbumber} rpid
  2012. * @param {number} action
  2013. * @returns {Promise<void>}
  2014. * type: 11
  2015. * ordering: heat
  2016. * jsonp: jsonp
  2017. * csrf: 54a******* CSRF Token(位于cookie)
  2018. */
  2019.  
  2020. likeInDynamicComments: async function(oid, rpid, action) {
  2021.  
  2022.  
  2023. Ajax.post({
  2024. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  2025. hasCookies: true,
  2026. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2027. data: {
  2028. "oid": oid,
  2029. "type": 11,
  2030. "rpid": rpid,
  2031. "action": action,
  2032. "ordering": "heat",
  2033. "jsonp": "jsonp",
  2034. "csrf": Live_info.csrf_token,
  2035. },
  2036. success: responseText => {
  2037.  
  2038. if (/^{"code":0/.test(responseText)) {
  2039.  
  2040. BiliData.replyAction = JSON.parse(responseText);
  2041. console.log("点赞成功!" + responseText);
  2042. }
  2043. }
  2044. })
  2045.  
  2046. }
  2047.  
  2048.  
  2049. }
  2050.  
  2051. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  2052.  
  2053.  
  2054. let HNTOOL = {
  2055.  
  2056.  
  2057. copyText: function(domId) {
  2058. let btn = document.getElementById(domId);
  2059. btn.select();
  2060. if (document.execCommand('copy')) {
  2061. document.execCommand('copy');
  2062. javaex.tip({
  2063. content: "复制成功!",
  2064. type: "success"
  2065. });
  2066. }
  2067.  
  2068. },
  2069. /**
  2070. * s数组去重并排序
  2071. */
  2072.  
  2073. arrUnique: function(ary) {
  2074.  
  2075. let obj = {};
  2076. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  2077. let item = ary[i]
  2078. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  2079. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  2080. // 如果没有 将这个元素添加到对象中
  2081. ary.sort((a, b) => {
  2082. return a - b
  2083. }) // 数组去重后 按升序排列
  2084. obj = null;
  2085.  
  2086. javaex.tip({
  2087. content: "已去重!",
  2088. type: "success"
  2089. });
  2090. return ary;
  2091.  
  2092. },
  2093.  
  2094. split_array: function(arr, len) {
  2095.  
  2096. let arr_length = arr.length;
  2097. let newArr = [];
  2098. for (let i = 0; i < arr_length; i += len) {
  2099. newArr.push(arr.slice(i, i + len));
  2100. }
  2101. return newArr;
  2102. },
  2103. strToJson: function(params) {
  2104. const isJSON = (str => {
  2105. if (typeof str === 'string') {
  2106. try {
  2107. const obj = JSON.parse(str);
  2108. return typeof obj === 'object' ? obj : false
  2109. } catch (_) {
  2110. console.log(str);
  2111. return false;
  2112. }
  2113. } else {
  2114. console.log(`${str}\nIt is not a string!`);
  2115. return false;
  2116. }
  2117. })(params);
  2118. return isJSON ? isJSON : {}
  2119. },
  2120.  
  2121. chackAtMsg: function() {
  2122.  
  2123. let config = HNTOOL.getConfig();
  2124. if (config.qmsg_checked == true && config.qmsg_key) {
  2125.  
  2126. document.getElementById("getAtMsg").click();
  2127.  
  2128. }
  2129.  
  2130. },
  2131.  
  2132. cssChecked: function(id, dom) {
  2133.  
  2134. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  2135.  
  2136.  
  2137. },
  2138. getConfig: function() {
  2139.  
  2140. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  2141.  
  2142. if (CONFIG == null) {
  2143. CONFIG = HN_SETUP_CONFIG;
  2144. }
  2145.  
  2146. return CONFIG;
  2147. },
  2148.  
  2149. /**
  2150. * 获取cookie 中某个键对应的值
  2151. * @param name
  2152. */
  2153.  
  2154. getCookie: function(name) {
  2155. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  2156. if (arr != null) return unescape(arr[2]);
  2157. return false;
  2158. },
  2159. /**
  2160. * 得到一个字符串数组的中随机一个
  2161. * @param {List} list
  2162. */
  2163. getRandomWordOfList: function(list) {
  2164. var L = list.length;
  2165. var i = Math.ceil(Math.random() * L);
  2166.  
  2167. return list[i];
  2168. },
  2169. random: function(min, max) {
  2170.  
  2171. return Math.floor(Math.random() * (max - min)) + min;
  2172. },
  2173.  
  2174. Sleep: function(ms) {
  2175. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  2176. }
  2177.  
  2178. }
  2179.  
  2180. let errorMsg = {
  2181. "-1": "应用程序不存在或已被封禁!",
  2182. "-2": "Access Key错误!",
  2183. "-3": "API校验密匙错误!",
  2184. "-4": "调用方对该Method没有权限!",
  2185. "-101": "账号未登录!",
  2186. "-102": "账号被封停!",
  2187. "-103": "积分不足!",
  2188. "-104": "硬币不足!",
  2189. "-105": "验证码错误!",
  2190. "-106": "账号非正式会员或在适应期!",
  2191. "-107": "应用不存在或者被封禁!",
  2192. "-108": "未绑定手机!",
  2193. "-109": "未知!",
  2194. "-110": "未绑定手机!",
  2195. "-111": "csrf 校验失败!",
  2196. "-112": "系统升级中!",
  2197. "-113": "账号尚未实名认证!",
  2198. "-114": "请先绑定手机!",
  2199. "-115": "请先完成实名认证!",
  2200. "-304": "木有改动!",
  2201. "-307": "撞车跳转!",
  2202. "-400": "请求错误!",
  2203. "-401": "未认证!",
  2204. "-403": "访问权限不足!",
  2205. "-404": "啥都木有!",
  2206. }
  2207.  
  2208. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  2209. /**
  2210. *
  2211. * @param code
  2212. * @constructor
  2213. */
  2214. let chackCode = function(code) {
  2215.  
  2216. let emsg = errorMsg[code + ""];
  2217. if (emsg != null) {
  2218. javaex.tip({
  2219. content: emsg,
  2220. type: "error"
  2221. });
  2222.  
  2223. return false;
  2224. }
  2225.  
  2226. return true;
  2227. }
  2228.  
  2229.  
  2230. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  2231. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  2232.  
  2233. /*window.onbeforeunload = function() {
  2234. if (!canLeavePage()) {
  2235. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  2236. }
  2237. };*/
  2238.  
  2239.  
  2240. /**
  2241. * Ajax请求对象
  2242. */
  2243. const Ajax = (() => {
  2244. /**
  2245. * 检查options是否符合要求
  2246. * @param {object} options
  2247. * @returns {boolean}
  2248. */
  2249. function checkOptions(options) {
  2250. let result = false;
  2251. if (typeof options !== 'object') {
  2252. console.warn('类型错误: typeof Options !== Object');
  2253. return result;
  2254. } else {
  2255. if (typeof options.url !== 'string') {
  2256. console.warn('类型错误: typeof Link !== Strings');
  2257. return result;
  2258. } else {
  2259. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  2260. if (!reg.test(options.url)) {
  2261. console.warn('url字符串须为完整http链接');
  2262. return result;
  2263. }
  2264. result = true;
  2265. }
  2266. }
  2267. return result;
  2268. }
  2269.  
  2270. /**
  2271. * 对象转URL编码
  2272. * @param {object} data
  2273. */
  2274. function objToURLCode(data) {
  2275. var _result = [];
  2276. for (var key in data) {
  2277. var value = data[key];
  2278. if (value instanceof Array) {
  2279. value.forEach(function(_value) {
  2280. _result.push(key + "=" + _value);
  2281. });
  2282. } else {
  2283. _result.push(key + '=' + value);
  2284. }
  2285. }
  2286. return _result.join('&');
  2287. }
  2288.  
  2289. /**
  2290. * 请求
  2291. * @param {string} method
  2292. * @param {object} options
  2293. */
  2294. function request(method, options) {
  2295. if (checkOptions(options)) {
  2296. let xhr = new XMLHttpRequest();
  2297. const {
  2298. url: _url,
  2299. queryStringsObj,
  2300. data,
  2301. dataType,
  2302. hasCookies
  2303. } = options, url = typeof queryStringsObj === 'object' ?
  2304. _url + '?' + objToURLCode(queryStringsObj) : _url;
  2305. switch (method) {
  2306. case 'GET':
  2307. xhr.open("GET", url);
  2308. break;
  2309. case 'POST':
  2310. xhr.open("POST", url);
  2311. xhr.setRequestHeader('Content-Type', dataType);
  2312. break;
  2313. default:
  2314. break;
  2315. }
  2316. if (hasCookies) xhr.withCredentials = true;
  2317. xhr.timeout = 3000;
  2318. xhr.addEventListener('load', () => {
  2319. if (xhr.status === 200) {
  2320. options.success(xhr.responseText)
  2321. } else {
  2322. console.error(`status:${xhr.status}`);
  2323. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  2324. }
  2325. })
  2326. xhr.addEventListener('error', () => {
  2327. console.error('ajax请求出错')
  2328. options.success('{"code":-1,"msg":"ajax请求出错"}');
  2329. })
  2330. xhr.addEventListener('timeout', () => {
  2331. console.error('请求超时')
  2332. options.success('{"code":-1,"msg":"请求超时"}');
  2333. })
  2334. switch (method) {
  2335. case 'GET':
  2336. xhr.send()
  2337. break;
  2338. case 'POST':
  2339. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  2340. break;
  2341. default:
  2342. break;
  2343. }
  2344. }
  2345. }
  2346.  
  2347. return {
  2348. /**
  2349. * 发送Get请求
  2350. * @param {Object} options
  2351. */
  2352. get(options) {
  2353. request("GET", options);
  2354. },
  2355. /**
  2356. * 发送Post请求
  2357. * @param {object} options
  2358. */
  2359. post(options) {
  2360. request("POST", options);
  2361. }
  2362. }
  2363. })()