-哔哩猫-(试用版)

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

目前為 2021-07-28 提交的版本,檢視 最新版本

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