-哔哩猫-(试用版)

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

当前为 2021-07-25 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/422731/954050/-%E5%93%94%E5%93%A9%E7%8C%AB-%EF%BC%88%E8%AF%95%E7%94%A8%E7%89%88%EF%BC%89.js

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