-哔哩猫-(试用版)

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

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

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