-哔哩猫-(试用版)

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

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

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