-哔哩猫-(试用版)

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

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

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

  1. // ==UserScript==
  2. // @name -哔哩猫-(试用版)
  3. // @description 注:练手作品,多多包涵,不接受恶意差评,有问题群内咨询(Q群1031014013):批量播放视频;批量拉黑;批量关注;动态艾特消息提醒(友情天选群746790091 )
  4. // @namespace http://tampermonkey.net/
  5. // @version 1.5.31
  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. GM_addStyle(`
  35.  
  36. #switch-qsmg:before {
  37. content: "开关";
  38. letter-spacing: 16px;
  39. top: 4px;
  40. left: 10px;
  41. }
  42. #left_navbar{
  43. z-index: 1000;
  44. position: absolute;
  45. top: 100px;
  46. left: 5px;
  47. }
  48. button[hnBtn="btn_open"] {
  49. z-index: 1001;
  50. z-index: 1000px;
  51. position: absolute;
  52. top: 58px;
  53. left: 220px;
  54. }
  55. .javaex-panel.javaex-panel-right.javaex-animated-zoom-in {
  56. top: 60px;
  57. }
  58. .javaex-menu-container {
  59. border: 1px solid #eee;
  60. }
  61. .javaex-panel-box p {
  62. text-align: center;
  63. background: #fb7299;
  64. }
  65. .fontbold{
  66. color: #00a1d6;
  67. font-weight: bold;
  68. cursor: pointer;
  69. }
  70. `);
  71.  
  72.  
  73. let HN_SETUP_CONFIG = {
  74.  
  75. qmsg_key: null, //后期改为kull 存储到本地
  76. qmsg_checked: false,
  77.  
  78.  
  79. }
  80.  
  81. let Live_info = {
  82. room_id: undefined,
  83. uid: undefined,
  84. blocked: undefined,
  85. csrf_token: undefined,
  86. visit_id: undefined,
  87. rnd: undefined,
  88. ruid: undefined,
  89. uname: undefined,
  90. user_level: undefined,
  91. ruid: undefined,
  92. };
  93.  
  94. let BILIBLI_PATH = {
  95.  
  96. "passport": "https://passport.bilibili.com",
  97. "api": "https://api.bilibili.com",
  98. "video": "https://www.bilibili.com/video/",
  99. "single_unread": "http://api.vc.bilibili.com/"
  100. }
  101.  
  102. let BILIBILI_URL = {
  103. // 导航栏用户信息
  104. "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
  105. }
  106.  
  107. let BiliData = {
  108.  
  109. this_uid: window.location.href.split("/")[3], //当前页面uid
  110. author_uid: 99439379,
  111. login_code: null,
  112. login_message: "",
  113. LoginData: {},
  114. CoinLog: {},
  115. Unread: null,
  116. Video: {},
  117. replyAction: {},
  118. upCard: {},
  119. BVList: [],
  120. }
  121.  
  122. window.onload = function () {
  123.  
  124.  
  125. //界面显示
  126. init();
  127.  
  128.  
  129. }
  130.  
  131.  
  132. function init() {
  133.  
  134. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  135. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  136.  
  137. addStyle();
  138. addSetPage();
  139.  
  140. HNTOOL.chackAtMsg();
  141.  
  142. $("#getCoinLog").bind("click", async function () {
  143.  
  144.  
  145. if (HNAPI.getCoinLog()) {
  146.  
  147. await HNTOOL.Sleep(500);
  148. let html = '';
  149. html += '<div class="javaex-panel-box" style="width: 250px;">';
  150. html += ' <ul>';
  151. html += ` <p style="color: #FFF;">硬币使用记录</p>`;
  152.  
  153. BiliData.CoinLog.list.forEach(function (item) {
  154.  
  155. let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
  156. if (BV.indexOf("BV") != -1) {
  157. html += `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
  158. }
  159. html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
  160.  
  161.  
  162. });
  163. html += ' <hr class="javaex-divider"></hr>';
  164. html += ' </ul>';
  165. html += '</div>';
  166.  
  167. javaex.panel(this, {
  168. position: "right",
  169. //offsetTop: "104",
  170. content: html
  171. });
  172. javaex.tip({
  173. content: "获取用户成功!",
  174. type: "success"
  175. });
  176.  
  177. } else {
  178. javaex.tip({
  179. content: "获取硬币记录失败,请稍后重试!",
  180. type: "error"
  181. });
  182. }
  183.  
  184.  
  185. });
  186.  
  187. $("#getUnread").bind("click", async function () {
  188.  
  189. javaex.tip({
  190. content: "获取中,请稍候...",
  191. type: "submit"
  192. });
  193. HNAPI.getUnread();
  194.  
  195.  
  196. });
  197.  
  198.  
  199. $("#likeInDynamicComments").bind("click", async function () {
  200.  
  201. let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get("likeInDynamic_PRID");
  202. let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get("likeInDynamic_OID");
  203.  
  204. let html = '';
  205.  
  206. html += '<div style="padding: 10px 10px 10px 0px;">'
  207. html += '<form id="likeInDynamic_form">'
  208. html += ' <div class="javaex-unit clear">'
  209. html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
  210. html += ' <div class="javaex-unit-right">'
  211. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
  212. html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
  213. html += ' </div>'
  214. html += ' </div>'
  215. html += ' <div class="javaex-unit clear">'
  216. html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
  217. html += ' <div class="javaex-unit-right">'
  218. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
  219. html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
  220. html += ' </div>'
  221. html += ' </div>'
  222. html += ' <div class="javaex-unit clear tc">'
  223. html += ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
  224. html += ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
  225. html += ' </div>'
  226. html += '</form>';
  227. html += '<hr class="javaex-divider"></hr>';
  228. html += '</div>';
  229.  
  230.  
  231. javaex.panel(this, {
  232. position: "right",
  233. content: html
  234. });
  235.  
  236.  
  237. // 监听点击保存按钮事件
  238. $("#likeInDynamic_yes").click(async function () {
  239. // 表单验证函数
  240. if (javaexVerify()) {
  241.  
  242. HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex.getSelectVal("#likeInDynamic_PRID"), 1);
  243. await HNTOOL.Sleep(1000);
  244.  
  245. if (BiliData.replyAction.code == 0) {
  246.  
  247. LocalData.set("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  248. LocalData.set("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  249.  
  250. javaex.tip({content: "评论区点赞成功!", type: "success"});
  251. } else {
  252. javaex.tip({content: "评论区点赞失败!", type: "error"});
  253. }
  254. if (BiliData.replyAction.code == 65006) {
  255. javaex.tip({content: "请勿重复点赞!", type: "error"});
  256. }
  257. }
  258. });
  259.  
  260. // 监听点击返回按钮事件
  261. $("#likeInDynamic_no").click(async function () {
  262.  
  263. if (javaexVerify()) {
  264.  
  265. HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +javaex.getLocalStorage("#likeInDynamic_PRID"), 0);
  266. await HNTOOL.Sleep(500);
  267.  
  268. if (BiliData.replyAction.code == 0) {
  269.  
  270. javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  271. javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  272.  
  273. javaex.tip({content: "评论区取消点赞成功!", type: "success"});
  274. } else {
  275. javaex.tip({content: "评论区取消点赞失败!", type: "error"});
  276. }
  277. if (BiliData.replyAction.code == 65006) {
  278. javaex.tip({content: "请勿重复取消点赞!", type: "error"});
  279. }
  280. }
  281. });
  282.  
  283. });
  284.  
  285. $("#biliUserMsg").bind("click", async function () {
  286.  
  287.  
  288. //刷新信息
  289. HNAPI.getUserNav();
  290. await HNTOOL.Sleep(500);
  291.  
  292. let isLogin = "未登录";
  293. let vipType = "无";
  294. //判断是否成功
  295. if (BiliData.login_code == 0) {
  296.  
  297.  
  298. if (BiliData.LoginData.isLogin) {
  299. isLogin = "已登录";
  300. }
  301.  
  302. if (BiliData.LoginData.vipType == 1) {
  303. vipType = "月度大会员";
  304. } else if (BiliData.LoginData.vipType == 2) {
  305. vipType = "年度大会员";
  306. }
  307.  
  308. let html = '';
  309. html += '<div class="javaex-panel-box" style="width: 250px;">';
  310. html += ' <ul>';
  311. html += ` <p style="color: #FFF;">用户信息</p>`;
  312. html += ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
  313. html += ` <li>用户状态:${isLogin} </li> `;
  314. html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
  315. html += ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
  316. html += ` <li>UID${BiliData.LoginData.mid} </li> `;
  317. html += ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
  318. html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
  319. html += ` <li>会员:${vipType} </li> `;
  320. html += ' <hr class="javaex-divider"></hr>';
  321. html += ' </ul>';
  322. html += '</div>';
  323.  
  324.  
  325. javaex.panel(this, {
  326. position: "right",
  327. content: html
  328. });
  329.  
  330. javaex.tip({
  331. content: "获取用户成功!",
  332. type: "success"
  333. });
  334.  
  335. } else {
  336. javaex.tip({
  337. content: "获取用户信息失败!",
  338. type: "error"
  339. });
  340. }
  341.  
  342.  
  343. });
  344.  
  345. $("#getAtMsg").bind("click", async function () {
  346.  
  347. if (HNAPI.getMsgfeed("at") && typeof (HNAPI.getMsgfeed("at")) != "undefined") {
  348.  
  349. javaex.tip({
  350. content: "可能中奖了!!!",
  351. type: "success"
  352. });
  353. }
  354. });
  355.  
  356.  
  357. $("#disUser").bind("click", async function () {
  358.  
  359. let html = '';
  360. html += '<div class="javaex-panel-box" style="width: 500px;">';
  361. html += ' <div class="javaex-unit clear">';
  362. html += ' <div class="javaex-unit-left ml-10 mt-10">*拉黑列表</div>';
  363. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  364. html += ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
  365. html += ' </div>';
  366. html += ' </div>';
  367. html += ' <div class="javaex-unit clear tc">';
  368. html += ' <input type="button" id="disUser_beg" class="javaex-btn yes" value="开始" />';
  369. html += ' </div>';
  370. html += '</div>';
  371.  
  372. javaex.panel(this, {
  373. position: "right",
  374. content: html
  375. });
  376.  
  377. $("#disUser_beg").bind("click", async function () {
  378.  
  379. let disUser_str = javaex.getSelectVal("#disUser_uidList");
  380. disUser_uidList = disUser_str.split(",");
  381.  
  382. let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
  383. for (const vmid of disUserStr) {
  384.  
  385. HNAPI.batchModify(vmid.toString(), 5);
  386. await HNTOOL.Sleep(6000);
  387. }
  388.  
  389.  
  390. /* let disUser_str = javaex.getSelectVal("#disUser_uidList");
  391. let disUser_uidList = disUser_str.split(",");
  392.  
  393. for (const vmid of disUser_uidList) {
  394.  
  395. HNAPI.disUserByUid(vmid);
  396.  
  397. await HNTOOL.Sleep(1500);
  398.  
  399. }
  400. */
  401. });
  402.  
  403. });
  404.  
  405. $("#arrUnique").bind("click", async function () {
  406.  
  407. let html = '';
  408. html += '<div class="javaex-panel-box" style="width: 500px;">';
  409. html += ' <div class="javaex-unit clear">';
  410. html += ' <div class="javaex-unit-left ml-10 mt-10">*数组</div>';
  411. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  412. html += ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  413. html += ' </div>';
  414. html += ' </div>';
  415. html += ' <div class="javaex-unit clear tc">';
  416. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="开始" />';
  417. html += ' </div>';
  418. html += '</div>';
  419.  
  420. javaex.panel(this, {
  421. position: "right",
  422. content: html
  423. });
  424.  
  425. $("#arrUnique_beg").bind("click", async function () {
  426.  
  427. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  428. let arrUnique_uidList = arrUnique_str.split(",");
  429.  
  430. let arrUniqueStr = HNTOOL.arrUnique(arrUnique_uidList).toString();
  431.  
  432. document.getElementById("arrUnique_str").value = arrUniqueStr;
  433.  
  434. });
  435.  
  436. });
  437.  
  438. $("#batchFollow").bind("click", async function () {
  439.  
  440. var thisUPName = $("#h-name").text();
  441.  
  442.  
  443. let html = '';
  444. html += '<div class="javaex-panel-box" style="width: 600px;">';
  445. html += ' <div class="javaex-unit clear">';
  446. html += ' <div class="javaex-unit-left ml-10 mt-10">*关注列表</div>';
  447. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  448. html += ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
  449. html += ' </div>';
  450. html += ' </div>';
  451. html += ' <div class="javaex-unit clear tc" >';
  452. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  453. html += ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="爬取关注" />';
  454. html += ` <input type="button" id="Follow_thisUp" class="javaex-btn yes tc" value="关注${thisUPName}" />`;
  455. html += ` <input type="button" id="disFollow_thisUp" class="javaex-btn yes tc" value="拉黑${thisUPName}" /> `;
  456. html += ' </div>';
  457. html += '</div>';
  458.  
  459. javaex.panel(this, {
  460. position: "right",
  461. content: html
  462. });
  463.  
  464. $("#disFollow_thisUp").bind("click", async function () {
  465.  
  466. HNAPI.batchModify(BiliData.this_uid, 5);
  467.  
  468. });
  469.  
  470. $("#Follow_thisUp").bind("click", async function () {
  471.  
  472. HNAPI.batchModify(BiliData.this_uid);
  473.  
  474. });
  475.  
  476. $("#batchFollow_beg").bind("click", async function () {
  477.  
  478. let mid_str = javaex.getSelectVal("#batchFollow_uidList");
  479. mid_list = mid_str.split(",");
  480.  
  481. let mid_Lists = HNTOOL.split_array(mid_list, 15);
  482. for (const mids of mid_Lists) {
  483.  
  484. HNAPI.batchModify(mids.toString());
  485. await HNTOOL.Sleep(10000);
  486. }
  487.  
  488.  
  489. });
  490.  
  491. $("#crawler_follow").bind("click", async function () {
  492.  
  493. //x/space/myinfo
  494. let myinfoData = await HNAPI.getMyinfo();
  495. await HNAPI.getUpCard(myinfoData.mid);
  496. await HNTOOL.Sleep(1000);
  497. let len = parseInt(BiliData.upCard.data.card.attention / 20);
  498. let followData = [];
  499.  
  500. for (let i = 0; i < len; i++) {
  501. if (BiliData.upCard.code != 0) {
  502. javaex.tip({
  503. content: `爬取关注出现异常 终止爬取!{BiliData.upCard.message}`,
  504. type: "error"
  505. });
  506. break;
  507. }
  508.  
  509. javaex.tip({
  510. content: `正在爬取`+myinfoData.mid+`的`+i+`页的关注!!!`,
  511. type: "success"
  512. });
  513.  
  514. let followList = await HNAPI.getMyFollow(myinfoData.mid, i);
  515.  
  516. for (const fl of followList.list) {
  517.  
  518. if (fl.official_verify.type != 1 || fl.vip.vipType == 0) {
  519. continue;
  520. }
  521.  
  522. followData.push(fl.mid);
  523.  
  524. }
  525.  
  526. await HNTOOL.Sleep(3000);
  527. }
  528.  
  529. document.getElementById("batchFollow_uidList").value = followData.toString();
  530.  
  531. });
  532.  
  533.  
  534. });
  535.  
  536.  
  537. $("#HNSetup").bind("click", async function () {
  538.  
  539. var CONFIG = HNTOOL.getConfig();
  540.  
  541.  
  542. let html = '';
  543.  
  544. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  545. html += '<form id="HNGG_SETUP">'
  546. html += ' <div class="javaex-unit clear">'
  547. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Q酱key</p></div>'
  548. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  549. html += ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  550. html += ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  551. html += ' </div>'
  552. html += ' <div class="javaex-unit-left mr-10">'
  553. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  554. html += ' </div>'
  555. html += ' </div>'
  556. html += '</form>';
  557. html += '<div class="javaex-unit clear tc">';
  558. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  559. html += '</div>';
  560. html += '<hr class="javaex-divider"></hr>';
  561. html += '</div>';
  562.  
  563. javaex.panel(this, {
  564. position: "right",
  565. content: html
  566. });
  567.  
  568.  
  569. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  570.  
  571. $("#switch-qsmg").bind("click", function () {
  572.  
  573. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  574.  
  575. })
  576.  
  577.  
  578. $("#HNSetup_save").bind("click", async function () {
  579.  
  580.  
  581. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  582.  
  583. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  584.  
  585. javaex.tip({
  586. content: "设置成功!",
  587. type: "success"
  588. });
  589.  
  590. });
  591.  
  592. });
  593.  
  594. //
  595. $("#getUpMassage").bind("click", async function () {
  596.  
  597.  
  598. let html = '';
  599.  
  600. html += '<div style="padding: 10px 10px 10px 0px;">'
  601. html += '<form id="getUpMassage_form">'
  602. html += ' <div class="javaex-unit clear">'
  603. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  604. html += ' <div class="javaex-unit-left mr-10">'
  605. html += ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  606. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  607. html += ' </div>'
  608. html += ' <div class="javaex-unit-right mr-10">'
  609. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  610. html += ' </div>'
  611. html += ' </div>'
  612. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  613. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  614. html += ' <thead>'
  615. html += ' <tr><th>内容</th><th>详情</th></tr>'
  616. html += ' </thead>'
  617. html += ' <tbody id="upMsgTbody">'
  618.  
  619. html += ' </tbody>'
  620. html += '</table> '
  621. html += '</div>'
  622. html += '</form>';
  623. html += '<hr class="javaex-divider"></hr>';
  624. html += '</div>';
  625.  
  626.  
  627. javaex.panel(this, {
  628. position: "right",
  629. content: html
  630. });
  631.  
  632. javaex.table({
  633. id: "upMsgTable",
  634. isDragColWidth: true, // 是否允许拖动改变列宽
  635. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  636. leftFixedColNum: 2, // 左侧固定列数
  637. rightFixedColNum: 1, // 右侧固定列数
  638. sort: {
  639. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  640. "2": "update_time"
  641. },
  642. sortCallback: function (rtn) {
  643. //console.log(rtn.sortArr);
  644. }
  645. });
  646.  
  647. //
  648. $("#getUpMsg").click(async function () {
  649.  
  650. let thismid = javaex.getSelectVal("#up_uid");
  651. await HNAPI.userInfo(thismid)
  652.  
  653. let temp = await HNAPI.getUpCard(thismid);
  654.  
  655.  
  656. await HNTOOL.Sleep(500);
  657.  
  658.  
  659. if (temp != false) {
  660. let data = BiliData.upCard.data;
  661.  
  662. let html = ``;
  663. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  664. html += `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  665. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  666. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  667. html += `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  668. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  669. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  670. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  671. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  672. html += `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  673. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  674. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  675.  
  676.  
  677. $("#upMsgTbody").empty();
  678. $("#upMsgTbody").append(html);
  679. }
  680.  
  681.  
  682. });
  683. //点击放大
  684. /* $("img").click(function() {
  685. javaex.dialog({
  686. type : "image", // 弹出层类型
  687. url : $(this).attr("src") // 图片地址
  688. });
  689. });*/
  690.  
  691. });
  692.  
  693.  
  694. $("#plateActivity").bind("click", async function () {
  695.  
  696. //获取轮盘数据
  697.  
  698. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/plateActivity.json";
  699. let myjson = await HNAPI.getMyJson(url);
  700.  
  701. for (const json of myjson) {
  702. let x = json.name;
  703.  
  704. }
  705.  
  706.  
  707. });
  708.  
  709. $("#addPlay").bind("click", async function () {
  710.  
  711.  
  712. let html = '';
  713.  
  714. html += '<div style="padding: 10px 10px 10px 0px;">'
  715. html += '<form id="getUpMassage_form">'
  716.  
  717. html += ' <div class="javaex-unit clear">'
  718. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  719. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  720. html += ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  721. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  722. html += ' </div>'
  723. html += ' </div>'
  724. html += ' <div class="javaex-unit clear">'
  725. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  726. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  727. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  728. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  729. html += ' </div>'
  730. html += ' </div>'
  731. html += '</form>';
  732. html += ' <div class="javaex-unit clear tc">'
  733. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  734. html += ' </div>'
  735. html += '<hr class="javaex-divider"></hr>';
  736. html += '</div>';
  737.  
  738.  
  739. javaex.panel(this, {
  740. position: "right",
  741. content: html
  742. });
  743.  
  744. $("#addPlay_bgn").click(async function () {
  745.  
  746. let MID = javaex.getSelectVal("#addPlay_uid")
  747. let BV = javaex.getSelectVal("#addPlay_bv");
  748. let bvArr = [];
  749. let bvArr2 = [];
  750.  
  751. MID = javaex.ifnull(MID, BiliData.author_uid);
  752.  
  753.  
  754. if (BV == "0") {
  755.  
  756. //1.查询up所有视频BV号 2.发送心跳间隔2s
  757. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  758. await HNTOOL.Sleep(500);
  759. bvArr2 = BiliData.BVList;
  760.  
  761. for (let i = 1; i > 0; i++) {
  762.  
  763. HNAPI.getUpAllBV(MID, i);
  764.  
  765. await HNTOOL.Sleep(500);
  766.  
  767. if (BiliData.BVList.length == 0) {
  768. if (bvArr.length == 0) {
  769. javaex.tip({
  770. content: "该用户无投稿视频,请确认是否有误!",
  771. type: "success"
  772. });
  773. await HNTOOL.Sleep(2000);
  774. }
  775. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  776. bvArr = bvArr.concat(bvArr2);
  777. break;
  778. }
  779.  
  780. bvArr = bvArr.concat(BiliData.BVList);
  781. }
  782.  
  783.  
  784. if (bvArr.length != 0) {
  785.  
  786. for (const emt of bvArr) {
  787.  
  788. HNAPI.playOneVideo(emt.bvid, MID);
  789.  
  790. await HNTOOL.Sleep(2000);
  791.  
  792. }
  793.  
  794. alert("播放完成!!!");
  795.  
  796. }
  797.  
  798.  
  799. } else {
  800. //1.调用点击播放接口
  801. //2.发送心跳
  802.  
  803. await HNTOOL.Sleep(500);
  804.  
  805. HNAPI.playOneVideo(BV);
  806. }
  807.  
  808.  
  809. });
  810.  
  811.  
  812. });
  813.  
  814. }
  815.  
  816. let showUnreadMsg = function () {
  817.  
  818. var html = '';
  819. html += '<div class="javaex-panel-box" style="width: 250px;">';
  820. html += ' <ul>';
  821. html += ` <p style="color: #FFF;">用户消息</p>`;
  822. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  823. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  824. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  825. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  826. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  827. html += ' <hr class="javaex-divider"></hr>';
  828. html += ' </ul>';
  829. html += '</div>';
  830.  
  831.  
  832. javaex.panel(document.getElementById("getUnread"), {
  833. position: "right",
  834. content: html
  835. });
  836.  
  837. javaex.tip({
  838. content: "查询用户通知成功!",
  839. type: "success"
  840. });
  841.  
  842. }
  843.  
  844. /**
  845. * 检查 艾特信息
  846. * @returns {Promise<void>}
  847. */
  848. let chackAtMsg = async function (items) {
  849.  
  850. await HNTOOL.Sleep(500);
  851.  
  852. if (items != false && typeof (items) != "undefined") {
  853.  
  854.  
  855. var html = '';
  856. html += '<div class="javaex-panel-box" style="width: auto;">';
  857. html += ' <ul>';
  858. html += ` <p style="color: #FFF;">@信息</p>`;
  859. items.forEach(function (item) {
  860.  
  861. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  862. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" + `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  863.  
  864. html += ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  865. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  866. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  867. html += ' <hr class="javaex-divider"></hr>';
  868. });
  869. html += ' </ul>';
  870. html += '</div>';
  871.  
  872.  
  873. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  874. javaex.panel(document.getElementById("getAtMsg"), {
  875. position: "right",
  876. content: html
  877. });
  878. } else {
  879. javaex.panel(document.getElementById("chackList"), {
  880. position: "right",
  881. content: html
  882. });
  883. }
  884.  
  885.  
  886. }
  887.  
  888. }
  889.  
  890.  
  891. let addSetPage = async function () {
  892.  
  893. HNTOOL.Sleep(1000);
  894.  
  895. $('body').append('' +
  896. '<div id="left_navbar">' +
  897. '<div class="javaex-menu-container"> ' +
  898. ' <div id="menu" class="javaex-menu"> ' +
  899. ' <ul> ' +
  900. ' <li class="javaex-menu-item alone hover" > ' +
  901. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  902. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  903. ' </li> ' +
  904. ' </ul> ' +
  905. ' <ul> ' +
  906. ' <li class="javaex-menu-item"> ' +
  907. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  908. ' <ul> ' +
  909. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  910. ' </ul> ' +
  911. ' </li> ' +
  912. ' <li id="chackList" class="javaex-menu-item"> ' +
  913. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  914. ' <ul> ' +
  915. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  916. ' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  917. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  918. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  919. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  920. ' </ul> ' +
  921. ' </li> ' +
  922. ' <li class="javaex-menu-item"> ' +
  923. ' <a href="javascript:;">工具<i class="icon-angle-down"></i></a> ' +
  924. ' <ul> ' +
  925. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  926. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  927. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  928. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  929. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  930. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑</a></li> ' +
  931. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  932. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  933. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  934. ' <li id="" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' +//likeInDynamicComments
  935. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  936. ' </ul> ' +
  937. ' </li> ' +
  938. ' <li class="javaex-menu-item"> ' +
  939. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  940. ' <ul> ' +
  941. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  942. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  943. ' </ul> ' +
  944. ' </li> ' +
  945.  
  946. ' </ul> ' +
  947. ' </div> ' +
  948. '</div>' +
  949. '</div>');
  950. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  951.  
  952. javaex.menu({
  953. id: "menu",
  954. isShowAll: false
  955. });
  956.  
  957. }
  958.  
  959.  
  960. let addStyle = function () {
  961. const animate = GM_getResourceText('animate');
  962. const common = GM_getResourceText('common');
  963. const defaultCss = GM_getResourceText('defaultCss');
  964. //const icomoonex = GM_getResourceText('icomoonex');
  965. //const AllCss = animate + common + defaultCss + icomoonex;
  966. const AllCss = animate + common + defaultCss;
  967. const style = document.createElement('style');
  968. style.innerHTML = AllCss;
  969. return document.getElementsByTagName('head')[0].appendChild(style);
  970. }
  971.  
  972. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  973.  
  974.  
  975. /*-----------------------------------------------常用API--------------------------------------------------*/
  976.  
  977. let HNAPI = {
  978. /**
  979. * 查询用户关注 默认一次查询50
  980. * @param vmid 用户uid
  981. * @param pn 页码
  982. * @returns {Promise<unknown>}
  983. */
  984. getMyFollow: async function (vmid, pn) {
  985. return new Promise((resolve) => {
  986. Ajax.get({
  987. url: BILIBLI_PATH.api + '/x/relation/followings',
  988. queryStringsObj: {
  989. vmid:vmid,
  990. pn:pn
  991. },
  992. hasCookies: true,
  993. success: responseText => {
  994. let res = HNTOOL.strToJson(responseText);
  995. if (res.code === 0) {
  996. resolve(res.data)
  997. } else {
  998. resolve(null)
  999. }
  1000. }
  1001. })
  1002. });
  1003. },
  1004.  
  1005.  
  1006. getMyinfo: function () {
  1007. return new Promise((resolve) => {
  1008. Ajax.get({
  1009. url: BILIBLI_PATH.api + '/x/space/myinfo',
  1010. queryStringsObj: {},
  1011. hasCookies: true,
  1012. success: responseText => {
  1013. let res = HNTOOL.strToJson(responseText);
  1014. if (res.code === 0) {
  1015. resolve(res.data)
  1016. } else {
  1017. resolve(null)
  1018. }
  1019. }
  1020. })
  1021. });
  1022. },
  1023.  
  1024. getMyJson: function (url) {
  1025. return new Promise((resolve) => {
  1026. GM_xmlhttpRequest({
  1027. method: "GET",
  1028. url: url,
  1029. onload: function (response) {
  1030. const res = HNTOOL.strToJson((response || {}).responseText)
  1031. resolve(res);
  1032. }
  1033. });
  1034. })
  1035. },
  1036.  
  1037.  
  1038. userInfo: function (mid) {
  1039.  
  1040. Ajax.get({
  1041. url: BILIBLI_PATH.api + '/x/space/acc/info',
  1042. queryStringsObj: {
  1043. mid: mid
  1044. },
  1045. hasCookies: true,
  1046. success: responseText => {
  1047.  
  1048. var json = JSON.parse(responseText);
  1049.  
  1050. if (json.code != 0) {
  1051.  
  1052.  
  1053. }
  1054. }
  1055. });
  1056.  
  1057. },
  1058.  
  1059. sendQmsg: function (key, msg) {
  1060.  
  1061. GM_xmlhttpRequest({
  1062. method: "GET",
  1063. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  1064. onload: function (response) {
  1065.  
  1066. let json = JSON.parse(response.response);
  1067. if (json.code == 0) {
  1068.  
  1069. javaex.tip({
  1070. content: "自动动态中奖提醒成功!" + json.reason,
  1071. type: "success"
  1072. });
  1073. } else {
  1074. console.log("自动动态中奖提醒失败!" + json.reason);
  1075. javaex.tip({
  1076. content: "自动动态中奖提醒失败!" + json.reason,
  1077. type: "error"
  1078. });
  1079. }
  1080.  
  1081. }
  1082. });
  1083.  
  1084. },
  1085.  
  1086. /**
  1087. * 批量关注和拉黑 batchModify
  1088. *
  1089. * https://api.bilibili.com/x/relation/batch/modify
  1090. * @param uid
  1091. */
  1092.  
  1093. batchModify: function (uids, act) {
  1094.  
  1095.  
  1096. Ajax.post({
  1097. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  1098. hasCookies: true,
  1099. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1100. data: {
  1101.  
  1102. "fids": uids,
  1103. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  1104. "re_src": 151,
  1105. csrf: Live_info.csrf_token,
  1106. },
  1107. success: responseText => {
  1108.  
  1109. let json = JSON.parse(responseText);
  1110.  
  1111. if (/^{"code":0/.test(responseText)) {
  1112.  
  1113. javaex.tip({
  1114. content: `执行成功!---失败({json.data.failed_fids.length}个)名单:` + json.data.failed_fids,
  1115. type: "success"
  1116. });
  1117.  
  1118. } else {
  1119. javaex.tip({
  1120. content: "关注失败!" + json.message,
  1121. type: "error"
  1122. });
  1123. }
  1124. }
  1125. })
  1126. },
  1127.  
  1128.  
  1129. /**
  1130. * //https://api.bilibili.com/x/relation/modify
  1131. *
  1132. * @param UID
  1133. */
  1134. disUserByUid: function (vmid) {
  1135.  
  1136. Ajax.post({
  1137. url: BILIBLI_PATH.api + '/x/relation/modify',
  1138. data: {
  1139. fid: parseInt(vmid),
  1140. re_src: 11,
  1141. act: 5,
  1142. jsonp: "jsonp",
  1143. csrf: Live_info.csrf_token,
  1144. },
  1145. hasCookies: true,
  1146. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1147. success: responseText => {
  1148.  
  1149. var json = JSON.parse(responseText);
  1150.  
  1151. if (json.code != 0) {
  1152.  
  1153. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  1154. javaex.tip({
  1155. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  1156. type: "error"
  1157. });
  1158.  
  1159. } else {
  1160. console.log("拉黑用户成功 uid:" + vmid);
  1161. javaex.tip({
  1162. content: "拉黑用户成功 uid:" + vmid,
  1163. type: "success"
  1164. });
  1165. }
  1166. }
  1167. });
  1168.  
  1169. },
  1170. /**
  1171. * http://api.bilibili.com/x/web-interface/view
  1172. * @param BV
  1173. * 心跳间隔15秒
  1174. */
  1175. playOneVideo: function (BV, MID) {
  1176.  
  1177. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  1178. Ajax.post({
  1179. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  1180. hasCookies: true,
  1181. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1182. data: {
  1183.  
  1184. "bvid": BV,
  1185. "part": 1,
  1186. "mid": Live_info.uid,
  1187. "lv": 2,
  1188. "jsonp": "jsonp",
  1189. "type": 3,
  1190. "sub_type": 0
  1191. },
  1192. success: responseText => {
  1193.  
  1194. let json = JSON.parse(responseText);
  1195.  
  1196. if (/^{"code":0/.test(responseText)) {
  1197. //发送一次心跳
  1198. HNAPI.sendHeartbeat(BV, MID);
  1199.  
  1200. } else {
  1201. javaex.tip({
  1202. content: "视频" + data.bvid + "播放失败!" + json.message,
  1203. type: "error"
  1204. });
  1205. }
  1206. }
  1207. })
  1208.  
  1209.  
  1210. },
  1211.  
  1212. //上报视频播放心跳(web端)
  1213. /**
  1214. * http://api.bilibili.com/x/click-interface/web/heartbeat
  1215. * @param json
  1216. */
  1217. sendHeartbeat: function (bvid, MID) {
  1218.  
  1219. Ajax.post({
  1220. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  1221. hasCookies: true,
  1222. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1223. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  1224. data: {
  1225. "bvid": bvid,
  1226. "type": 3,
  1227. "dt": 2,
  1228. "played_time": HNTOOL.random(12, 40),
  1229. "realtime": HNTOOL.random(12, 40),
  1230. "play_type": 0
  1231. },
  1232. success: responseText => {
  1233.  
  1234. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  1235.  
  1236. javaex.tip({
  1237. content: "视频BV" + bvid + "播放一次!",
  1238. type: "success"
  1239. });
  1240. }
  1241. }
  1242. })
  1243.  
  1244. },
  1245.  
  1246. //获取up所有投稿视频
  1247. /**
  1248. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  1249. * @param mid
  1250. */
  1251. getUpAllBV: function (mid, pn, ps) {
  1252. ps = (ps === undefined ? 30 : ps); // a默认值为1
  1253. Ajax.get({
  1254. url: BILIBLI_PATH.api + '/x/space/arc/search',
  1255. queryStringsObj: {
  1256. mid: mid,
  1257. tid: 0,
  1258. order: 'pubdate',
  1259. jsonp: 'jsonp',
  1260. pn: pn,
  1261. ps: ps
  1262. },
  1263. hasCookies: true,
  1264. success: responseText => {
  1265.  
  1266. var json = JSON.parse(responseText);
  1267.  
  1268. if (json.code != 0) {
  1269.  
  1270. javaex.tip({
  1271. content: "获取up所有投稿视频失败!" + json.message,
  1272. type: "success"
  1273. });
  1274.  
  1275. } else {
  1276. BiliData.BVList = json.data.list.vlist;
  1277.  
  1278. }
  1279. }
  1280. });
  1281.  
  1282. },
  1283.  
  1284.  
  1285. /**
  1286. *
  1287. * @param path
  1288. * @param data
  1289. * @param saveObj
  1290. * @param Func
  1291. */
  1292. publicGet: function (path, queryStringsObj) {
  1293.  
  1294. if (typeof (queryStringsObj) != "undefined") {
  1295. queryStringsObj = {};
  1296. }
  1297. Ajax.get({
  1298. url: BILIBLI_PATH.api + path,
  1299. queryStringsObj: queryStringsObj,
  1300. hasCookies: true,
  1301. success: responseText => {
  1302.  
  1303. let json = JSON.parse(responseText);
  1304. if (chackCode(json.code) && json.code == 0) {
  1305.  
  1306. return json.data;
  1307. }
  1308.  
  1309. return false;
  1310.  
  1311. }
  1312. })
  1313.  
  1314. },
  1315.  
  1316. /**
  1317. * 导航栏用户信息
  1318. */
  1319. getUserNav: async function () {
  1320.  
  1321. GM_xmlhttpRequest({
  1322. method: "GET",
  1323. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  1324. //timeout:3000,
  1325. onload: function (response) {
  1326.  
  1327. let json = JSON.parse(response.response);
  1328. console.log(json);
  1329. BiliData.login_code = json.code;
  1330. BiliData.login_message = json.message;
  1331. BiliData.LoginData = json.data;
  1332.  
  1333. }
  1334. });
  1335.  
  1336. },
  1337.  
  1338. /**
  1339. * 获取某up详细信息
  1340. * http://api.bilibili.com/x/web-interface/card
  1341. */
  1342. getUpCard: function (mid) {
  1343.  
  1344. Ajax.get({
  1345. url: BILIBLI_PATH.api + '/x/web-interface/card',
  1346. queryStringsObj: {
  1347. mid: mid,
  1348. photo: false
  1349. },
  1350. hasCookies: true,
  1351. success: responseText => {
  1352.  
  1353. var json = JSON.parse(responseText);
  1354.  
  1355. if (json.code != 0) {
  1356.  
  1357. javaex.tip({
  1358. content: "查询失败!" + json.message,
  1359. type: "success"
  1360. });
  1361. return false;
  1362. } else {
  1363. BiliData.upCard = json;
  1364.  
  1365. }
  1366.  
  1367.  
  1368. }
  1369. })
  1370.  
  1371. },
  1372.  
  1373. /**
  1374. *
  1375. * @param uid 用户uid
  1376. * @param ps 每页视频个数 默认30个
  1377. * @param pn 第几页
  1378. */
  1379. getUpAllVideo: function (uid, ps, pn) {
  1380.  
  1381. },
  1382. getChallenge: async function () {
  1383.  
  1384.  
  1385. },
  1386. /**
  1387. * 硬币记录
  1388. * @returns {Promise<void>}
  1389. */
  1390. getCoinLog: async function () {
  1391.  
  1392. GM_xmlhttpRequest({
  1393. method: "GET",
  1394. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  1395. //url: "http://api.bilibili.com/x/member/web/coin/log",
  1396. onload: function (response) {
  1397.  
  1398. let json = JSON.parse(response.response);
  1399. if (json.code == 0) {
  1400.  
  1401. console.log("硬币记录" + json);
  1402. BiliData.CoinLog = json.data;
  1403.  
  1404. return true;
  1405. }
  1406.  
  1407. }
  1408. });
  1409. },
  1410. /**
  1411. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  1412. * @returns {Promise<void>}
  1413. */
  1414. getUnread: async function () {
  1415.  
  1416. Ajax.get({
  1417. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1418. hasCookies: true,
  1419. success: responseText => {
  1420.  
  1421. let json = JSON.parse(responseText);
  1422. if (chackCode(json.code) && json.code == 0) {
  1423.  
  1424. BiliData.Unread = json.data;
  1425. showUnreadMsg();
  1426. }
  1427.  
  1428. return false;
  1429.  
  1430. }
  1431. })
  1432.  
  1433. /* GM_xmlhttpRequest({
  1434. method: "GET",
  1435. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1436. onload: function (response) {
  1437.  
  1438. let json = JSON.parse(response.response);
  1439.  
  1440. if (chackCode(json.code) && json.code == 0) {
  1441.  
  1442. BiliData.Unread = json.code;
  1443. showUnreadMsg();
  1444.  
  1445. }
  1446.  
  1447. }
  1448. });*/
  1449. },
  1450. /**
  1451. *
  1452. * @param type reply:回复我的 at @我的
  1453. */
  1454. getMsgfeed: function (type) {
  1455. Ajax.get({
  1456. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  1457. queryStringsObj: {
  1458. build: 0,
  1459. mobi_app: 'web'
  1460. },
  1461. hasCookies: true,
  1462. success: responseText => {
  1463.  
  1464. var json = JSON.parse(responseText);
  1465.  
  1466. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  1467. return false;
  1468. } else {
  1469. chackAtMsg(json.data.items);
  1470.  
  1471. return true;
  1472. }
  1473.  
  1474.  
  1475. }
  1476. })
  1477.  
  1478. },
  1479.  
  1480. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  1481. * @returns {Promise<void>}
  1482. */
  1483. getUnrewad: async function () {
  1484.  
  1485. GM_xmlhttpRequest({
  1486. method: "GET",
  1487. data: {
  1488. "mid": 99439379,
  1489. "pn": 1,
  1490. "ps": 5,
  1491. },
  1492. url: BILIBLI_PATH.api + "/x/space/arc/search",
  1493. onload: function (response) {
  1494.  
  1495. let json = JSON.parse(response.response);
  1496. if (json.code == 0) {
  1497.  
  1498. BiliData.Video = json.data;
  1499. console.log("未读消息数" + json);
  1500. }
  1501.  
  1502. }
  1503. });
  1504. },
  1505.  
  1506. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  1507. * @param {number} oid
  1508. * @param {nbumber} rpid
  1509. * @param {number} action
  1510. * @returns {Promise<void>}
  1511. * type: 11
  1512. * ordering: heat
  1513. * jsonp: jsonp
  1514. * csrf: 54a******* CSRF Token(位于cookie)
  1515. */
  1516.  
  1517. likeInDynamicComments: async function (oid, rpid, action) {
  1518.  
  1519.  
  1520. Ajax.post({
  1521. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  1522. hasCookies: true,
  1523. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1524. data: {
  1525. "oid": oid,
  1526. "type": 11,
  1527. "rpid": rpid,
  1528. "action": action,
  1529. "ordering": "heat",
  1530. "jsonp": "jsonp",
  1531. "csrf": Live_info.csrf_token,
  1532. },
  1533. success: responseText => {
  1534.  
  1535. if (/^{"code":0/.test(responseText)) {
  1536.  
  1537. BiliData.replyAction = JSON.parse(responseText);
  1538. console.log("点赞成功!" + responseText);
  1539. }
  1540. }
  1541. })
  1542.  
  1543. }
  1544.  
  1545.  
  1546. }
  1547.  
  1548. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  1549.  
  1550.  
  1551. let HNTOOL = {
  1552. /**
  1553. * s数组去重并排序
  1554. */
  1555.  
  1556. arrUnique: function (ary) {
  1557.  
  1558. let obj = {};
  1559. for (let i = 0; i < ary.length; i++) {//this 指向方法.前的对象ary
  1560. let item = ary[i]
  1561. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  1562. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  1563. // 如果没有 将这个元素添加到对象中
  1564. ary.sort((a, b) => {
  1565. return a - b
  1566. })// 数组去重后 按升序排列
  1567. obj = null;
  1568. return ary;
  1569.  
  1570. },
  1571.  
  1572. split_array: function (arr, len) {
  1573.  
  1574. let arr_length = arr.length;
  1575. let newArr = [];
  1576. for (let i = 0; i < arr_length; i += len) {
  1577. newArr.push(arr.slice(i, i + len));
  1578. }
  1579. return newArr;
  1580. },
  1581. strToJson: function (params) {
  1582. const isJSON = (str => {
  1583. if (typeof str === 'string') {
  1584. try {
  1585. const obj = JSON.parse(str);
  1586. return typeof obj === 'object' ? obj : false
  1587. } catch (_) {
  1588. console.log(str);
  1589. return false;
  1590. }
  1591. } else {
  1592. console.log(`${str}\nIt is not a string!`);
  1593. return false;
  1594. }
  1595. })(params);
  1596. return isJSON ? isJSON : {}
  1597. },
  1598.  
  1599. chackAtMsg: function () {
  1600.  
  1601. let config = HNTOOL.getConfig();
  1602. if (config.qmsg_checked == true && config.qmsg_key) {
  1603.  
  1604. document.getElementById("getAtMsg").click();
  1605.  
  1606. }
  1607.  
  1608. },
  1609.  
  1610. cssChecked: function (id, dom) {
  1611.  
  1612. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  1613.  
  1614.  
  1615. },
  1616. getConfig: function () {
  1617.  
  1618. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  1619.  
  1620. if (CONFIG == null) {
  1621. CONFIG = HN_SETUP_CONFIG;
  1622. }
  1623.  
  1624. return CONFIG;
  1625. },
  1626.  
  1627. /**
  1628. * 获取cookie 中某个键对应的值
  1629. * @param name
  1630. */
  1631.  
  1632. getCookie: function (name) {
  1633. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  1634. if (arr != null) return unescape(arr[2]);
  1635. return false;
  1636. },
  1637. /**
  1638. * 得到一个字符串数组的中随机一个
  1639. * @param {List} list
  1640. */
  1641. getRandomWordOfList: function (list) {
  1642. var L = list.length;
  1643. var i = Math.ceil(Math.random() * L);
  1644.  
  1645. return list[i];
  1646. },
  1647. random: function (min, max) {
  1648.  
  1649. return Math.floor(Math.random() * (max - min)) + min;
  1650. },
  1651.  
  1652. Sleep: function (ms) {
  1653. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  1654. }
  1655.  
  1656. }
  1657.  
  1658. let errorMsg = {
  1659. "-1": "应用程序不存在或已被封禁!",
  1660. "-2": "Access Key错误!",
  1661. "-3": "API校验密匙错误!",
  1662. "-4": "调用方对该Method没有权限!",
  1663. "-101": "账号未登录!",
  1664. "-102": "账号被封停!",
  1665. "-103": "积分不足!",
  1666. "-104": "硬币不足!",
  1667. "-105": "验证码错误!",
  1668. "-106": "账号非正式会员或在适应期!",
  1669. "-107": "应用不存在或者被封禁!",
  1670. "-108": "未绑定手机!",
  1671. "-109": "未知!",
  1672. "-110": "未绑定手机!",
  1673. "-111": "csrf 校验失败!",
  1674. "-112": "系统升级中!",
  1675. "-113": "账号尚未实名认证!",
  1676. "-114": "请先绑定手机!",
  1677. "-115": "请先完成实名认证!",
  1678. "-304": "木有改动!",
  1679. "-307": "撞车跳转!",
  1680. "-400": "请求错误!",
  1681. "-401": "未认证!",
  1682. "-403": "访问权限不足!",
  1683. "-404": "啥都木有!",
  1684. }
  1685.  
  1686. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  1687. /**
  1688. *
  1689. * @param code
  1690. * @constructor
  1691. */
  1692. let chackCode = function (code) {
  1693.  
  1694. let emsg = errorMsg[code + ""];
  1695. if (emsg != null) {
  1696. javaex.tip({content: emsg, type: "error"});
  1697.  
  1698. return false;
  1699. }
  1700.  
  1701. return true;
  1702. }
  1703.  
  1704.  
  1705. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  1706. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  1707.  
  1708. /*window.onbeforeunload = function() {
  1709. if (!canLeavePage()) {
  1710. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  1711. }
  1712. };*/
  1713.  
  1714.  
  1715. /**
  1716. * Ajax请求对象
  1717. */
  1718. const Ajax = (() => {
  1719. /**
  1720. * 检查options是否符合要求
  1721. * @param {object} options
  1722. * @returns {boolean}
  1723. */
  1724. function checkOptions(options) {
  1725. let result = false;
  1726. if (typeof options !== 'object') {
  1727. console.warn('类型错误: typeof Options !== Object');
  1728. return result;
  1729. } else {
  1730. if (typeof options.url !== 'string') {
  1731. console.warn('类型错误: typeof Link !== Strings');
  1732. return result;
  1733. } else {
  1734. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  1735. if (!reg.test(options.url)) {
  1736. console.warn('url字符串须为完整http链接');
  1737. return result;
  1738. }
  1739. result = true;
  1740. }
  1741. }
  1742. return result;
  1743. }
  1744.  
  1745. /**
  1746. * 对象转URL编码
  1747. * @param {object} data
  1748. */
  1749. function objToURLCode(data) {
  1750. var _result = [];
  1751. for (var key in data) {
  1752. var value = data[key];
  1753. if (value instanceof Array) {
  1754. value.forEach(function (_value) {
  1755. _result.push(key + "=" + _value);
  1756. });
  1757. } else {
  1758. _result.push(key + '=' + value);
  1759. }
  1760. }
  1761. return _result.join('&');
  1762. }
  1763.  
  1764. /**
  1765. * 请求
  1766. * @param {string} method
  1767. * @param {object} options
  1768. */
  1769. function request(method, options) {
  1770. if (checkOptions(options)) {
  1771. let xhr = new XMLHttpRequest();
  1772. const {url: _url, queryStringsObj, data, dataType, hasCookies} = options
  1773. , url = typeof queryStringsObj === 'object' ?
  1774. _url + '?' + objToURLCode(queryStringsObj) : _url;
  1775. switch (method) {
  1776. case 'GET':
  1777. xhr.open("GET", url);
  1778. break;
  1779. case 'POST':
  1780. xhr.open("POST", url);
  1781. xhr.setRequestHeader('Content-Type', dataType);
  1782. break;
  1783. default:
  1784. break;
  1785. }
  1786. if (hasCookies) xhr.withCredentials = true;
  1787. xhr.timeout = 3000;
  1788. xhr.addEventListener('load', () => {
  1789. if (xhr.status === 200) {
  1790. options.success(xhr.responseText)
  1791. } else {
  1792. console.error(`status:${xhr.status}`);
  1793. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  1794. }
  1795. })
  1796. xhr.addEventListener('error', () => {
  1797. console.error('ajax请求出错')
  1798. options.success('{"code":-1,"msg":"ajax请求出错"}');
  1799. })
  1800. xhr.addEventListener('timeout', () => {
  1801. console.error('请求超时')
  1802. options.success('{"code":-1,"msg":"请求超时"}');
  1803. })
  1804. switch (method) {
  1805. case 'GET':
  1806. xhr.send()
  1807. break;
  1808. case 'POST':
  1809. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  1810. break;
  1811. default:
  1812. break;
  1813. }
  1814. }
  1815. }
  1816.  
  1817. return {
  1818. /**
  1819. * 发送Get请求
  1820. * @param {Object} options
  1821. */
  1822. get(options) {
  1823. request("GET", options);
  1824. },
  1825. /**
  1826. * 发送Post请求
  1827. * @param {object} options
  1828. */
  1829. post(options) {
  1830. request("POST", options);
  1831. }
  1832. }
  1833. })()