-哔哩猫-(试用版)

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

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

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