-哔哩猫-(试用版)

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

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

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

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