-哔哩猫-(试用版)

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

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

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