-哔哩猫-(试用版)

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

Fra 03.08.2021. Se den seneste versjonen.

Dette scriptet burde ikke installeres direkte. Det er et bibliotek for andre script å inkludere med det nye metadirektivet // @require https://update.greatest.deepsurf.us/scripts/422731/956989/-%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 2.1.0
  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. .hideLogo {
  74. position: absolute;
  75. top: 88px;
  76. left: 10px;
  77. width: 50px;
  78. height: 57px;
  79. z-index: 9999;
  80. cursor: pointer;
  81. }
  82. `
  83. );
  84.  
  85.  
  86. let HN_SETUP_CONFIG = {
  87.  
  88. qmsg_key: null, //后期改为kull 存储到本地
  89. qmsg_checked: false,
  90. Booking_last_sid: null,
  91. }
  92.  
  93. let replyList = ["哇⊙ω⊙", "仙女震惊", "都关注这么久了给个吧", "大佬,看下孩子吧,这次一定", "会有我吗?黑幕一手",
  94. "酋长在线拉低中奖率", "好耶(✪▽✪)", "好运", "希望欧一次", "永不缺席", " 永不中奖", " 永不放弃!", "万一呢", "在", "冲吖~", "来了",
  95. "芜湖,都想要,抽中那个都不亏阿", "从未中,从未停", "来力", "秋", "懂我意思吧", "今天去吃面", "从不缺席",
  96. "站友保佑抽到", "可以", "恰", "不会吧", "233", "好耶", "rush", "来了!!!", "来来", "ok", "冲", "凑热闹", "我要我要", "我还能中!", "让我中!!!",
  97. "是我的", "我是天选之子?", "给我中一次吧!", "坚持不懈,迎难而上", "开拓创新!", "我来抽个奖", "中中中中中", "我我我", "搞笑 这不得转", "我下手了",
  98. "看这里就想中一次", "不可能", "我不挑,都可以", "俺要当分母", "万一呢"
  99. ]
  100.  
  101.  
  102. let Live_info = {
  103. room_id: undefined,
  104. uid: undefined,
  105. blocked: undefined,
  106. csrf_token: undefined,
  107. SESSDATA: undefined,
  108. visit_id: undefined,
  109. rnd: undefined,
  110. ruid: undefined,
  111. uname: undefined,
  112. user_level: undefined,
  113. ruid: undefined,
  114. };
  115.  
  116. let BILIBLI_PATH = {
  117.  
  118. "live": "https://api.live.bilibili.com",
  119. "vcapi": "https://api.vc.bilibili.com",
  120. "passport": "https://passport.bilibili.com",
  121. "api": "https://api.bilibili.com",
  122. "video": "https://www.bilibili.com/video/",
  123. "single_unread": "http://api.vc.bilibili.com/",
  124.  
  125. }
  126.  
  127. let BILIBILI_URL = {
  128. // 导航栏用户信息
  129. "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
  130. }
  131.  
  132. let BiliData = {
  133.  
  134. this_uid: window.location.href.split("/")[3], //当前页面uid
  135. author_uid: 99439379,
  136. login_code: null,
  137. login_message: "",
  138. LoginData: {},
  139. CoinLog: {},
  140. Unread: null,
  141. Video: {},
  142. replyAction: {},
  143. upCard: {},
  144. BVList: [],
  145. }
  146.  
  147. window.onload = function() {
  148.  
  149.  
  150. //界面显示
  151. init();
  152.  
  153. addHideLogo();
  154.  
  155. /* var myVar = setInterval(function() {
  156. console.log("yunxing");
  157. AA ();
  158. }, 1000);
  159. function AA (){
  160. if ((new Date()).getMinutes() == 47) {
  161. console.log("stop");
  162. clearInterval(myVar);
  163. }
  164. } */
  165.  
  166.  
  167. }
  168.  
  169. function addHideLogo() {
  170.  
  171. let isHide = true;
  172.  
  173. $("#left_navbar").after(
  174. '<div id="hideLogo" class="hideLogo"> <img src="https://gitee.com/java_cn/BILIBLI_RES/raw/master/PIC/PC_1606377718.gif" alt="点击显示隐藏" width="100%" height="100%"></div>'
  175. );
  176. if (isHide) {
  177. $("#left_navbar").hide();
  178. isHide = false;
  179. } else {
  180. isHide = true;
  181. }
  182. $("#hideLogo").bind("click", async function() {
  183.  
  184. if (isHide) {
  185. $("#left_navbar").hide();
  186. isHide = false;
  187. } else {
  188. $("#left_navbar").show();
  189. isHide = true;
  190. }
  191. });
  192.  
  193. }
  194.  
  195.  
  196. function init() {
  197.  
  198. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  199. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  200. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  201.  
  202. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&54988";
  203.  
  204.  
  205. addStyle();
  206. addSetPage();
  207.  
  208. HNTOOL.chackAtMsg();
  209.  
  210. $("#getCoinLog").bind("click", async function() {
  211.  
  212.  
  213. if (HNAPI.getCoinLog()) {
  214.  
  215. await HNTOOL.Sleep(500);
  216. let html = '';
  217. html += '<div class="javaex-panel-box" style="width: 250px;">';
  218. html += ' <ul>';
  219. html += ` <p style="color: #FFF;">硬币使用记录</p>`;
  220.  
  221. BiliData.CoinLog.list.forEach(function(item) {
  222.  
  223. let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
  224. if (BV.indexOf("BV") != -1) {
  225. html += `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
  226. }
  227. html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
  228.  
  229.  
  230. });
  231. html += ' <hr class="javaex-divider"></hr>';
  232. html += ' </ul>';
  233. html += '</div>';
  234.  
  235. javaex.panel(this, {
  236. position: "right",
  237. //offsetTop: "104",
  238. content: html
  239. });
  240. javaex.tip({
  241. content: "获取用户成功!",
  242. type: "success"
  243. });
  244.  
  245. } else {
  246. javaex.tip({
  247. content: "获取硬币记录失败,请稍后重试!",
  248. type: "error"
  249. });
  250. }
  251.  
  252.  
  253. });
  254.  
  255. $("#getUnread").bind("click", async function() {
  256.  
  257. javaex.tip({
  258. content: "获取中,请稍候...",
  259. type: "submit"
  260. });
  261. HNAPI.getUnread();
  262.  
  263.  
  264. });
  265.  
  266.  
  267. $("#likeInDynamicComments").bind("click", async function() {
  268.  
  269. let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get("likeInDynamic_PRID");
  270. let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get("likeInDynamic_OID");
  271.  
  272. let html = '';
  273.  
  274. html += '<div style="padding: 10px 10px 10px 0px;">'
  275. html += '<form id="likeInDynamic_form">'
  276. html += ' <div class="javaex-unit clear">'
  277. html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
  278. html += ' <div class="javaex-unit-right">'
  279. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
  280. html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
  281. html += ' </div>'
  282. html += ' </div>'
  283. html += ' <div class="javaex-unit clear">'
  284. html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
  285. html += ' <div class="javaex-unit-right">'
  286. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
  287. html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
  288. html += ' </div>'
  289. html += ' </div>'
  290. html += ' <div class="javaex-unit clear tc">'
  291. html +=
  292. ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
  293. html +=
  294. ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
  295. html += ' </div>'
  296. html += '</form>';
  297. html += '<hr class="javaex-divider"></hr>';
  298. html += '</div>';
  299.  
  300.  
  301. javaex.panel(this, {
  302. position: "right",
  303. content: html
  304. });
  305.  
  306.  
  307. // 监听点击保存按钮事件
  308. $("#likeInDynamic_yes").click(async function() {
  309. // 表单验证函数
  310. if (javaexVerify()) {
  311.  
  312. HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex.getSelectVal(
  313. "#likeInDynamic_PRID"), 1);
  314. await HNTOOL.Sleep(1000);
  315.  
  316. if (BiliData.replyAction.code == 0) {
  317.  
  318. LocalData.set("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  319. LocalData.set("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  320.  
  321. javaex.tip({
  322. content: "评论区点赞成功!",
  323. type: "success"
  324. });
  325. } else {
  326. javaex.tip({
  327. content: "评论区点赞失败!",
  328. type: "error"
  329. });
  330. }
  331. if (BiliData.replyAction.code == 65006) {
  332. javaex.tip({
  333. content: "请勿重复点赞!",
  334. type: "error"
  335. });
  336. }
  337. }
  338. });
  339.  
  340. // 监听点击返回按钮事件
  341. $("#likeInDynamic_no").click(async function() {
  342.  
  343. if (javaexVerify()) {
  344.  
  345. HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +javaex.getLocalStorage(
  346. "#likeInDynamic_PRID"), 0);
  347. await HNTOOL.Sleep(500);
  348.  
  349. if (BiliData.replyAction.code == 0) {
  350.  
  351. javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  352. javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  353.  
  354. javaex.tip({
  355. content: "评论区取消点赞成功!",
  356. type: "success"
  357. });
  358. } else {
  359. javaex.tip({
  360. content: "评论区取消点赞失败!",
  361. type: "error"
  362. });
  363. }
  364. if (BiliData.replyAction.code == 65006) {
  365. javaex.tip({
  366. content: "请勿重复取消点赞!",
  367. type: "error"
  368. });
  369. }
  370. }
  371. });
  372.  
  373. });
  374.  
  375. $("#biliUserMsg").bind("click", async function() {
  376.  
  377.  
  378. //刷新信息
  379. HNAPI.getUserNav();
  380. await HNTOOL.Sleep(500);
  381.  
  382. let isLogin = "未登录";
  383. let vipType = "无";
  384. //判断是否成功
  385. if (BiliData.login_code == 0) {
  386.  
  387.  
  388. if (BiliData.LoginData.isLogin) {
  389. isLogin = "已登录";
  390. }
  391.  
  392. if (BiliData.LoginData.vipType == 1) {
  393. vipType = "月度大会员";
  394. } else if (BiliData.LoginData.vipType == 2) {
  395. vipType = "年度大会员";
  396. }
  397.  
  398. let html = '';
  399. html += '<div class="javaex-panel-box" style="width: 250px;">';
  400. html += ' <ul>';
  401. html += ` <p style="color: #FFF;">用户信息</p>`;
  402. html += ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
  403. html += ` <li>用户状态:${isLogin} </li> `;
  404. html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
  405. html +=
  406. ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
  407. html += ` <li>UID${BiliData.LoginData.mid} </li> `;
  408. html += ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
  409. html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
  410. html += ` <li>会员:${vipType} </li> `;
  411. html += ' <hr class="javaex-divider"></hr>';
  412. html += ' </ul>';
  413. html += '</div>';
  414.  
  415.  
  416. javaex.panel(this, {
  417. position: "right",
  418. content: html
  419. });
  420.  
  421. javaex.tip({
  422. content: "获取用户成功!",
  423. type: "success"
  424. });
  425.  
  426. } else {
  427. javaex.tip({
  428. content: "获取用户信息失败!",
  429. type: "error"
  430. });
  431. }
  432.  
  433.  
  434. });
  435.  
  436. $("#getAtMsg").bind("click", async function() {
  437.  
  438. if (HNAPI.getMsgfeed("at") && typeof(HNAPI.getMsgfeed("at")) != "undefined") {
  439.  
  440. javaex.tip({
  441. content: "可能中奖了!!!",
  442. type: "success"
  443. });
  444. }
  445. });
  446.  
  447.  
  448. $("#disUser").bind("click", async function() {
  449.  
  450. let html = '';
  451. html += '<div class="javaex-panel-box" style="width: 500px;">';
  452. html += ' <div class="javaex-unit clear">';
  453. html += ' <div class="javaex-unit-left ml-10 mt-10">*UID列表</div>';
  454. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  455. html +=
  456. ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
  457. html += ' </div>';
  458. html += ' </div>';
  459. html += ' <div class="javaex-unit clear tc">';
  460. html += ' <input type="button" id="disUser_block" class="javaex-btn yes" value="拉黑" />';
  461. html += ' <input type="button" id="disUser_cancelAtt_uid" class="javaex-btn yes" value="UID取关" />';
  462. html += ' <input type="button" id="disUser_cancelAtt_room" class="javaex-btn yes" value="房间号取关" />';
  463. html += ' </div>';
  464. html += '</div>';
  465.  
  466. javaex.panel(this, {
  467. position: "right",
  468. content: html
  469. });
  470.  
  471. let disUser_str;
  472. //拉黑
  473. $("#disUser_block").bind("click", async function() {
  474.  
  475. disUser_str = javaex.getSelectVal("#disUser_uidList");
  476. let disUser_uidList = disUser_str.split(",");
  477. let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
  478.  
  479. for (const vmid of disUserStr) {
  480.  
  481. HNAPI.batchModify(vmid.toString(), 5);
  482. await HNTOOL.Sleep(2000);
  483. }
  484. });
  485. //取关uid
  486. $("#disUser_cancelAtt_uid").bind("click", async function() {
  487. disUser_str = javaex.getSelectVal("#disUser_uidList");
  488. let disUser_uidList = disUser_str.split(",");
  489.  
  490. javaex.tip({
  491. content: "根据uid批量取关开始!!!",
  492. type: "success"
  493. });
  494.  
  495. /*
  496. let disuidList = [];
  497. let PN = 100;
  498. PN = disUser_uidList.length == 1 ? 0 : PN;
  499.  
  500. for (var i = 0; i < PN; i++) {
  501.  
  502. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  503. javaex.tip({
  504. content: "获取第" + i + "页黑名单成功!",
  505. type: "success"
  506. });
  507. await HNTOOL.Sleep(1000);
  508.  
  509. if (uidList.length == 0) {
  510. break;
  511. }
  512. if (uidList == null) {
  513. continue;
  514. }
  515.  
  516. for (let disuid of uidList) {
  517. if (disuidList.indexOf(disuid.mid) == -1) {
  518. disuidList.push(disuid.mid + "");
  519. }
  520. }
  521.  
  522.  
  523. } */
  524. let J = 1;
  525.  
  526. for (let uid of disUser_uidList) {
  527.  
  528. /* let uidType = "未在黑名单";
  529. if (disuidList.indexOf(uid) == -1) {
  530.  
  531. await HNAPI.cancelAtt(uid, 2);
  532. } else {
  533.  
  534. await HNAPI.cancelAtt(uid, 6, 116);
  535. uidType = "黑名单用户";
  536. } */
  537. await HNAPI.cancelAtt(uid, 2);
  538.  
  539. javaex.tip({
  540. content: "【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" + disUser_uidList.length + ")",
  541. type: "success"
  542. });
  543. await HNTOOL.Sleep(1000);
  544. }
  545.  
  546.  
  547. alert("根据uid批量取关完成!");
  548.  
  549. /* javaex.alert({
  550. content: "根据uid批量取关完成!",
  551. confirm: function() {
  552.  
  553. //return false;
  554. }
  555. }); */
  556.  
  557. });
  558. //取关room
  559. $("#disUser_cancelAtt_room").bind("click", async function() {
  560.  
  561. javaex.tip({
  562. content: "根据房间号批量取关开始!!!",
  563. type: "success"
  564. });
  565.  
  566. disUser_str = javaex.getSelectVal("#disUser_uidList");
  567. let disUser_roomList = disUser_str.split(",");
  568. /* let disuidList = [];
  569. let PN = 100;
  570. PN = disUser_roomList.length == 1 ? 0 : PN;
  571.  
  572. for (var i = 0; i < PN; i++) {
  573.  
  574. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  575. javaex.tip({
  576. content: "获取第" + i + "页黑名单成功!",
  577. type: "success"
  578. });
  579. await HNTOOL.Sleep(1000);
  580.  
  581. if (uidList.length == 0) {
  582. break;
  583. }
  584. if (uidList == null) {
  585. continue;
  586. }
  587.  
  588. for (let disuid of uidList) {
  589.  
  590. if (disuidList.indexOf(disuid.mid) == -1) {
  591. disuidList.push(disuid.mid);
  592. }
  593.  
  594. }
  595.  
  596.  
  597. } */
  598. let J = 1;
  599. for (let room of disUser_roomList) {
  600.  
  601. let uid = await HNAPI.getRoomMsg(room);
  602.  
  603. await HNTOOL.Sleep(1000);
  604.  
  605. if (uid == false) {
  606. javaex.tip({
  607. content: "uid查询失败跳过!",
  608. type: "error"
  609. });
  610. continue;
  611. }
  612. /* let uidType = "未在黑名单";
  613. if (disuidList.indexOf(uid) == -1) {
  614.  
  615. await HNAPI.cancelAtt(uid, 2);
  616. } else {
  617.  
  618. await HNAPI.cancelAtt(uid, 6, 116);
  619. uidType = "黑名单用户";
  620. } */
  621. await HNAPI.cancelAtt(uid, 2);
  622.  
  623. javaex.tip({
  624. content: "Room:" + room + "-【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" + disUser_roomList.length +
  625. ")",
  626. type: "success"
  627. });
  628. await HNTOOL.Sleep(1000);
  629.  
  630.  
  631. }
  632. alert("根据房间号批量取关完成!");
  633. /* javaex.alert({
  634. content: ,
  635. confirm: function() {
  636.  
  637. return false;
  638. }
  639. }); */
  640.  
  641. });
  642.  
  643. });
  644.  
  645. $("#getNeetCookie").bind("click", async function() {
  646.  
  647. let html = '';
  648. html += '<div class="javaex-panel-box" style="width: 750px;">';
  649. html += ' <div class="javaex-unit clear">';
  650. html += ' <div class="javaex-unit-left ml-10 mt-10">*cookie</div>';
  651. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  652. html +=
  653. ' <textarea id="neetCookie" class="javaex-desc" placeholder="获取需要的cookie,注意需要取消掉application->cookie>SESSDATA httpOnly 的对钩"></textarea>';
  654. html += ' </div>';
  655. html += ' </div>';
  656. html += ' <div class="javaex-unit clear tc">';
  657. html += ' <input type="button" id="getCookie_type1" class="javaex-btn yes" value="方式一" />';
  658. html += ' <input type="button" id="getCookie_type2" class="javaex-btn yes" value="方式二" />';
  659. html += ' <input type="button" id="getCookie_type3" class="javaex-btn yes" value="方式三" />';
  660. html += ' <input type="button" id="getCookie_copy" class="javaex-btn yes" value="复制" />';
  661. html += ' </div>';
  662. html += '</div>';
  663.  
  664. javaex.panel(this, {
  665. position: "right",
  666. content: html
  667. });
  668.  
  669. $('#getCookie_copy').bind('click', function() {
  670.  
  671. HNTOOL.copyText("neetCookie");
  672.  
  673. });
  674.  
  675. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  676. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  677. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  678.  
  679.  
  680. $("#getCookie_type1").bind("click", async function() {
  681.  
  682. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA.replace(/%25/g, "%") +
  683. "; bili_jct=" + Live_info.csrf_token +
  684. "; "
  685. document.getElementById("neetCookie").value = cookie01;
  686.  
  687. });
  688. $("#getCookie_type3").bind("click", async function() {
  689.  
  690. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA.replace(/%25/g, "%%") +
  691. "; bili_jct=" + Live_info.csrf_token +
  692. "; "
  693. document.getElementById("neetCookie").value = cookie01;
  694.  
  695. });
  696.  
  697. $("#getCookie_type2").bind("click", async function() {
  698.  
  699. var cookie02 = Live_info.uid + "\n" + Live_info.SESSDATA.replace(/%25/g, "%") + "\n" + Live_info.csrf_token;
  700. document.getElementById("neetCookie").value = cookie02;
  701. });
  702.  
  703. });
  704.  
  705. $("#arrUnique").bind("click", async function() {
  706.  
  707. let html = '';
  708. html += '<div class="javaex-panel-box" style="width: 500px;">';
  709. html += ' <div class="javaex-unit clear">';
  710. html += ' <div id="arrNub" class="javaex-unit-left ml-10 mt-10">*数组0</div>';
  711. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  712. html += ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  713. html += ' </div>';
  714. html += ' </div>';
  715. html += ' <div class="javaex-unit clear tc">';
  716. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="去重" />';
  717. //html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="粘贴" />';
  718. html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="复制" />';
  719. html += ' </div>';
  720. html += '</div>';
  721.  
  722. javaex.panel(this, {
  723. position: "right",
  724. content: html
  725. });
  726.  
  727. $('#arrUnique_str').bind('input propertychange', function() {
  728.  
  729. $('#arrNub').text("*数组" + $(this).val().split(",").length);
  730.  
  731. });
  732. $('#arrUnique_copy').bind('click', function() {
  733.  
  734. HNTOOL.copyText("arrUnique_str");
  735.  
  736. });
  737.  
  738.  
  739.  
  740.  
  741. $("#arrUnique_beg").bind("click", async function() {
  742.  
  743. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  744. let arrUnique_uidList = arrUnique_str.split(",");
  745.  
  746. let new_arr = HNTOOL.arrUnique(arrUnique_uidList);
  747.  
  748. document.getElementById("arrUnique_str").value = new_arr.toString();
  749.  
  750. $('#arrNub').text("*数组" + new_arr.length);
  751.  
  752. });
  753.  
  754. });
  755.  
  756. $("#batchFollow").bind("click", async function() {
  757.  
  758. var thisUPName = $("#h-name").text();
  759.  
  760.  
  761. let html = '';
  762. html += '<div class="javaex-panel-box" style="width: 600px;">';
  763. html += ' <div class="javaex-unit clear">';
  764. html += ' <div id="followNub" class="javaex-unit-left ml-10 mt-10">*关注列表0</div>';
  765. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  766. html +=
  767. ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
  768. html += ' </div>';
  769. html += ' </div>';
  770. html += ' <div class="javaex-unit clear tc" >';
  771. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  772. html += ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="爬取全部关注" />';
  773. html += ` <input type="button" id="Follow_thisUp" class="javaex-btn yes tc" value="关注${thisUPName}" />`;
  774. html += ` <input type="button" id="disFollow_thisUp" class="javaex-btn yes tc" value="拉黑${thisUPName}" /> `;
  775. html += ' </div>';
  776. html += '</div>';
  777.  
  778. javaex.panel(this, {
  779. position: "right",
  780. content: html
  781. });
  782.  
  783. $('#batchFollow_uidList').bind('input propertychange', function() {
  784.  
  785. $('#followNub').text("*关注列表" + $(this).val().split(",").length);
  786.  
  787. });
  788.  
  789. $("#disFollow_thisUp").bind("click", async function() {
  790.  
  791. HNAPI.batchModify(BiliData.this_uid, 5);
  792.  
  793. });
  794.  
  795. $("#Follow_thisUp").bind("click", async function() {
  796.  
  797. HNAPI.batchModify(BiliData.this_uid);
  798.  
  799. });
  800.  
  801. $("#batchFollow_beg").bind("click", async function() {
  802.  
  803. let mid_str = javaex.getSelectVal("#batchFollow_uidList");
  804. mid_list = mid_str.split(",");
  805.  
  806. let mid_Lists = HNTOOL.split_array(mid_list, 15);
  807. for (const mids of mid_Lists) {
  808.  
  809. HNAPI.batchModify(mids.toString());
  810. await HNTOOL.Sleep(8000);
  811. }
  812.  
  813. alert("关注完成!")
  814.  
  815. });
  816.  
  817. $("#crawler_follow").bind("click", async function() {
  818.  
  819. //x/space/myinfo
  820. let myinfoData = await HNAPI.getMyinfo();
  821. await HNAPI.getUpCard(myinfoData.mid);
  822. await HNTOOL.Sleep(1000);
  823. let len = parseInt(BiliData.upCard.data.card.attention / 20);
  824. let followData = [];
  825.  
  826. for (let i = 0; i < len; i++) {
  827. if (BiliData.upCard.code != 0) {
  828. javaex.tip({
  829. content: `爬取关注出现异常 终止爬取!{BiliData.upCard.message}`,
  830. type: "error"
  831. });
  832. break;
  833. }
  834.  
  835. javaex.tip({
  836. content: `正在爬取` + myinfoData.mid + `的` + i + `页的关注!!!`,
  837. type: "success"
  838. });
  839.  
  840. let followList = await HNAPI.getMyFollow(myinfoData.mid, i);
  841. if (followList != null) {
  842. for (const fl of followList.list) {
  843.  
  844. /* if (fl.official_verify.type != 1 || fl.vip.vipType == 0) {
  845. continue;
  846. } */
  847.  
  848. followData.push(fl.mid);
  849.  
  850. }
  851. }
  852.  
  853.  
  854. await HNTOOL.Sleep(3000);
  855. }
  856.  
  857. document.getElementById("batchFollow_uidList").value = followData.toString();
  858.  
  859. });
  860.  
  861.  
  862. });
  863.  
  864. $("#batchTargetMedal").bind("click", async function() {
  865.  
  866.  
  867. let html = '';
  868. html += '<div class="javaex-panel-box" style="width: 600px;">';
  869. html += ' <div class="javaex-unit clear">';
  870. html += ' <div id="targetNub" class="javaex-unit-left ml-10 mt-10">*房间列表0</div>';
  871. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  872. html +=
  873. ' <textarea id="batchTargetMedal_roomlist" class="javaex-desc" placeholder="特别注意:请填写用户真实房间号,多个用英文逗号,隔开!!"></textarea>';
  874. html += ' </div>';
  875. html += ' </div>';
  876. html += ' <div class="javaex-unit clear tc" >';
  877. html += ' <input type="button" id="batchTargetMedal_beg" class="javaex-btn yes" value="开始" />';
  878. html += ' </div>';
  879. html += '</div>';
  880.  
  881. javaex.panel(this, {
  882. position: "right",
  883. content: html
  884. });
  885.  
  886. $('#batchTargetMedal_roomlist').bind('input propertychange', function() {
  887.  
  888. $('#targetNub').text("*房间列表" + $(this).val().split(",").length);
  889.  
  890. });
  891.  
  892. $("#batchTargetMedal_beg").bind("click", async function() {
  893.  
  894. let room_str = javaex.getSelectVal("#batchTargetMedal_roomlist");
  895. let room_list = room_str.split(",");
  896.  
  897.  
  898. for (const room of room_list) {
  899.  
  900. let uid = await HNAPI.getRoomMsg(room);
  901. await HNTOOL.Sleep(500);
  902.  
  903. if (uid == false) {
  904.  
  905. javaex.tip({
  906. content: room + "获取勋章失败!",
  907. type: "error"
  908. });
  909.  
  910. continue;
  911. }
  912.  
  913. let result = await HNAPI.getFansMedalInfo(uid, room);
  914.  
  915. if (result) {
  916. javaex.tip({
  917. content: room + "勋章已经存在!",
  918. type: "success"
  919. });
  920. continue;
  921. }
  922. //获取包裹列表
  923. let giftRes = await HNAPI.getGiftList(room);
  924.  
  925. if (giftRes == false) {
  926.  
  927. continue;
  928. }
  929.  
  930. let bag_id = null;
  931.  
  932. for (let gr of giftRes) {
  933.  
  934. if (gr.gift_id == 3) {
  935.  
  936. bag_id = gr.bag_id;
  937. break;
  938. }
  939.  
  940. }
  941. if (bag_id != null) {
  942.  
  943. await HNAPI.bagSendGift(uid, room, bag_id);
  944. }
  945.  
  946.  
  947.  
  948. await HNTOOL.Sleep(5000);
  949. }
  950.  
  951. alert("批量送b克拉完毕!")
  952.  
  953.  
  954. });
  955.  
  956.  
  957. });
  958.  
  959.  
  960. $("#HNSetup").bind("click", async function() {
  961.  
  962. var CONFIG = HNTOOL.getConfig();
  963.  
  964.  
  965. let html = '';
  966.  
  967. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  968. html += '<form id="HNGG_SETUP">'
  969. html += ' <div class="javaex-unit clear">'
  970. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Qmsg-key</p></div>'
  971. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  972. html += ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  973. html += ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  974. html += ' </div>'
  975. html += ' <div class="javaex-unit-left mr-10">'
  976. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  977. html += ' </div>'
  978. html += ' </div>'
  979. html += '</form>';
  980. html += '<div class="javaex-unit clear tc">';
  981. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  982. html += '</div>';
  983. html += '<hr class="javaex-divider"></hr>';
  984. html += '</div>';
  985.  
  986. javaex.panel(this, {
  987. position: "right",
  988. content: html
  989. });
  990.  
  991.  
  992. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  993.  
  994. $("#switch-qsmg").bind("click", function() {
  995.  
  996. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  997.  
  998. })
  999.  
  1000.  
  1001. $("#HNSetup_save").bind("click", async function() {
  1002.  
  1003.  
  1004. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  1005.  
  1006. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  1007.  
  1008. javaex.tip({
  1009. content: "设置成功!",
  1010. type: "success"
  1011. });
  1012.  
  1013. });
  1014.  
  1015. });
  1016.  
  1017. //
  1018. $("#getUpMassage").bind("click", async function() {
  1019.  
  1020.  
  1021. let html = '';
  1022.  
  1023. html += '<div style="padding: 10px 10px 10px 0px;">'
  1024. html += '<form id="getUpMassage_form">'
  1025. html += ' <div class="javaex-unit clear">'
  1026. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  1027. html += ' <div class="javaex-unit-left mr-10">'
  1028. html +=
  1029. ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  1030. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  1031. html += ' </div>'
  1032. html += ' <div class="javaex-unit-right mr-10">'
  1033. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  1034. html += ' </div>'
  1035. html += ' </div>'
  1036. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  1037. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  1038. html += ' <thead>'
  1039. html += ' <tr><th>内容</th><th>详情</th></tr>'
  1040. html += ' </thead>'
  1041. html += ' <tbody id="upMsgTbody">'
  1042.  
  1043. html += ' </tbody>'
  1044. html += '</table> '
  1045. html += '</div>'
  1046. html += '</form>';
  1047. html += '<hr class="javaex-divider"></hr>';
  1048. html += '</div>';
  1049.  
  1050.  
  1051. javaex.panel(this, {
  1052. position: "right",
  1053. content: html
  1054. });
  1055.  
  1056. javaex.table({
  1057. id: "upMsgTable",
  1058. isDragColWidth: true, // 是否允许拖动改变列宽
  1059. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  1060. leftFixedColNum: 2, // 左侧固定列数
  1061. rightFixedColNum: 1, // 右侧固定列数
  1062. sort: {
  1063. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  1064. "2": "update_time"
  1065. },
  1066. sortCallback: function(rtn) {
  1067. //console.log(rtn.sortArr);
  1068. }
  1069. });
  1070.  
  1071. //
  1072. $("#getUpMsg").click(async function() {
  1073.  
  1074. let thismid = javaex.getSelectVal("#up_uid");
  1075. await HNAPI.userInfo(thismid)
  1076.  
  1077. let temp = await HNAPI.getUpCard(thismid);
  1078.  
  1079.  
  1080. await HNTOOL.Sleep(500);
  1081.  
  1082.  
  1083. if (temp != false) {
  1084. let data = BiliData.upCard.data;
  1085.  
  1086. let html = ``;
  1087. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  1088. html += `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  1089. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  1090. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  1091. html +=
  1092. `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  1093. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  1094. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  1095. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  1096. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  1097. html +=
  1098. `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  1099. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  1100. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  1101.  
  1102.  
  1103. $("#upMsgTbody").empty();
  1104. $("#upMsgTbody").append(html);
  1105. }
  1106.  
  1107.  
  1108. });
  1109. //点击放大
  1110. /* $("img").click(function() {
  1111. javaex.dialog({
  1112. type : "image", // 弹出层类型
  1113. url : $(this).attr("src") // 图片地址
  1114. });
  1115. });*/
  1116.  
  1117. });
  1118.  
  1119.  
  1120. $("#everyDayTask").bind("click", async function() {
  1121.  
  1122. let videoAid = 758643487;
  1123. let videoCid = 357521682;
  1124. let videoBvid = "BV1V64y1d7ed";
  1125. let videoMid = 99439379;
  1126.  
  1127. await HNAPI.clickNow();
  1128. await HNTOOL.Sleep(3000);
  1129.  
  1130. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  1131. await HNAPI.DoSign();
  1132. await HNTOOL.Sleep(3000);
  1133.  
  1134.  
  1135. //2.每日观看视频 获取分区最新视频列表 http://api.bilibili.com/x/web-interface/dynamic/region pn=1 ps=20 rid=21
  1136. let archivesList = await HNAPI.getDynamicRegion();
  1137. await HNTOOL.Sleep(2000);
  1138. //2.每日观看视频 获取分区最新专栏列表
  1139. let articleData = await HNAPI.getArticleRecommends();
  1140. await HNTOOL.Sleep(2000);
  1141.  
  1142. let num = HNTOOL.random(0, archivesList.length - 1);
  1143. let article = articleData[HNTOOL.random(0, 18)];
  1144.  
  1145. if (archivesList != false && num != 2) {
  1146.  
  1147. videoAid = archivesList[num].aid;
  1148. videoBvid = archivesList[num].bvid;
  1149. videoCid = archivesList[num].cid;
  1150. videoMid = archivesList[num].owner.mid;
  1151. }
  1152.  
  1153. await HNAPI.playOneVideo(videoBvid, videoMid);
  1154. await HNTOOL.Sleep(2000);
  1155. //await HNAPI.addVideoCoin(videoAid);//视频投币
  1156.  
  1157. await HNAPI.addArticleCoin(article.id, article.author.mid); //专栏投币
  1158. await HNTOOL.Sleep(2000);
  1159.  
  1160.  
  1161. await HNAPI.addShare(videoAid);
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167. });
  1168.  
  1169.  
  1170. $("#dynamicActivity").bind("click", async function() {
  1171.  
  1172. javaex.tip({
  1173. content: "动态转发开始!",
  1174. type: "success"
  1175. });
  1176.  
  1177. let dynamic_id_list = await HNTOOL.getLatestDynamic();
  1178. //let save_dynamic_id = await HNAPI.getSpaceNotice();
  1179. await HNTOOL.Sleep(2000);
  1180.  
  1181. for (let index = 0, len = dynamic_id_list.length; index < len; index++) {
  1182.  
  1183. let value = dynamic_id_list[index];
  1184.  
  1185. let dynamic_data = await HNAPI.getdynamicData(value);
  1186.  
  1187. if (dynamic_data.hasOwnProperty('card') == false) {
  1188. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 失效!!!");
  1189. continue;
  1190. }
  1191. let dynamic_id = dynamic_data.card.desc.dynamic_id_str;
  1192. let dynamic_type = 17;
  1193. await HNTOOL.Sleep(2000);
  1194.  
  1195. if (dynamic_data.card.desc.is_liked == 1) {
  1196. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 已转发,舍弃!!!");
  1197. continue;
  1198. }
  1199. //判断是否过期
  1200. if (dynamic_data.card.desc.type == 2) {
  1201. dynamic_type = 11;
  1202. dynamic_id = dynamic_data.card.desc.rid;
  1203. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1204. await HNTOOL.Sleep(2000);
  1205.  
  1206. if (lNoticeData.lottery_time * 1000 <= (new Date()).getTime()) {
  1207.  
  1208.  
  1209. console.log(
  1210. "【" + index + "已过开奖时间】\n" +
  1211. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1212. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n"
  1213. );
  1214. continue;
  1215. }
  1216.  
  1217. }
  1218. //0.判断是否关注
  1219. /* if (dynamic_data.attentions.uids.indexOf(dynamic_data.card.desc.uid) == -1) {
  1220.  
  1221. HNAPI.batchModify(dynamic_data.card.desc.uid);
  1222. console.log("【" + index + "】" + dynamic_data.card.desc.uid + "无需关注!!!");
  1223. await HNTOOL.Sleep(1000);
  1224. } */
  1225. HNAPI.batchModify(dynamic_data.card.desc.uid);
  1226. console.log("【" + index + "】" + dynamic_data.card.desc.uid + "已关注!!!");
  1227. await HNTOOL.Sleep(1000);
  1228.  
  1229. //1.评论
  1230. await HNAPI.addReply(dynamic_id, dynamic_type);
  1231. console.log("【" + index + "】" + dynamic_id + "评论成功!!!");
  1232. await HNTOOL.Sleep(1000);
  1233. //3.点赞
  1234. await HNAPI.likeDynamic(value);
  1235. await HNTOOL.Sleep(1000);
  1236. //2.转发
  1237. let repostCard = HNTOOL.strToJson(dynamic_data.card.card);
  1238. let repostStr = HNTOOL.getRandomWordOfList(replyList);
  1239. if (repostCard["user"]["uname"] != undefined && dynamic_data.card.desc.type == 1) {
  1240. repostStr = HNTOOL.getRandomWordOfList(replyList) + "//@" + repostCard.user.uname + " :" + repostCard.item.content;
  1241. }
  1242. await HNAPI.repostDynamic(value, repostStr);
  1243. await HNTOOL.Sleep(1000);
  1244. console.log("【" + index + "】动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!");
  1245.  
  1246. javaex.tip({
  1247. content: "动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!",
  1248. type: "success"
  1249. });
  1250.  
  1251. //存储标记
  1252. //await HNAPI.setNotice(value);
  1253.  
  1254. //随机延迟120 -240秒
  1255. let sleeptime = HNTOOL.random(12, 24) * 10 * 1000;
  1256. console.log("转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!")
  1257. javaex.tip({
  1258. content: "转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!",
  1259. type: "success"
  1260. });
  1261. await HNTOOL.Sleep(sleeptime);
  1262. }
  1263.  
  1264. alert("今日动态抽奖完成!!!");
  1265.  
  1266. });
  1267.  
  1268. $("#batchFollowOfbastard").bind("click", async function() {
  1269.  
  1270. if (confirm("作者个人需求开发,谨慎使用!!!\n 本功能会取关设定值以下没有认证(官方&&个人)的关注! \n 不确定使用请取消!")) {
  1271.  
  1272. let fansNum = prompt("请输入最低粉丝数量", "50000");
  1273.  
  1274. if (fansNum != null && fansNum != "") {
  1275. //fansNum
  1276.  
  1277. let followList = await HNAPI.getAllFollow();
  1278. console.log(followList);
  1279. await HNTOOL.Sleep(2000);
  1280.  
  1281. for (let fl of followList) {
  1282.  
  1283. if (fl == 99439379) {
  1284. continue;
  1285. }
  1286. let user = await HNAPI.getCardByUID(fl);
  1287. await HNTOOL.Sleep(1000);
  1288. if (user.fans < parseInt(fansNum) && user.official_verify.type == -1) {
  1289.  
  1290. await HNAPI.cancelAtt(fl, 2);
  1291.  
  1292. javaex.tip({
  1293. content: "uid:" + user.mid + "-" + user.name + "---符合条件 取关成功!!!",
  1294. type: "success"
  1295. });
  1296. console.log("uid:" + user.mid + "-" + user.name + "--符合条件 取关成功!!!");
  1297.  
  1298. } else {
  1299. javaex.tip({
  1300. content: "uid:" + user.mid + "-" + user.name + "---不符合条件 取消!!!",
  1301. type: "success"
  1302. });
  1303. console.log("uid:" + user.mid + "-" + user.name + "---不符合条件 取消!!!");
  1304. }
  1305. }
  1306. }
  1307.  
  1308. }
  1309.  
  1310. });
  1311.  
  1312.  
  1313. $("#reserveActivity").bind("click", async function() {
  1314.  
  1315.  
  1316. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSid.json";
  1317. let myjson = await HNAPI.getMyJson(url);
  1318.  
  1319. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1320. if (typeof(lastSid) == "undefined") {
  1321. lastSid = HN_SETUP_CONFIG.Booking_last_sid;
  1322. }
  1323. lastSid = lastSid.split("&")[1];
  1324.  
  1325.  
  1326.  
  1327. for (const sid in myjson) {
  1328.  
  1329. if (lastSid >= sid) {
  1330.  
  1331. continue;
  1332. }
  1333.  
  1334. let siddata = myjson[sid];
  1335. //let sidList = await HNAPI.getDataByLiveSid(sid);
  1336. //await HNTOOL.Sleep(2000);
  1337.  
  1338. //let returnData = await HNAPI.reserveActivity(sid, sidList[sid].total);
  1339. await HNAPI.reserveActivity(sid);
  1340. await HNTOOL.Sleep(2000);
  1341.  
  1342. let tiplog = "\n --预约开始:" + javaex.dateFormat(siddata.livePlanStartTime, 'yyyy-MM-dd HH:mm:ss') +
  1343. //"\n --预约SID:" + siddata.sid +
  1344. //"\n --预约UID:" + siddata.upmid +
  1345. //"\n --预约地址:" + siddata.prizeInfo.jumpUrl +
  1346. "\n --预约人数:" + siddata.total + "人" +
  1347. "\n --预约奖品:" + siddata.prizeInfo.text;
  1348.  
  1349. console.log(tiplog);
  1350.  
  1351. javaex.tip({
  1352. content: tiplog,
  1353. type: "success"
  1354. });
  1355.  
  1356. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + sid;
  1357.  
  1358. HNTOOL.saveConfig();
  1359.  
  1360. }
  1361.  
  1362.  
  1363. alert("预约抽奖结束");
  1364. });
  1365.  
  1366. $("#plateActivity").bind("click", async function() {
  1367.  
  1368. //获取轮盘数据
  1369.  
  1370. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1371. let myjson = await HNAPI.getMyJson(url);
  1372. let lmt = 0;
  1373. let k = 20; //重试次数 防止卡主
  1374. let giftArr = [];
  1375. let endAtion = [];
  1376.  
  1377. javaex.tip({
  1378. content: "开始参加轮盘!!!",
  1379. type: "success"
  1380. });
  1381.  
  1382. await HNAPI.getUserNav();
  1383. await HNTOOL.Sleep(1500);
  1384.  
  1385.  
  1386. for (const json of myjson) {
  1387. //let x = json.name;
  1388. for (let i = 0; i < 20; i++) {
  1389. //结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1390. let resout = await HNAPI.addLotteryTimes(json.sid);
  1391.  
  1392. await HNTOOL.Sleep(200);
  1393. if (resout == 1) {
  1394.  
  1395. endAtion.push(json.name + ":活动已结束!");
  1396. javaex.tip({
  1397. content: json.name + "活动已结束!",
  1398. type: "success"
  1399. });
  1400.  
  1401. break;
  1402. }
  1403. if (resout != 0 && resout != 1) {
  1404.  
  1405. javaex.tip({
  1406. content: json.name + resout,
  1407. type: "error"
  1408. });
  1409.  
  1410. break;
  1411. }
  1412.  
  1413. if (resout == 0) {
  1414.  
  1415. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1416. continue;
  1417. }
  1418.  
  1419. }
  1420.  
  1421. javaex.tip({
  1422. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1423. type: "success"
  1424. });
  1425.  
  1426. await HNTOOL.Sleep(1500);
  1427.  
  1428. for (let i = 0; i < lmt; i++) {
  1429.  
  1430. let gift = await HNAPI.lotteryDo(json.sid);
  1431.  
  1432.  
  1433. if (gift == true) {
  1434.  
  1435. javaex.tip({
  1436. content: "点击过快,9秒后自动重试!!!",
  1437. type: "error"
  1438. });
  1439.  
  1440. i--;
  1441. k--;
  1442. }
  1443.  
  1444. if (gift == false || k == 0) {
  1445. break;
  1446. }
  1447.  
  1448. if (gift != "未中奖0" && gift != true) {
  1449. giftArr.push(json.name + "奖品为:" + gift);
  1450. break;
  1451. } else {
  1452. javaex.tip({
  1453. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  1454. type: "success"
  1455. });
  1456. }
  1457. await HNTOOL.Sleep(9000);
  1458.  
  1459. }
  1460.  
  1461.  
  1462. }
  1463.  
  1464.  
  1465. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1466. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1467.  
  1468. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1469. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1470.  
  1471.  
  1472. });
  1473.  
  1474. $("#addPlay").bind("click", async function() {
  1475.  
  1476.  
  1477. let html = '';
  1478.  
  1479. html += '<div style="padding: 10px 10px 10px 0px;">'
  1480. html += '<form id="getUpMassage_form">'
  1481.  
  1482. html += ' <div class="javaex-unit clear">'
  1483. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  1484. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  1485. html +=
  1486. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  1487. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  1488. html += ' </div>'
  1489. html += ' </div>'
  1490. html += ' <div class="javaex-unit clear">'
  1491. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  1492. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  1493. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  1494. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  1495. html += ' </div>'
  1496. html += ' </div>'
  1497. html += '</form>';
  1498. html += ' <div class="javaex-unit clear tc">'
  1499. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  1500. html += ' </div>'
  1501. html += '<hr class="javaex-divider"></hr>';
  1502. html += '</div>';
  1503.  
  1504.  
  1505. javaex.panel(this, {
  1506. position: "right",
  1507. content: html
  1508. });
  1509.  
  1510. $("#addPlay_bgn").click(async function() {
  1511.  
  1512. let MID = javaex.getSelectVal("#addPlay_uid")
  1513. let BV = javaex.getSelectVal("#addPlay_bv");
  1514. let bvArr = [];
  1515. let bvArr2 = [];
  1516.  
  1517. MID = javaex.ifnull(MID, BiliData.author_uid);
  1518.  
  1519.  
  1520. if (BV == "0") {
  1521.  
  1522. //1.查询up所有视频BV号 2.发送心跳间隔2s
  1523. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  1524. await HNTOOL.Sleep(500);
  1525. bvArr2 = BiliData.BVList;
  1526.  
  1527. for (let i = 1; i > 0; i++) {
  1528.  
  1529. HNAPI.getUpAllBV(MID, i);
  1530.  
  1531. await HNTOOL.Sleep(500);
  1532.  
  1533. if (BiliData.BVList.length == 0) {
  1534. if (bvArr.length == 0) {
  1535. javaex.tip({
  1536. content: "该用户无投稿视频,请确认是否有误!",
  1537. type: "success"
  1538. });
  1539. await HNTOOL.Sleep(2000);
  1540. }
  1541. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  1542. bvArr = bvArr.concat(bvArr2);
  1543. break;
  1544. }
  1545.  
  1546. bvArr = bvArr.concat(BiliData.BVList);
  1547. }
  1548.  
  1549.  
  1550. if (bvArr.length != 0) {
  1551.  
  1552. for (const emt of bvArr) {
  1553.  
  1554. HNAPI.playOneVideo(emt.bvid, MID);
  1555.  
  1556. await HNTOOL.Sleep(2000);
  1557.  
  1558. }
  1559.  
  1560. alert("播放完成!!!");
  1561.  
  1562. }
  1563.  
  1564.  
  1565. } else {
  1566. //1.调用点击播放接口
  1567. //2.发送心跳
  1568.  
  1569. await HNTOOL.Sleep(500);
  1570.  
  1571. HNAPI.playOneVideo(BV);
  1572. }
  1573.  
  1574.  
  1575. });
  1576.  
  1577.  
  1578. });
  1579.  
  1580. }
  1581.  
  1582.  
  1583. let addSetPage = async function() {
  1584.  
  1585. HNTOOL.Sleep(1000);
  1586.  
  1587. $('body').append('' +
  1588. '<div id="left_navbar">' +
  1589. '<div class="javaex-menu-container"> ' +
  1590. ' <div id="menu" class="javaex-menu"> ' +
  1591. ' <ul> ' +
  1592. ' <li class="javaex-menu-item alone hover" > ' +
  1593. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  1594. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  1595. ' </li> ' +
  1596. ' </ul> ' +
  1597. ' <ul> ' +
  1598. ' <li class="javaex-menu-item"> ' +
  1599. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  1600. ' <ul> ' +
  1601. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  1602. ' </ul> ' +
  1603. ' </li> ' +
  1604. ' <li id="chackList" class="javaex-menu-item"> ' +
  1605. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  1606. ' <ul> ' +
  1607. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  1608. //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  1609. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  1610. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  1611. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  1612. ' </ul> ' +
  1613. ' </li> ' +
  1614. ' <li class="javaex-menu-item"> ' +
  1615. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  1616. ' <ul> ' +
  1617. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  1618. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  1619. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  1620. ' <li id="batchFollowOfbastard" class="javaex-hover-pulse"><a href="javaScript:;" >批量取关-慎用</a></li> ' +
  1621. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  1622. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  1623. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  1624. ' </ul> ' +
  1625. ' </li> ' +
  1626. ' <li class="javaex-menu-item"> ' +
  1627. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  1628. ' <ul> ' +
  1629. ' <li id="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
  1630. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  1631. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  1632. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  1633. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  1634. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  1635. ' <li id="dynamicActivity" class="javaex-hover-pulse"><a href="javaScript:;" >动态抽奖</a></li> ' +
  1636. //' <li id="likeInDynamicComments" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  1637. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  1638. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  1639. ' </ul> ' +
  1640. ' </li> ' +
  1641. ' <li class="javaex-menu-item"> ' +
  1642. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  1643. ' <ul> ' +
  1644. ' <li class="javaex-hover-pulse"><a href="https://greatest.deepsurf.us/zh-CN/scripts/422731" >更新</a></li> ' +
  1645. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  1646. ' </ul> ' +
  1647. ' </li> ' +
  1648.  
  1649. ' </ul> ' +
  1650. ' </div> ' +
  1651. '</div>' +
  1652. '</div>');
  1653. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  1654.  
  1655. javaex.menu({
  1656. id: "menu",
  1657. isShowAll: false
  1658. });
  1659.  
  1660. }
  1661.  
  1662.  
  1663.  
  1664.  
  1665. let showUnreadMsg = function() {
  1666.  
  1667. var html = '';
  1668. html += '<div class="javaex-panel-box" style="width: 250px;">';
  1669. html += ' <ul>';
  1670. html += ` <p style="color: #FFF;">用户消息</p>`;
  1671. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  1672. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  1673. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  1674. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  1675. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  1676. html += ' <hr class="javaex-divider"></hr>';
  1677. html += ' </ul>';
  1678. html += '</div>';
  1679.  
  1680.  
  1681. javaex.panel(document.getElementById("getUnread"), {
  1682. position: "right",
  1683. content: html
  1684. });
  1685.  
  1686. javaex.tip({
  1687. content: "查询用户通知成功!",
  1688. type: "success"
  1689. });
  1690.  
  1691. }
  1692.  
  1693. /**
  1694. * 检查 艾特信息
  1695. * @returns {Promise<void>}
  1696. */
  1697. let chackAtMsg = async function(items) {
  1698.  
  1699. await HNTOOL.Sleep(500);
  1700.  
  1701. if (items != false && typeof(items) != "undefined") {
  1702.  
  1703.  
  1704. var html = '';
  1705. html += '<div class="javaex-panel-box" style="width: auto;">';
  1706. html += ' <ul>';
  1707. html += ` <p style="color: #FFF;">@信息</p>`;
  1708. items.forEach(function(item) {
  1709.  
  1710. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  1711. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  1712. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  1713.  
  1714. html +=
  1715. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  1716. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  1717. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  1718. html += ' <hr class="javaex-divider"></hr>';
  1719. });
  1720. html += ' </ul>';
  1721. html += '</div>';
  1722.  
  1723.  
  1724. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  1725. javaex.panel(document.getElementById("getAtMsg"), {
  1726. position: "right",
  1727. content: html
  1728. });
  1729. } else {
  1730. javaex.panel(document.getElementById("chackList"), {
  1731. position: "right",
  1732. content: html
  1733. });
  1734. }
  1735.  
  1736.  
  1737. }
  1738.  
  1739. }
  1740.  
  1741.  
  1742. let addStyle = function() {
  1743. const animate = GM_getResourceText('animate');
  1744. const common = GM_getResourceText('common');
  1745. const defaultCss = GM_getResourceText('defaultCss');
  1746. //const icomoonex = GM_getResourceText('icomoonex');
  1747. //const AllCss = animate + common + defaultCss + icomoonex;
  1748. const AllCss = animate + common + defaultCss;
  1749. const style = document.createElement('style');
  1750. style.innerHTML = AllCss;
  1751. return document.getElementsByTagName('head')[0].appendChild(style);
  1752. }
  1753.  
  1754. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  1755.  
  1756.  
  1757. /*-----------------------------------------------常用API--------------------------------------------------*/
  1758.  
  1759. let HNAPI = {
  1760.  
  1761.  
  1762. getLotteryNotice: async function(dynamic_id) {
  1763. return new Promise((resolve) => {
  1764. Ajax.get({
  1765. url: BILIBLI_PATH.vcapi + '/lottery_svr/v1/lottery_svr/lottery_notice',
  1766. queryStringsObj: {
  1767. "dynamic_id": dynamic_id
  1768. },
  1769. hasCookies: true,
  1770. success: responseText => {
  1771. let res = HNTOOL.strToJson(responseText);
  1772. if (res.code === 0) {
  1773.  
  1774. resolve(res.data);
  1775.  
  1776. } else {
  1777. console.log("获取开奖信息失败:" + res.message);
  1778. resolve(false);
  1779. }
  1780. }
  1781. })
  1782. });
  1783. },
  1784.  
  1785.  
  1786. likeDynamic: async function(dynamic_id) {
  1787.  
  1788. return new Promise((resolve) => {
  1789. Ajax.post({
  1790. url: BILIBLI_PATH.vcapi + '/dynamic_like/v1/dynamic_like/thumb',
  1791. hasCookies: true,
  1792. dataType: 'application/x-www-form-urlencoded',
  1793. data: {
  1794. uid: Live_info.uid,
  1795. dynamic_id: dynamic_id,
  1796. up: 1,
  1797. csrf: Live_info.csrf_token
  1798. },
  1799. success: responseText => {
  1800. let res = HNTOOL.strToJson(responseText);
  1801. if (res.code === 0) {
  1802.  
  1803. javaex.tip({
  1804. content: "动态点赞成功!",
  1805. type: "success"
  1806. });
  1807.  
  1808. resolve(true);
  1809. } else {
  1810.  
  1811. console.log("动态点赞发生错误!" + res.message);
  1812.  
  1813. javaex.tip({
  1814. content: "动态点赞发生错误!" + res.message,
  1815. type: "error"
  1816. });
  1817.  
  1818. resolve(false);
  1819. }
  1820. }
  1821. })
  1822. });
  1823. },
  1824.  
  1825. repostDynamic: async function(dynamic_id, content) {
  1826.  
  1827. return new Promise((resolve) => {
  1828. Ajax.post({
  1829. url: BILIBLI_PATH.vcapi + '/dynamic_repost/v1/dynamic_repost/repost',
  1830. dataType: 'application/x-www-form-urlencoded',
  1831. hasCookies: true,
  1832. data: {
  1833. uid: Live_info.uid,
  1834. dynamic_id: dynamic_id,
  1835. content: content,
  1836. csrf: Live_info.csrf_token
  1837. },
  1838. success: responseText => {
  1839. let res = HNTOOL.strToJson(responseText);
  1840. if (res.code === 0) {
  1841.  
  1842. javaex.tip({
  1843. content: "动态转发成功!",
  1844. type: "success"
  1845. });
  1846.  
  1847. resolve(true);
  1848. } else {
  1849.  
  1850. console.log("动态转发发生错误!" + res.message);
  1851.  
  1852. javaex.tip({
  1853. content: "动态转发发生错误!" + res.message,
  1854. type: "error"
  1855. });
  1856.  
  1857. resolve(false);
  1858. }
  1859. }
  1860. })
  1861. });
  1862. },
  1863.  
  1864. addReply: async function(oid, type) {
  1865.  
  1866. return new Promise((resolve) => {
  1867. Ajax.post({
  1868. url: BILIBLI_PATH.api + '/x/v2/reply/add',
  1869. dataType: 'application/x-www-form-urlencoded',
  1870. hasCookies: true,
  1871. data: {
  1872. "oid": oid,
  1873. "type": type, //11官方 17 加码
  1874. "ordering": 'heat',
  1875. "message": HNTOOL.getRandomWordOfList(replyList),
  1876. "jsonp": 'jsonp',
  1877. "csrf": Live_info.csrf_token
  1878. },
  1879. success: responseText => {
  1880. let res = HNTOOL.strToJson(responseText);
  1881. if (res.code === 0) {
  1882. javaex.tip({
  1883. content: "'自动评论成功'!",
  1884. type: "success"
  1885. });
  1886. resolve(0);
  1887. } else if (res.code === -404) {
  1888. console.log('自动评论原动态已删除');
  1889. resolve(0);
  1890. } else if (res.code === 12002) {
  1891. console.log('自动评论评论区已关闭');
  1892. resolve(0);
  1893. } else if (res.code === 12015) {
  1894. console.log('自动评论需要输入验证码');
  1895. resolve(1);
  1896. } else {
  1897. console.log('自动评论', `评论失败\n${responseText}`);
  1898. resolve(0);
  1899. }
  1900. }
  1901. })
  1902. });
  1903. },
  1904.  
  1905.  
  1906. setNotice: async function(notice) {
  1907.  
  1908. return new Promise((resolve) => {
  1909. Ajax.post({
  1910. url: BILIBLI_PATH.api + '/x/space/notice/set',
  1911. hasCookies: true,
  1912. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1913. data: {
  1914. notice: notice,
  1915. jsonp: 'jsonp',
  1916. csrf: Live_info.csrf_token
  1917. },
  1918. success: responseText => {
  1919. let res = HNTOOL.strToJson(responseText);
  1920. if (res.code === 0) {
  1921.  
  1922. javaex.tip({
  1923. content: "动态标记保存到个人公告成功!",
  1924. type: "success"
  1925. });
  1926.  
  1927. resolve(true);
  1928. } else {
  1929.  
  1930. javaex.tip({
  1931. content: res.message,
  1932. type: "error"
  1933. });
  1934.  
  1935. resolve(false);
  1936. }
  1937. }
  1938. })
  1939. });
  1940. },
  1941.  
  1942. getSpaceNotice: async function() {
  1943. return new Promise((resolve) => {
  1944. Ajax.get({
  1945. url: BILIBLI_PATH.api + '/x/space/notice',
  1946. queryStringsObj: {
  1947. "mid": Live_info.uid
  1948. },
  1949. hasCookies: true,
  1950. success: responseText => {
  1951. let res = HNTOOL.strToJson(responseText);
  1952. if (res.code === 0) {
  1953.  
  1954. resolve(res.data);
  1955.  
  1956. } else {
  1957. console.log("获取公告信息失败:" + res.message);
  1958. resolve(false);
  1959. }
  1960. }
  1961. })
  1962. });
  1963. },
  1964.  
  1965. getdynamicData: async function(dynamic_id_str) {
  1966. return new Promise((resolve) => {
  1967. Ajax.get({
  1968.  
  1969. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
  1970. queryStringsObj: {
  1971. "dynamic_id": dynamic_id_str
  1972. },
  1973. hasCookies: true,
  1974. success: responseText => {
  1975. let res = HNTOOL.strToJson(responseText);
  1976. if (res.code === 0) {
  1977.  
  1978. resolve(res.data);
  1979.  
  1980. } else {
  1981. console.log("获取动态信息失败:" + res.message);
  1982. resolve(false);
  1983. }
  1984. }
  1985. })
  1986. });
  1987. },
  1988.  
  1989. getAllFollow: async function() {
  1990. return new Promise((resolve) => {
  1991. Ajax.get({
  1992.  
  1993. url: BILIBLI_PATH.vcapi + '/feed/v1/feed/get_attention_list',
  1994. queryStringsObj: {
  1995. "uid": Live_info.uid
  1996. },
  1997. hasCookies: true,
  1998. success: responseText => {
  1999. let res = HNTOOL.strToJson(responseText);
  2000. if (res.code === 0) {
  2001.  
  2002. resolve(res.data.list);
  2003.  
  2004. } else {
  2005. console.log("查询失败!" + res.message);
  2006. resolve(false);
  2007. }
  2008. }
  2009. })
  2010. });
  2011. },
  2012.  
  2013. getCardByUID: async function(UID) {
  2014. return new Promise((resolve) => {
  2015. Ajax.get({
  2016.  
  2017. url: BILIBLI_PATH.api + '/x/web-interface/card',
  2018. queryStringsObj: {
  2019. "mid": UID
  2020. },
  2021. hasCookies: true,
  2022. success: responseText => {
  2023. let res = HNTOOL.strToJson(responseText);
  2024. if (res.code === 0) {
  2025.  
  2026. resolve(res.data.card);
  2027.  
  2028. } else {
  2029. console.log("查询失败!" + res.message);
  2030. resolve(false);
  2031. }
  2032. }
  2033. })
  2034. });
  2035. },
  2036.  
  2037.  
  2038. /**
  2039. *
  2040. *
  2041. */
  2042.  
  2043. getTodayDynamicList: async function(mid, indexStr) {
  2044. return new Promise((resolve) => {
  2045. Ajax.get({
  2046.  
  2047. url: BILIBLI_PATH.api + '/x/space/article',
  2048. queryStringsObj: {
  2049. "mid": mid,
  2050. "pn": 1,
  2051. "ps": 12,
  2052. "sort": 'publish_time'
  2053. },
  2054. hasCookies: true,
  2055. success: responseText => {
  2056. let res = HNTOOL.strToJson(responseText);
  2057. if (res.code === 0) {
  2058. let artlist = false;
  2059.  
  2060. for (let art of res.data.articles) {
  2061.  
  2062. //if (art.title.indexOf("抽奖合集") > -1) {
  2063. if (art.title.indexOf(indexStr) > -1) {
  2064. artlist = art;
  2065. break;
  2066. }
  2067. }
  2068.  
  2069. resolve(artlist);
  2070. } else {
  2071.  
  2072.  
  2073. console.log("查询失败!" + res.message);
  2074. resolve(false);
  2075. }
  2076. }
  2077. })
  2078. });
  2079. },
  2080.  
  2081. getDataByLiveSid: async function(ids) {
  2082. return new Promise((resolve) => {
  2083. Ajax.get({
  2084.  
  2085. url: BILIBLI_PATH.api + '/x/activity/up/reserve/relation/info',
  2086. queryStringsObj: {
  2087. "ids": ids
  2088. },
  2089. hasCookies: true,
  2090. success: responseText => {
  2091. let res = HNTOOL.strToJson(responseText);
  2092. if (res.code === 0 && Object.keys(res.data.list).length != 0) {
  2093.  
  2094. resolve(res.data.list);
  2095. } else {
  2096.  
  2097. /* javaex.tip({
  2098. content: "查询失败!" + res.message,
  2099. type: "error"
  2100. }); */
  2101. console.log("查询失败!" + res.message);
  2102.  
  2103. resolve(false);
  2104. }
  2105. }
  2106. })
  2107. });
  2108. },
  2109.  
  2110. /**
  2111. * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
  2112. */
  2113. clickNow: async function() {
  2114. return new Promise((resolve) => {
  2115. Ajax.get({
  2116.  
  2117. url: BILIBLI_PATH.api + '/x/report/click/now',
  2118. queryStringsObj: {
  2119. jsonp: "jsonp"
  2120. },
  2121. hasCookies: true,
  2122. success: responseText => {
  2123. let res = HNTOOL.strToJson(responseText);
  2124. if (res.code === 0) {
  2125.  
  2126. javaex.tip({
  2127. content: "每日登录" + res.data.text,
  2128. type: "success"
  2129. });
  2130. resolve(true);
  2131.  
  2132. } else {
  2133.  
  2134. javaex.tip({
  2135. content: res.message,
  2136. type: "error"
  2137. });
  2138.  
  2139. resolve(false);
  2140. }
  2141. }
  2142. })
  2143. });
  2144. },
  2145.  
  2146. /**
  2147. * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
  2148. * @param {number} videoAid
  2149. */
  2150. addShare: async function(videoAid) {
  2151. return new Promise((resolve) => {
  2152. Ajax.post({
  2153. url: BILIBLI_PATH.api + '/x/web-interface/share/add',
  2154. hasCookies: true,
  2155. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2156. data: {
  2157. aid: videoAid,
  2158. csrf: Live_info.csrf_token
  2159. },
  2160. success: responseText => {
  2161. let res = HNTOOL.strToJson(responseText);
  2162. if (res.code === 0) {
  2163.  
  2164. javaex.tip({
  2165. content: "每日分享视频成功",
  2166. type: "success"
  2167. });
  2168.  
  2169. resolve(true);
  2170. } else {
  2171.  
  2172. javaex.tip({
  2173. content: res.message,
  2174. type: "error"
  2175. });
  2176.  
  2177. resolve(false);
  2178. }
  2179. }
  2180. })
  2181. });
  2182. },
  2183.  
  2184.  
  2185.  
  2186. /**
  2187. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  2188. * @param {number} videoAid
  2189. */
  2190. addArticleCoin: async function(cvID, mid) {
  2191. return new Promise((resolve) => {
  2192. Ajax.post({
  2193. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  2194. hasCookies: true,
  2195. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2196. data: {
  2197. aid: cvID,
  2198. upid: mid,
  2199. multiply: 2,
  2200. avtype: 2,
  2201. csrf: Live_info.csrf_token
  2202. },
  2203. success: responseText => {
  2204. let res = HNTOOL.strToJson(responseText);
  2205. if (res.code === 0) {
  2206.  
  2207. javaex.tip({
  2208. content: '专栏:' + cvID + "投币成功",
  2209. type: "success"
  2210. });
  2211.  
  2212. resolve(true);
  2213. } else {
  2214.  
  2215. javaex.tip({
  2216. content: res.message,
  2217. type: "error"
  2218. });
  2219.  
  2220. console.log('专栏投币失败:' + cvID + res.message);
  2221.  
  2222. resolve(false);
  2223. }
  2224. }
  2225. })
  2226. });
  2227. },
  2228.  
  2229. /**
  2230. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  2231. * @param {number} videoAid
  2232. */
  2233. addVideoCoin: async function(videoAid) {
  2234. return new Promise((resolve) => {
  2235. Ajax.post({
  2236. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  2237. hasCookies: true,
  2238. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2239. data: {
  2240. aid: videoAid,
  2241. multiply: 2,
  2242. select_like: 0,
  2243. cross_domain: true,
  2244. csrf: Live_info.csrf_token
  2245. },
  2246. success: responseText => {
  2247. let res = HNTOOL.strToJson(responseText);
  2248. if (res.code === 0) {
  2249.  
  2250. javaex.tip({
  2251. content: "投币成功",
  2252. type: "success"
  2253. });
  2254.  
  2255. resolve(true);
  2256. } else {
  2257.  
  2258. javaex.tip({
  2259. content: res.message,
  2260. type: "error"
  2261. });
  2262.  
  2263. resolve(false);
  2264. }
  2265. }
  2266. })
  2267. });
  2268. },
  2269.  
  2270.  
  2271. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  2272.  
  2273. DoSign: async function() {
  2274. return new Promise((resolve) => {
  2275. Ajax.get({
  2276.  
  2277. url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
  2278. queryStringsObj: {
  2279.  
  2280. },
  2281. hasCookies: true,
  2282. success: responseText => {
  2283. let res = HNTOOL.strToJson(responseText);
  2284. if (res.code === 0) {
  2285.  
  2286. javaex.tip({
  2287. content: "签到成功:" + res.data.text,
  2288. type: "success"
  2289. });
  2290. resolve(true);
  2291.  
  2292. } else if (res.code === 1011040) {
  2293.  
  2294. javaex.tip({
  2295. content: res.message,
  2296. type: "success"
  2297. });
  2298.  
  2299. resolve(true);
  2300. } else {
  2301.  
  2302. javaex.tip({
  2303. content: res.message,
  2304. type: "error"
  2305. });
  2306.  
  2307. resolve(false);
  2308. }
  2309. }
  2310. })
  2311. });
  2312. },
  2313.  
  2314.  
  2315. /**
  2316. * // 获取分区最新专栏列表 https://api.bilibili.com/x/article/recommends?cid=0&pn=1
  2317. */
  2318. getArticleRecommends: async function() {
  2319. return new Promise((resolve) => {
  2320. Ajax.get({
  2321.  
  2322. url: BILIBLI_PATH.api + '/x/article/recommends',
  2323. queryStringsObj: {
  2324. "cid": 0,
  2325. "pn": 1
  2326. },
  2327. hasCookies: true,
  2328. success: responseText => {
  2329. let res = HNTOOL.strToJson(responseText);
  2330. if (res.code === 0) {
  2331.  
  2332. javaex.tip({
  2333. content: "获取最新专栏成功!",
  2334. type: "success"
  2335. });
  2336. resolve(res.data);
  2337.  
  2338. } else {
  2339.  
  2340. javaex.tip({
  2341. content: "获取最新专栏失败!" + res.message,
  2342. type: "error"
  2343. });
  2344.  
  2345. console.log(res.message);
  2346.  
  2347. resolve(false);
  2348. }
  2349. }
  2350. })
  2351. });
  2352. },
  2353. /**
  2354. * // 获取分区最新视频列表
  2355. */
  2356. getDynamicRegion: async function() {
  2357. return new Promise((resolve) => {
  2358. Ajax.get({
  2359.  
  2360. url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
  2361. queryStringsObj: {
  2362. "pn": 1,
  2363. "ps": 20,
  2364. "rid": 21
  2365. },
  2366. hasCookies: true,
  2367. success: responseText => {
  2368. let res = HNTOOL.strToJson(responseText);
  2369. if (res.code === 0) {
  2370.  
  2371. javaex.tip({
  2372. content: "获取分区最新视频成功",
  2373. type: "success"
  2374. });
  2375. resolve(res.data.archives);
  2376.  
  2377. } else {
  2378.  
  2379. javaex.tip({
  2380. content: "获取分区最新视频失败" + res.message,
  2381. type: "error"
  2382. });
  2383.  
  2384. resolve(false);
  2385. }
  2386. }
  2387. })
  2388. });
  2389. },
  2390.  
  2391. /*
  2392. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  2393. * @param {Object} sid
  2394. */
  2395. reserveActivity: async function(sid) {
  2396. return new Promise((resolve) => {
  2397. Ajax.post({
  2398. url: BILIBLI_PATH.api + '/x/space/reserve',
  2399. hasCookies: true,
  2400. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2401. data: {
  2402. sid: sid, //当前用户
  2403. jsonp: "jsonp",
  2404. csrf: Live_info.csrf_token
  2405. },
  2406. success: responseText => {
  2407. let res = HNTOOL.strToJson(responseText);
  2408. if (res.code === 0) {
  2409.  
  2410. resolve(true);
  2411. } else {
  2412. javaex.tip({
  2413. content: res.message,
  2414. type: "error"
  2415. });
  2416. resolve(false);
  2417. }
  2418. }
  2419. })
  2420. });
  2421. },
  2422. /**
  2423. reserveActivity: async function(sid, reserve_total) {
  2424. return new Promise((resolve) => {
  2425. Ajax.post({
  2426. url: BILIBLI_PATH.vcapi + '/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
  2427. hasCookies: true,
  2428. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2429. data: {
  2430. reserve_id: sid,
  2431. cur_btn_status: 1,
  2432. reserve_total: reserve_total,
  2433. csrf: Live_info.csrf_token
  2434. },
  2435. success: responseText => {
  2436. let res = HNTOOL.strToJson(responseText);
  2437. if (res.code === 0) {
  2438.  
  2439. resolve(res.data);
  2440. } else {
  2441.  
  2442. javaex.tip({
  2443. content: res.message,
  2444. type: "error"
  2445. });
  2446.  
  2447. resolve(false);
  2448. }
  2449. }
  2450. })
  2451. });
  2452. }, */
  2453.  
  2454. getGiftList: async function(room) {
  2455. return new Promise((resolve) => {
  2456. Ajax.get({
  2457.  
  2458. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  2459. queryStringsObj: {
  2460. "room_id": room
  2461. },
  2462. hasCookies: true,
  2463. success: responseText => {
  2464. let res = HNTOOL.strToJson(responseText);
  2465. if (res.code === 0) {
  2466.  
  2467. resolve(res.data.list);
  2468. } else {
  2469.  
  2470. javaex.tip({
  2471. content: "查询包裹失败!" + res.message,
  2472. type: "error"
  2473. });
  2474.  
  2475. resolve(false)
  2476. }
  2477. }
  2478. })
  2479. });
  2480. },
  2481.  
  2482. /**
  2483. * 送银B克拉
  2484. * @param {Object} ruid
  2485. * @param {Object} roomid
  2486. */
  2487. bagSendGift: async function(ruid, roomid, bag_id) {
  2488. return new Promise((resolve) => {
  2489. Ajax.post({
  2490. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  2491. hasCookies: true,
  2492. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2493. data: {
  2494. uid: Live_info.uid, //当前用户
  2495. gift_id: 3,
  2496. ruid: ruid,
  2497. send_ruid: 0,
  2498. gift_num: 1,
  2499. bag_id: bag_id,
  2500. //rnd: Math.round(new Date() / 1000); //时间戳,
  2501. platform: 'pc',
  2502. biz_code: 'Live',
  2503. biz_id: roomid,
  2504. storm_beat_id: 0,
  2505. price: 0,
  2506. csrf_token: Live_info.csrf_token,
  2507. csrf: Live_info.csrf_token
  2508.  
  2509. },
  2510. success: responseText => {
  2511. let res = HNTOOL.strToJson(responseText);
  2512. if (res.code === 0) {
  2513.  
  2514. javaex.tip({
  2515. content: roomid + "赠送b克拉成功!" + res.message,
  2516. type: "success"
  2517. });
  2518.  
  2519. resolve(true);
  2520. } else {
  2521.  
  2522. javaex.tip({
  2523. content: res.message,
  2524. type: "error"
  2525. });
  2526.  
  2527. resolve(false);
  2528. }
  2529. }
  2530. })
  2531. });
  2532. },
  2533.  
  2534.  
  2535. /**
  2536. * 判断是否有勋章
  2537. * @param {Object} uid
  2538. * @param {Object} room
  2539. */
  2540.  
  2541. getFansMedalInfo: async function(uid, room) {
  2542. return new Promise((resolve) => {
  2543. Ajax.get({
  2544.  
  2545. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  2546. queryStringsObj: {
  2547. "target_id": uid,
  2548. "room_id": room
  2549. },
  2550. //dataType:'application/json, text/plain, */*',
  2551. hasCookies: true,
  2552. success: responseText => {
  2553. let res = HNTOOL.strToJson(responseText);
  2554. if (res.code === 0) {
  2555.  
  2556. if (res.data.my_fans_medal.level == 0) {
  2557. resolve(false)
  2558. } else {
  2559. resolve(true)
  2560. }
  2561.  
  2562. } else {
  2563.  
  2564. javaex.tip({
  2565. content: "查询勋章失败!" + res.message,
  2566. type: "error"
  2567. });
  2568.  
  2569. resolve(false)
  2570. }
  2571. }
  2572. })
  2573. });
  2574. },
  2575.  
  2576.  
  2577.  
  2578.  
  2579. getDisuidList: async function(re_version, pn) {
  2580. return new Promise((resolve) => {
  2581. Ajax.get({
  2582.  
  2583. url: BILIBLI_PATH.api + '/x/relation/blacks',
  2584. queryStringsObj: {
  2585. "re_version": re_version,
  2586. "pn": pn
  2587. },
  2588. hasCookies: true,
  2589. success: responseText => {
  2590. let res = HNTOOL.strToJson(responseText);
  2591. if (res.code === 0) {
  2592. resolve(res.data.list)
  2593. } else {
  2594.  
  2595. javaex.tip({
  2596. content: "查询黑名单失败!" + res.message,
  2597. type: "error"
  2598. });
  2599.  
  2600. resolve(null)
  2601. }
  2602. }
  2603. })
  2604. });
  2605. },
  2606.  
  2607. /**
  2608. * @param {Object} uid
  2609. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  2610. */
  2611. cancelAtt: async function(uid, act, re_src) {
  2612. return new Promise((resolve) => {
  2613. Ajax.post({
  2614. url: BILIBLI_PATH.api + '/x/relation/modify',
  2615. hasCookies: true,
  2616. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2617. data: {
  2618. fid: uid,
  2619. act: act,
  2620. re_src: re_src == undefined ? 11 : 116,
  2621. jsonp: "jsonp",
  2622. csrf: Live_info.csrf_token,
  2623. },
  2624. success: responseText => {
  2625. let res = HNTOOL.strToJson(responseText);
  2626. if (res.code === 0) {
  2627.  
  2628. //HNAPI.cancelAtt(uid, 6);
  2629.  
  2630. javaex.tip({
  2631. content: "取关成功!" + res.message,
  2632. type: "success"
  2633. });
  2634.  
  2635. resolve(true);
  2636. } else if (res.code === 22003) {
  2637.  
  2638. HNAPI.cancelAtt(uid, 6);
  2639.  
  2640. javaex.tip({
  2641. content: "取消拉黑" + res.message,
  2642. type: "success"
  2643. });
  2644. resolve(true);
  2645. } else {
  2646.  
  2647. javaex.tip({
  2648. content: res.message,
  2649. type: "error"
  2650. });
  2651.  
  2652. resolve(false);
  2653. }
  2654. }
  2655. })
  2656. });
  2657. },
  2658.  
  2659. getRoomMsg: async function(roomid) {
  2660. return new Promise((resolve) => {
  2661. Ajax.get({
  2662.  
  2663. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  2664. queryStringsObj: {
  2665. "roomid": roomid
  2666. },
  2667. hasCookies: true,
  2668. success: responseText => {
  2669. let res = HNTOOL.strToJson(responseText);
  2670. if (res.code === 0) {
  2671. resolve(res.data.info.uid)
  2672. } else {
  2673. resolve(false)
  2674. }
  2675. }
  2676. })
  2677. });
  2678. },
  2679.  
  2680. /**
  2681. *
  2682. * @param sid
  2683. * @returns {Promise<unknown>}
  2684. */
  2685. lotteryDo: async function(sid) {
  2686. return new Promise((resolve) => {
  2687. Ajax.post({
  2688. url: BILIBLI_PATH.api + '/x/activity/lottery/do',
  2689. hasCookies: true,
  2690. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2691. data: {
  2692.  
  2693. sid: sid,
  2694. type: 1,
  2695. csrf: Live_info.csrf_token,
  2696. },
  2697. success: responseText => {
  2698. let res = HNTOOL.strToJson(responseText);
  2699. if (res.code === 0) {
  2700. resolve((res.data)[0].gift_name);
  2701.  
  2702. } else if (res.code === 75400) {
  2703.  
  2704. resolve(true);
  2705. } else {
  2706. javaex.tip({
  2707. content: "本次抽奖失败!" + res.message,
  2708. type: "error"
  2709. });
  2710. resolve(false);
  2711. }
  2712. }
  2713. })
  2714. });
  2715. },
  2716.  
  2717.  
  2718. getLotteryMytimes: async function(sid) {
  2719. return new Promise((resolve) => {
  2720. Ajax.get({
  2721. url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
  2722. queryStringsObj: {
  2723. sid: sid
  2724. },
  2725. hasCookies: true,
  2726. success: responseText => {
  2727. let res = HNTOOL.strToJson(responseText);
  2728. if (res.code === 0) {
  2729. resolve(res.data.times)
  2730. } else {
  2731. resolve(0)
  2732. }
  2733. }
  2734. })
  2735. });
  2736. },
  2737.  
  2738. /**
  2739. * 增加抽奖次数一般是分享
  2740. * @param sid 活动sid
  2741. * @returns {Promise<unknown>} 0 成功 1:活动结束
  2742. */
  2743. addLotteryTimes: async function(sid) {
  2744. return new Promise((resolve) => {
  2745. Ajax.post({
  2746. url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
  2747. hasCookies: true,
  2748. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2749. data: {
  2750.  
  2751. sid: sid,
  2752. action_type: 3,
  2753. csrf: Live_info.csrf_token,
  2754. },
  2755. success: responseText => {
  2756. let res = HNTOOL.strToJson(responseText);
  2757. if (res.code === 0) {
  2758.  
  2759. resolve(0)
  2760. } else if (res.code === 75003) {
  2761.  
  2762. resolve(1)
  2763.  
  2764. } else {
  2765.  
  2766. resolve(res.message);
  2767. }
  2768. }
  2769. })
  2770. });
  2771. },
  2772. /**
  2773. * 查询用户关注 默认一次查询50
  2774. * @param vmid 用户uid
  2775. * @param pn 页码
  2776. * @returns {Promise<unknown>}
  2777. */
  2778. getMyFollow: async function(vmid, pn) {
  2779. return new Promise((resolve) => {
  2780. Ajax.get({
  2781. url: BILIBLI_PATH.api + '/x/relation/followings',
  2782. queryStringsObj: {
  2783. vmid: vmid,
  2784. pn: pn
  2785. },
  2786. hasCookies: true,
  2787. success: responseText => {
  2788. let res = HNTOOL.strToJson(responseText);
  2789. if (res.code === 0) {
  2790. resolve(res.data)
  2791. } else {
  2792. resolve(null)
  2793. }
  2794. }
  2795. })
  2796. });
  2797. },
  2798.  
  2799.  
  2800. getMyinfo: function() {
  2801. return new Promise((resolve) => {
  2802. Ajax.get({
  2803. url: BILIBLI_PATH.api + '/x/space/myinfo',
  2804. queryStringsObj: {},
  2805. hasCookies: true,
  2806. success: responseText => {
  2807. let res = HNTOOL.strToJson(responseText);
  2808. if (res.code === 0) {
  2809. resolve(res.data)
  2810. } else {
  2811. resolve(null)
  2812. }
  2813. }
  2814. })
  2815. });
  2816. },
  2817.  
  2818. getMyJson: function(url) {
  2819. return new Promise((resolve) => {
  2820. GM_xmlhttpRequest({
  2821. method: "GET",
  2822. url: url,
  2823. onload: function(response) {
  2824. const res = HNTOOL.strToJson((response || {}).responseText)
  2825. resolve(res);
  2826. }
  2827. });
  2828. })
  2829. },
  2830.  
  2831.  
  2832. userInfo: function(mid) {
  2833.  
  2834. Ajax.get({
  2835. url: BILIBLI_PATH.api + '/x/space/acc/info',
  2836. queryStringsObj: {
  2837. mid: mid
  2838. },
  2839. hasCookies: true,
  2840. success: responseText => {
  2841.  
  2842. var json = JSON.parse(responseText);
  2843.  
  2844. if (json.code != 0) {
  2845.  
  2846.  
  2847. }
  2848. }
  2849. });
  2850.  
  2851. },
  2852.  
  2853. sendQmsg: async function(key, msg) {
  2854.  
  2855. $.ajax({
  2856. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  2857.  
  2858. success: function(result) {
  2859.  
  2860. }
  2861. });
  2862.  
  2863.  
  2864. /*GM_xmlhttpRequest({
  2865. method: "GET",
  2866. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  2867. onload: function (response) {
  2868.  
  2869. let json = JSON.parse(response.response);
  2870. if (json.code == 0) {
  2871.  
  2872. javaex.tip({
  2873. content: "自动动态中奖提醒成功!" + json.reason,
  2874. type: "success"
  2875. });
  2876. } else {
  2877. console.log("自动动态中奖提醒失败!" + json.reason);
  2878. javaex.tip({
  2879. content: "自动动态中奖提醒失败!" + json.reason,
  2880. type: "error"
  2881. });
  2882. }
  2883.  
  2884. }
  2885. });*/
  2886.  
  2887. },
  2888.  
  2889. /**
  2890. * 批量关注和拉黑 batchModify
  2891. *
  2892. * https://api.bilibili.com/x/relation/batch/modify
  2893. * @param uid
  2894. */
  2895.  
  2896. batchModify: function(uids, act) {
  2897.  
  2898.  
  2899. Ajax.post({
  2900. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  2901. hasCookies: true,
  2902. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2903. data: {
  2904.  
  2905. "fids": uids,
  2906. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  2907. "re_src": 151,
  2908. csrf: Live_info.csrf_token,
  2909. },
  2910. success: responseText => {
  2911.  
  2912. let json = JSON.parse(responseText);
  2913.  
  2914. if (/^{"code":0/.test(responseText)) {
  2915.  
  2916. javaex.tip({
  2917. content: `执行成功!---失败(` + json.data.failed_fids.length + `/15)名单:` + json.data.failed_fids,
  2918. type: "success"
  2919. });
  2920.  
  2921. } else {
  2922. javaex.tip({
  2923. content: "关注失败!" + json.message,
  2924. type: "error"
  2925. });
  2926. }
  2927. }
  2928. })
  2929. },
  2930.  
  2931.  
  2932. /**
  2933. * //https://api.bilibili.com/x/relation/modify
  2934. *
  2935. * @param UID
  2936. */
  2937. disUserByUid: function(vmid) {
  2938.  
  2939. Ajax.post({
  2940. url: BILIBLI_PATH.api + '/x/relation/modify',
  2941. data: {
  2942. fid: parseInt(vmid),
  2943. re_src: 11,
  2944. act: 5,
  2945. jsonp: "jsonp",
  2946. csrf: Live_info.csrf_token,
  2947. },
  2948. hasCookies: true,
  2949. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2950. success: responseText => {
  2951.  
  2952. var json = JSON.parse(responseText);
  2953.  
  2954. if (json.code != 0) {
  2955.  
  2956. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  2957. javaex.tip({
  2958. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  2959. type: "error"
  2960. });
  2961.  
  2962. } else {
  2963. console.log("拉黑用户成功 uid:" + vmid);
  2964. javaex.tip({
  2965. content: "拉黑用户成功 uid:" + vmid,
  2966. type: "success"
  2967. });
  2968. }
  2969. }
  2970. });
  2971.  
  2972. },
  2973. /**
  2974. * http://api.bilibili.com/x/web-interface/view
  2975. * @param BV
  2976. * 心跳间隔15秒
  2977. */
  2978. playOneVideo: function(BV, MID) {
  2979.  
  2980. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  2981. Ajax.post({
  2982. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  2983. hasCookies: true,
  2984. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2985. data: {
  2986.  
  2987. "bvid": BV,
  2988. "part": 1,
  2989. "mid": Live_info.uid,
  2990. "lv": 2,
  2991. "jsonp": "jsonp",
  2992. "type": 3,
  2993. "sub_type": 0
  2994. },
  2995. success: responseText => {
  2996.  
  2997. let json = JSON.parse(responseText);
  2998.  
  2999. if (/^{"code":0/.test(responseText)) {
  3000. //发送一次心跳
  3001. HNAPI.sendHeartbeat(BV, MID);
  3002.  
  3003. } else {
  3004. javaex.tip({
  3005. content: "视频" + data.bvid + "播放失败!" + json.message,
  3006. type: "error"
  3007. });
  3008. }
  3009. }
  3010. })
  3011.  
  3012.  
  3013. },
  3014.  
  3015. //上报视频播放心跳(web端)
  3016. /**
  3017. * http://api.bilibili.com/x/click-interface/web/heartbeat
  3018. * @param json
  3019. */
  3020. sendHeartbeat: function(bvid, MID) {
  3021.  
  3022. Ajax.post({
  3023. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  3024. hasCookies: true,
  3025. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3026. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  3027. data: {
  3028. "bvid": bvid,
  3029. "type": 3,
  3030. "dt": 2,
  3031. "played_time": HNTOOL.random(12, 40),
  3032. "realtime": HNTOOL.random(12, 40),
  3033. "play_type": 0
  3034. },
  3035. success: responseText => {
  3036.  
  3037. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  3038.  
  3039. javaex.tip({
  3040. content: "视频BV" + bvid + "播放一次!",
  3041. type: "success"
  3042. });
  3043. }
  3044. }
  3045. })
  3046.  
  3047. },
  3048.  
  3049. //获取up所有投稿视频
  3050. /**
  3051. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  3052. * @param mid
  3053. */
  3054. getUpAllBV: function(mid, pn, ps) {
  3055. ps = (ps === undefined ? 30 : ps); // a默认值为1
  3056. Ajax.get({
  3057. url: BILIBLI_PATH.api + '/x/space/arc/search',
  3058. queryStringsObj: {
  3059. mid: mid,
  3060. tid: 0,
  3061. order: 'pubdate',
  3062. jsonp: 'jsonp',
  3063. pn: pn,
  3064. ps: ps
  3065. },
  3066. hasCookies: true,
  3067. success: responseText => {
  3068.  
  3069. var json = JSON.parse(responseText);
  3070.  
  3071. if (json.code != 0) {
  3072.  
  3073. javaex.tip({
  3074. content: "获取up所有投稿视频失败!" + json.message,
  3075. type: "success"
  3076. });
  3077.  
  3078. } else {
  3079. BiliData.BVList = json.data.list.vlist;
  3080.  
  3081. }
  3082. }
  3083. });
  3084.  
  3085. },
  3086.  
  3087.  
  3088. /**
  3089. *
  3090. * @param path
  3091. * @param data
  3092. * @param saveObj
  3093. * @param Func
  3094. */
  3095. publicGet: function(path, queryStringsObj) {
  3096.  
  3097. if (typeof(queryStringsObj) != "undefined") {
  3098. queryStringsObj = {};
  3099. }
  3100. Ajax.get({
  3101. url: BILIBLI_PATH.api + path,
  3102. queryStringsObj: queryStringsObj,
  3103. hasCookies: true,
  3104. success: responseText => {
  3105.  
  3106. let json = JSON.parse(responseText);
  3107. if (chackCode(json.code) && json.code == 0) {
  3108.  
  3109. return json.data;
  3110. }
  3111.  
  3112. return false;
  3113.  
  3114. }
  3115. })
  3116.  
  3117. },
  3118.  
  3119. /**
  3120. * 导航栏用户信息
  3121. */
  3122. getUserNav: async function() {
  3123.  
  3124. GM_xmlhttpRequest({
  3125. method: "GET",
  3126. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  3127. //timeout:3000,
  3128. onload: function(response) {
  3129.  
  3130. let json = JSON.parse(response.response);
  3131. console.log(json);
  3132. BiliData.login_code = json.code;
  3133. BiliData.login_message = json.message;
  3134. BiliData.LoginData = json.data;
  3135.  
  3136. }
  3137. });
  3138.  
  3139. },
  3140.  
  3141. /**
  3142. * 获取某up详细信息
  3143. * http://api.bilibili.com/x/web-interface/card
  3144. */
  3145. getUpCard: function(mid) {
  3146.  
  3147. Ajax.get({
  3148. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3149. queryStringsObj: {
  3150. mid: mid,
  3151. photo: false
  3152. },
  3153. hasCookies: true,
  3154. success: responseText => {
  3155.  
  3156. var json = JSON.parse(responseText);
  3157.  
  3158. if (json.code != 0) {
  3159.  
  3160. javaex.tip({
  3161. content: "查询失败!" + json.message,
  3162. type: "success"
  3163. });
  3164. return false;
  3165. } else {
  3166. BiliData.upCard = json;
  3167.  
  3168. }
  3169.  
  3170.  
  3171. }
  3172. })
  3173.  
  3174. },
  3175.  
  3176. /**
  3177. *
  3178. * @param uid 用户uid
  3179. * @param ps 每页视频个数 默认30个
  3180. * @param pn 第几页
  3181. */
  3182. getUpAllVideo: function(uid, ps, pn) {
  3183.  
  3184. },
  3185. getChallenge: async function() {
  3186.  
  3187.  
  3188. },
  3189. /**
  3190. * 硬币记录
  3191. * @returns {Promise<void>}
  3192. */
  3193. getCoinLog: async function() {
  3194.  
  3195. GM_xmlhttpRequest({
  3196. method: "GET",
  3197. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  3198. //url: "http://api.bilibili.com/x/member/web/coin/log",
  3199. onload: function(response) {
  3200.  
  3201. let json = JSON.parse(response.response);
  3202. if (json.code == 0) {
  3203.  
  3204. console.log("硬币记录" + json);
  3205. BiliData.CoinLog = json.data;
  3206.  
  3207. return true;
  3208. }
  3209.  
  3210. }
  3211. });
  3212. },
  3213. /**
  3214. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  3215. * @returns {Promise<void>}
  3216. */
  3217. getUnread: async function() {
  3218.  
  3219. Ajax.get({
  3220. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  3221. hasCookies: true,
  3222. success: responseText => {
  3223.  
  3224. let json = JSON.parse(responseText);
  3225. if (chackCode(json.code) && json.code == 0) {
  3226.  
  3227. BiliData.Unread = json.data;
  3228. showUnreadMsg();
  3229. }
  3230.  
  3231. return false;
  3232.  
  3233. }
  3234. })
  3235.  
  3236. /* GM_xmlhttpRequest({
  3237. method: "GET",
  3238. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  3239. onload: function (response) {
  3240.  
  3241. let json = JSON.parse(response.response);
  3242.  
  3243. if (chackCode(json.code) && json.code == 0) {
  3244.  
  3245. BiliData.Unread = json.code;
  3246. showUnreadMsg();
  3247.  
  3248. }
  3249.  
  3250. }
  3251. });*/
  3252. },
  3253. /**
  3254. *
  3255. * @param type reply:回复我的 at @我的
  3256. */
  3257. getMsgfeed: function(type) {
  3258. Ajax.get({
  3259. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  3260. queryStringsObj: {
  3261. build: 0,
  3262. mobi_app: 'web'
  3263. },
  3264. hasCookies: true,
  3265. success: responseText => {
  3266.  
  3267. var json = JSON.parse(responseText);
  3268.  
  3269. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  3270. return false;
  3271. } else {
  3272. chackAtMsg(json.data.items);
  3273.  
  3274. return true;
  3275. }
  3276.  
  3277.  
  3278. }
  3279. })
  3280.  
  3281. },
  3282.  
  3283. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  3284. * @returns {Promise<void>}
  3285. */
  3286. getUnrewad: async function() {
  3287.  
  3288. GM_xmlhttpRequest({
  3289. method: "GET",
  3290. data: {
  3291. "mid": 99439379,
  3292. "pn": 1,
  3293. "ps": 5,
  3294. },
  3295. url: BILIBLI_PATH.api + "/x/space/arc/search",
  3296. onload: function(response) {
  3297.  
  3298. let json = JSON.parse(response.response);
  3299. if (json.code == 0) {
  3300.  
  3301. BiliData.Video = json.data;
  3302. console.log("未读消息数" + json);
  3303. }
  3304.  
  3305. }
  3306. });
  3307. },
  3308.  
  3309. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  3310. * @param {number} oid
  3311. * @param {nbumber} rpid
  3312. * @param {number} action
  3313. * @returns {Promise<void>}
  3314. * type: 11
  3315. * ordering: heat
  3316. * jsonp: jsonp
  3317. * csrf: 54a******* CSRF Token(位于cookie)
  3318. */
  3319.  
  3320. likeInDynamicComments: async function(latestDynamic) {
  3321.  
  3322.  
  3323. Ajax.post({
  3324. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  3325. hasCookies: true,
  3326. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3327. data: {
  3328. "oid": oid,
  3329. "type": 11,
  3330. "rpid": rpid,
  3331. "action": action,
  3332. "ordering": "heat",
  3333. "jsonp": "jsonp",
  3334. "csrf": Live_info.csrf_token,
  3335. },
  3336. success: responseText => {
  3337.  
  3338. if (/^{"code":0/.test(responseText)) {
  3339.  
  3340. BiliData.replyAction = JSON.parse(responseText);
  3341. console.log("点赞成功!" + responseText);
  3342. }
  3343. }
  3344. })
  3345.  
  3346. }
  3347.  
  3348.  
  3349. }
  3350.  
  3351. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  3352. var http_request = null;
  3353.  
  3354. function send_request(url, method) {}
  3355.  
  3356. let HNTOOL = {
  3357.  
  3358. getLatestDynamic: async function() {
  3359.  
  3360. let date = new Date();
  3361. let thisMonth = date.getMonth() + 1;
  3362. let thisday = date.getDate();
  3363. let thisdate = thisMonth + "月" + thisday < 10 ? '0' + thisday : thisday + "日";
  3364. let thisdate2 = (thisMonth < 10 ? '0' + thisMonth : thisMonth) + '-' + (thisday < 10 ? '0' + thisday : thisday);
  3365. let thisdate2_1 = (thisMonth < 10 ? '0' + thisMonth : thisMonth) + '-' + (thisday < 10 ? '0' + (thisday - 1) :
  3366. thisday - 1);
  3367.  
  3368. let latestDynamic = await HNAPI.getTodayDynamicList(226257459, thisdate);
  3369. let latestDynamic2 = await HNAPI.getTodayDynamicList(226257459, "抽奖合集");
  3370. let latestDynamic3 = await HNAPI.getTodayDynamicList(2295698, thisdate2);
  3371. if (latestDynamic3 == false) {
  3372.  
  3373. latestDynamic3 = await HNAPI.getTodayDynamicList(2295698, thisdate2_1);
  3374. }
  3375.  
  3376.  
  3377.  
  3378.  
  3379.  
  3380.  
  3381. let ld1 = await HNTOOL.getDynamicIdList(latestDynamic);
  3382. await HNTOOL.Sleep(1000);
  3383. let ld2 = await HNTOOL.getDynamicIdList(latestDynamic2);
  3384. await HNTOOL.Sleep(1000);
  3385. let ld3 = await HNTOOL.getDynamicIdList(latestDynamic3);
  3386. await HNTOOL.Sleep(1000);
  3387. return HNTOOL.arrUnique(ld1.concat(ld2.concat(ld3)), false);
  3388.  
  3389.  
  3390. },
  3391.  
  3392. getDynamicIdList: async function(latestDynamic) {
  3393.  
  3394.  
  3395. let returnlist = [];
  3396. return new Promise((resolve) => {
  3397. Ajax.get({
  3398. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  3399. queryStringsObj: {},
  3400. dataType: "html",
  3401. hasCookies: false,
  3402. success: responseText => {
  3403. let datalist = HNTOOL.httpString(responseText);
  3404. let dls;
  3405. for (let dl of datalist) {
  3406.  
  3407. let len = dl.indexOf("?");
  3408. if (len == -1) {
  3409. dl += "?tab=2";
  3410. }
  3411. dls = dl.substring(dl.indexOf("?") - 18, dl.indexOf("?"));
  3412. if (returnlist.indexOf(dls) > -1 || dls == null || dl.indexOf("read") > -1 || dl.indexOf("html") > -1) {
  3413. continue;
  3414. }
  3415. /* let len = dl.indexOf("?");
  3416. if (len > -1) {
  3417. dls = dl.substring(len - 18, len);
  3418. }
  3419.  
  3420. if (dl.indexOf("tab") == -1 || returnlist.indexOf(dls) > -1 || dls == null) {
  3421. continue;
  3422. } */
  3423. returnlist.push(dls);
  3424.  
  3425. }
  3426. resolve(HNTOOL.arrUnique(returnlist, false));
  3427.  
  3428. if (datalist.length == 0) {
  3429. resolve(false);
  3430. }
  3431. }
  3432. })
  3433. });
  3434. },
  3435.  
  3436.  
  3437. /* getDynamicIdList: async function() {
  3438.  
  3439.  
  3440. let latestDynamic = await HNAPI.getTodayDynamicList();
  3441. let returnlist = [];
  3442. $.ajax({
  3443. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  3444. dataType: "html",
  3445. success: function(data) {
  3446. let datalist = HNTOOL.httpString(data);
  3447.  
  3448. let dls;
  3449. for (let dl of datalist) {
  3450. let len = dl.indexOf("?");
  3451. if (len > -1) {
  3452. dls = dl.substring(len - 18, len);
  3453. }
  3454.  
  3455. if (dl.indexOf("tab") == -1 || returnlist.indexOf(dls) > -1 || dls == null) {
  3456. continue;
  3457. }
  3458. //https://t.bilibili.com/552091391342505523?tab=22
  3459. returnlist.push(dls);
  3460.  
  3461. }
  3462.  
  3463. return returnlist;
  3464. }
  3465. });
  3466.  
  3467. }, */
  3468.  
  3469.  
  3470.  
  3471. httpString: function(s) {
  3472. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  3473. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  3474. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3475. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3476. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  3477. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  3478. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  3479. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  3480. s = s.match(reg);
  3481. console.log(s)
  3482. return (s)
  3483. },
  3484.  
  3485. saveConfig: function() {
  3486.  
  3487. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  3488. /* javaex.tip({
  3489. content: "配置保存成功!",
  3490. type: "success"
  3491. }); */
  3492.  
  3493. },
  3494.  
  3495. copyText: function(domId) {
  3496. let btn = document.getElementById(domId);
  3497. btn.select();
  3498. if (document.execCommand('copy')) {
  3499. document.execCommand('copy');
  3500. javaex.tip({
  3501. content: "复制成功!",
  3502. type: "success"
  3503. });
  3504. }
  3505.  
  3506. },
  3507. /**
  3508. * s数组去重并排序
  3509. */
  3510.  
  3511. arrUnique: function(ary, isSort) {
  3512.  
  3513. if (isSort == undefined) {
  3514. isSort = true
  3515. }
  3516. let obj = {};
  3517. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  3518. let item = ary[i]
  3519. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  3520. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  3521. // 如果没有 将这个元素添加到对象中
  3522. if (isSort) {
  3523. ary.sort((a, b) => {
  3524. return a - b
  3525. }) // 数组去重后 按升序排列
  3526. }
  3527.  
  3528. obj = null;
  3529.  
  3530. javaex.tip({
  3531. content: "已去重!",
  3532. type: "success"
  3533. });
  3534. return ary;
  3535.  
  3536. },
  3537.  
  3538. split_array: function(arr, len) {
  3539.  
  3540. let arr_length = arr.length;
  3541. let newArr = [];
  3542. for (let i = 0; i < arr_length; i += len) {
  3543. newArr.push(arr.slice(i, i + len));
  3544. }
  3545. return newArr;
  3546. },
  3547. strToJson: function(params) {
  3548. const isJSON = (str => {
  3549. if (typeof str === 'string') {
  3550. try {
  3551. const obj = JSON.parse(str);
  3552. return typeof obj === 'object' ? obj : false
  3553. } catch (_) {
  3554. console.log(str);
  3555. return false;
  3556. }
  3557. } else {
  3558. console.log(`${str}\nIt is not a string!`);
  3559. return false;
  3560. }
  3561. })(params);
  3562. return isJSON ? isJSON : {}
  3563. },
  3564.  
  3565. chackAtMsg: function() {
  3566.  
  3567. let config = HNTOOL.getConfig();
  3568. if (config.qmsg_checked == true && config.qmsg_key) {
  3569.  
  3570. document.getElementById("getAtMsg").click();
  3571.  
  3572. }
  3573.  
  3574. },
  3575.  
  3576. cssChecked: function(id, dom) {
  3577.  
  3578. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  3579.  
  3580.  
  3581. },
  3582. getConfig: function() {
  3583.  
  3584. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  3585.  
  3586. if (CONFIG == null) {
  3587. CONFIG = HN_SETUP_CONFIG;
  3588. }
  3589.  
  3590. return CONFIG;
  3591. },
  3592.  
  3593. /**
  3594. * 获取cookie 中某个键对应的值
  3595. * @param name
  3596. */
  3597.  
  3598. getCookie: function(name) {
  3599. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  3600. if (arr != null) return escape(arr[2]);
  3601. return false;
  3602. },
  3603. /**
  3604. * 得到一个字符串数组的中随机一个
  3605. * @param {List} list
  3606. */
  3607.  
  3608.  
  3609. getRandomWordOfList: function(list) {
  3610. var L = list.length;
  3611. var i = Math.ceil(Math.random() * L);
  3612.  
  3613. return list[i];
  3614. },
  3615. random: function(min, max) {
  3616.  
  3617. return Math.floor(Math.random() * (max - min)) + min;
  3618. },
  3619.  
  3620. Sleep: function(ms) {
  3621. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  3622. }
  3623.  
  3624. }
  3625.  
  3626. let errorMsg = {
  3627. "-1": "应用程序不存在或已被封禁!",
  3628. "-2": "Access Key错误!",
  3629. "-3": "API校验密匙错误!",
  3630. "-4": "调用方对该Method没有权限!",
  3631. "-101": "账号未登录!",
  3632. "-102": "账号被封停!",
  3633. "-103": "积分不足!",
  3634. "-104": "硬币不足!",
  3635. "-105": "验证码错误!",
  3636. "-106": "账号非正式会员或在适应期!",
  3637. "-107": "应用不存在或者被封禁!",
  3638. "-108": "未绑定手机!",
  3639. "-109": "未知!",
  3640. "-110": "未绑定手机!",
  3641. "-111": "csrf 校验失败!",
  3642. "-112": "系统升级中!",
  3643. "-113": "账号尚未实名认证!",
  3644. "-114": "请先绑定手机!",
  3645. "-115": "请先完成实名认证!",
  3646. "-304": "木有改动!",
  3647. "-307": "撞车跳转!",
  3648. "-400": "请求错误!",
  3649. "-401": "未认证!",
  3650. "-403": "访问权限不足!",
  3651. "-404": "啥都木有!",
  3652. }
  3653.  
  3654. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  3655. /**
  3656. *
  3657. * @param code
  3658. * @constructor
  3659. */
  3660. let chackCode = function(code) {
  3661.  
  3662. let emsg = errorMsg[code + ""];
  3663. if (emsg != null) {
  3664. javaex.tip({
  3665. content: emsg,
  3666. type: "error"
  3667. });
  3668.  
  3669. return false;
  3670. }
  3671.  
  3672. return true;
  3673. }
  3674.  
  3675.  
  3676. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  3677. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  3678.  
  3679. /*window.onbeforeunload = function() {
  3680. if (!canLeavePage()) {
  3681. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  3682. }
  3683. };*/
  3684.  
  3685.  
  3686. /**
  3687. * Ajax请求对象
  3688. */
  3689. const Ajax = (() => {
  3690. /**
  3691. * 检查options是否符合要求
  3692. * @param {object} options
  3693. * @returns {boolean}
  3694. */
  3695. function checkOptions(options) {
  3696. let result = false;
  3697. if (typeof options !== 'object') {
  3698. console.warn('类型错误: typeof Options !== Object');
  3699. return result;
  3700. } else {
  3701. if (typeof options.url !== 'string') {
  3702. console.warn('类型错误: typeof Link !== Strings');
  3703. return result;
  3704. } else {
  3705. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  3706. if (!reg.test(options.url)) {
  3707. console.warn('url字符串须为完整http链接');
  3708. return result;
  3709. }
  3710. result = true;
  3711. }
  3712. }
  3713. return result;
  3714. }
  3715.  
  3716. /**
  3717. * 对象转URL编码
  3718. * @param {object} data
  3719. */
  3720. function objToURLCode(data) {
  3721. var _result = [];
  3722. for (var key in data) {
  3723. var value = data[key];
  3724. if (value instanceof Array) {
  3725. value.forEach(function(_value) {
  3726. _result.push(key + "=" + _value);
  3727. });
  3728. } else {
  3729. _result.push(key + '=' + value);
  3730. }
  3731. }
  3732. return _result.join('&');
  3733. }
  3734.  
  3735. /**
  3736. * 请求
  3737. * @param {string} method
  3738. * @param {object} options
  3739. */
  3740. function request(method, options) {
  3741. if (checkOptions(options)) {
  3742. let xhr = new XMLHttpRequest();
  3743. const {
  3744. url: _url,
  3745. queryStringsObj,
  3746. data,
  3747. dataType,
  3748. hasCookies
  3749. } = options, url = typeof queryStringsObj === 'object' ?
  3750. _url + '?' + objToURLCode(queryStringsObj) : _url;
  3751. switch (method) {
  3752. case 'GET':
  3753. xhr.open("GET", url);
  3754. break;
  3755. case 'POST':
  3756. xhr.open("POST", url);
  3757. xhr.setRequestHeader('Content-Type', dataType);
  3758. break;
  3759. default:
  3760. break;
  3761. }
  3762. if (hasCookies) xhr.withCredentials = true;
  3763. xhr.timeout = 3000;
  3764. xhr.addEventListener('load', () => {
  3765. if (xhr.status === 200) {
  3766. options.success(xhr.responseText)
  3767. } else {
  3768. console.error(`status:${xhr.status}`);
  3769. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  3770. }
  3771. })
  3772. xhr.addEventListener('error', () => {
  3773. console.error('ajax请求出错')
  3774. options.success('{"code":-1,"msg":"ajax请求出错"}');
  3775. })
  3776. xhr.addEventListener('timeout', () => {
  3777. console.error('请求超时')
  3778. options.success('{"code":-1,"msg":"请求超时"}');
  3779. })
  3780. switch (method) {
  3781. case 'GET':
  3782. xhr.send()
  3783. break;
  3784. case 'POST':
  3785. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  3786. break;
  3787. default:
  3788. break;
  3789. }
  3790. }
  3791. }
  3792.  
  3793. return {
  3794. /**
  3795. * 发送Get请求
  3796. * @param {Object} options
  3797. */
  3798. get(options) {
  3799. request("GET", options);
  3800. },
  3801. /**
  3802. * 发送Post请求
  3803. * @param {object} options
  3804. */
  3805. post(options) {
  3806. request("POST", options);
  3807. }
  3808. }
  3809. })()