-哔哩猫-(试用版)

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

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

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/422731/918206/-%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.12
  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.  
  391. /* let disUser_str = javaex.getSelectVal("#disUser_uidList");
  392. let disUser_uidList = disUser_str.split(",");
  393.  
  394. for (const vmid of disUser_uidList) {
  395.  
  396. HNAPI.disUserByUid(vmid);
  397.  
  398. await HNTOOL.Sleep(1500);
  399.  
  400. }
  401. */
  402. });
  403.  
  404. });
  405.  
  406. $("#arrUnique").bind("click", async function () {
  407.  
  408. let html = '';
  409. html += '<div class="javaex-panel-box" style="width: 500px;">';
  410. html += ' <div class="javaex-unit clear">';
  411. html += ' <div class="javaex-unit-left ml-10 mt-10">*数组</div>';
  412. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  413. html += ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  414. html += ' </div>';
  415. html += ' </div>';
  416. html += ' <div class="javaex-unit clear tc">';
  417. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="开始" />';
  418. html += ' </div>';
  419. html += '</div>';
  420.  
  421. javaex.panel(this, {
  422. position: "right",
  423. content: html
  424. });
  425.  
  426. $("#arrUnique_beg").bind("click", async function () {
  427.  
  428. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  429. let arrUnique_uidList = arrUnique_str.split(",");
  430.  
  431. let arrUniqueStr = HNTOOL.arrUnique(arrUnique_uidList).toString();
  432.  
  433. document.getElementById("arrUnique_str").value = arrUniqueStr;
  434.  
  435. });
  436.  
  437. });
  438.  
  439. $("#batchFollow").bind("click", async function () {
  440.  
  441. var thisUPName = $("#h-name").text();
  442.  
  443.  
  444. let html = '';
  445. html += '<div class="javaex-panel-box" style="width: 500px;">';
  446. html += ' <div class="javaex-unit clear">';
  447. html += ' <div class="javaex-unit-left ml-10 mt-10">*关注列表</div>';
  448. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  449. html += ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!"></textarea>';
  450. html += ' </div>';
  451. html += ' </div>';
  452. html += ' <div class="javaex-unit clear tc">';
  453. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  454. html += ` <input type="button" id="Follow_thisUp" class="javaex-btn yes" value="关注${thisUPName}" />`;
  455. html += ` <input type="button" id="disFollow_thisUp" class="javaex-btn yes" 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,10);
  482. for (const mids of mid_Lists) {
  483.  
  484. HNAPI.batchModify(mids.toString());
  485. await HNTOOL.Sleep(3000);
  486. }
  487.  
  488.  
  489. });
  490.  
  491. });
  492.  
  493.  
  494. $("#HNSetup").bind("click", async function () {
  495.  
  496. var CONFIG = HNTOOL.getConfig();
  497.  
  498.  
  499. let html = '';
  500.  
  501. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  502. html += '<form id="HNGG_SETUP">'
  503. html += ' <div class="javaex-unit clear">'
  504. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Q酱key</p></div>'
  505. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  506. html += ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  507. html += ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  508. html += ' </div>'
  509. html += ' <div class="javaex-unit-left mr-10">'
  510. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  511. html += ' </div>'
  512. html += ' </div>'
  513. html += '</form>';
  514. html += '<div class="javaex-unit clear tc">';
  515. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  516. html += '</div>';
  517. html += '<hr class="javaex-divider"></hr>';
  518. html += '</div>';
  519.  
  520. javaex.panel(this, {
  521. position: "right",
  522. content: html
  523. });
  524.  
  525.  
  526. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  527.  
  528. $("#switch-qsmg").bind("click", function () {
  529.  
  530. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  531.  
  532. })
  533.  
  534.  
  535. $("#HNSetup_save").bind("click", async function () {
  536.  
  537.  
  538. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  539.  
  540. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  541.  
  542. javaex.tip({
  543. content: "设置成功!",
  544. type: "success"
  545. });
  546.  
  547. });
  548.  
  549. });
  550.  
  551. //
  552. $("#getUpMassage").bind("click", async function () {
  553.  
  554.  
  555. let html = '';
  556.  
  557. html += '<div style="padding: 10px 10px 10px 0px;">'
  558. html += '<form id="getUpMassage_form">'
  559. html += ' <div class="javaex-unit clear">'
  560. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  561. html += ' <div class="javaex-unit-left mr-10">'
  562. html += ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  563. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  564. html += ' </div>'
  565. html += ' <div class="javaex-unit-right mr-10">'
  566. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  567. html += ' </div>'
  568. html += ' </div>'
  569. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  570. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  571. html += ' <thead>'
  572. html += ' <tr><th>内容</th><th>详情</th></tr>'
  573. html += ' </thead>'
  574. html += ' <tbody id="upMsgTbody">'
  575.  
  576. html += ' </tbody>'
  577. html += '</table> '
  578. html += '</div>'
  579. html += '</form>';
  580. html += '<hr class="javaex-divider"></hr>';
  581. html += '</div>';
  582.  
  583.  
  584. javaex.panel(this, {
  585. position: "right",
  586. content: html
  587. });
  588.  
  589. javaex.table({
  590. id: "upMsgTable",
  591. isDragColWidth: true, // 是否允许拖动改变列宽
  592. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  593. leftFixedColNum: 2, // 左侧固定列数
  594. rightFixedColNum: 1, // 右侧固定列数
  595. sort: {
  596. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  597. "2": "update_time"
  598. },
  599. sortCallback: function (rtn) {
  600. //console.log(rtn.sortArr);
  601. }
  602. });
  603.  
  604. //
  605. $("#getUpMsg").click(async function () {
  606.  
  607. let thismid = javaex.getSelectVal("#up_uid");
  608. await HNAPI.userInfo(thismid)
  609.  
  610. let temp = await HNAPI.getUpCard(thismid);
  611.  
  612.  
  613. await HNTOOL.Sleep(500);
  614.  
  615.  
  616. if (temp != false) {
  617. let data = BiliData.upCard.data;
  618.  
  619. let html = ``;
  620. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  621. html += `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  622. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  623. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  624. html += `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  625. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  626. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  627. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  628. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  629. html += `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  630. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  631. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  632.  
  633.  
  634. $("#upMsgTbody").empty();
  635. $("#upMsgTbody").append(html);
  636. }
  637.  
  638.  
  639. });
  640. //点击放大
  641. /* $("img").click(function() {
  642. javaex.dialog({
  643. type : "image", // 弹出层类型
  644. url : $(this).attr("src") // 图片地址
  645. });
  646. });*/
  647.  
  648. });
  649.  
  650.  
  651. $("#plateActivity").bind("click", async function () {
  652.  
  653. //获取轮盘数据
  654.  
  655. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/plateActivity.json";
  656. let myjson = await HNAPI.getMyJson(url);
  657.  
  658. for (const json of myjson) {
  659. let x = json.name;
  660.  
  661. }
  662.  
  663.  
  664. });
  665.  
  666. $("#addPlay").bind("click", async function () {
  667.  
  668.  
  669. let html = '';
  670.  
  671. html += '<div style="padding: 10px 10px 10px 0px;">'
  672. html += '<form id="getUpMassage_form">'
  673.  
  674. html += ' <div class="javaex-unit clear">'
  675. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  676. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  677. html += ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  678. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  679. html += ' </div>'
  680. html += ' </div>'
  681. html += ' <div class="javaex-unit clear">'
  682. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  683. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  684. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  685. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  686. html += ' </div>'
  687. html += ' </div>'
  688. html += '</form>';
  689. html += ' <div class="javaex-unit clear tc">'
  690. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  691. html += ' </div>'
  692. html += '<hr class="javaex-divider"></hr>';
  693. html += '</div>';
  694.  
  695.  
  696. javaex.panel(this, {
  697. position: "right",
  698. content: html
  699. });
  700.  
  701. $("#addPlay_bgn").click(async function () {
  702.  
  703. let MID = javaex.getSelectVal("#addPlay_uid")
  704. let BV = javaex.getSelectVal("#addPlay_bv");
  705. let bvArr = [];
  706. let bvArr2 = [];
  707.  
  708. MID = javaex.ifnull(MID, BiliData.author_uid);
  709.  
  710.  
  711. if (BV == "0") {
  712.  
  713. //1.查询up所有视频BV号 2.发送心跳间隔2s
  714. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  715. await HNTOOL.Sleep(500);
  716. bvArr2 = BiliData.BVList;
  717.  
  718. for (let i = 1; i > 0; i++) {
  719.  
  720. HNAPI.getUpAllBV(MID, i);
  721.  
  722. await HNTOOL.Sleep(500);
  723.  
  724. if (BiliData.BVList.length == 0) {
  725. if (bvArr.length == 0) {
  726. javaex.tip({
  727. content: "该用户无投稿视频,请确认是否有误!",
  728. type: "success"
  729. });
  730. await HNTOOL.Sleep(2000);
  731. }
  732. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  733. bvArr = bvArr.concat(bvArr2);
  734. break;
  735. }
  736.  
  737. bvArr = bvArr.concat(BiliData.BVList);
  738. }
  739.  
  740.  
  741. if (bvArr.length != 0) {
  742.  
  743. for (const emt of bvArr) {
  744.  
  745. HNAPI.playOneVideo(emt.bvid, MID);
  746.  
  747. await HNTOOL.Sleep(2000);
  748.  
  749. }
  750.  
  751. alert("播放完成!!!");
  752.  
  753. }
  754.  
  755.  
  756. } else {
  757. //1.调用点击播放接口
  758. //2.发送心跳
  759.  
  760. await HNTOOL.Sleep(500);
  761.  
  762. HNAPI.playOneVideo(BV);
  763. }
  764.  
  765.  
  766. });
  767.  
  768.  
  769. });
  770.  
  771. }
  772.  
  773. let showUnreadMsg = function () {
  774.  
  775. var html = '';
  776. html += '<div class="javaex-panel-box" style="width: 250px;">';
  777. html += ' <ul>';
  778. html += ` <p style="color: #FFF;">用户消息</p>`;
  779. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  780. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  781. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  782. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  783. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  784. html += ' <hr class="javaex-divider"></hr>';
  785. html += ' </ul>';
  786. html += '</div>';
  787.  
  788.  
  789. javaex.panel(document.getElementById("getUnread"), {
  790. position: "right",
  791. content: html
  792. });
  793.  
  794. javaex.tip({
  795. content: "查询用户通知成功!",
  796. type: "success"
  797. });
  798.  
  799. }
  800.  
  801. /**
  802. * 检查 艾特信息
  803. * @returns {Promise<void>}
  804. */
  805. let chackAtMsg = async function (items) {
  806.  
  807. await HNTOOL.Sleep(500);
  808.  
  809. if (items != false && typeof (items) != "undefined") {
  810.  
  811.  
  812. var html = '';
  813. html += '<div class="javaex-panel-box" style="width: auto;">';
  814. html += ' <ul>';
  815. html += ` <p style="color: #FFF;">@信息</p>`;
  816. items.forEach(function (item) {
  817.  
  818. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  819. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" + `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  820.  
  821. html += ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  822. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  823. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  824. html += ' <hr class="javaex-divider"></hr>';
  825. });
  826. html += ' </ul>';
  827. html += '</div>';
  828.  
  829.  
  830. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  831. javaex.panel(document.getElementById("getAtMsg"), {
  832. position: "right",
  833. content: html
  834. });
  835. } else {
  836. javaex.panel(document.getElementById("chackList"), {
  837. position: "right",
  838. content: html
  839. });
  840. }
  841.  
  842.  
  843. }
  844.  
  845. }
  846.  
  847.  
  848. let addSetPage = async function () {
  849.  
  850. HNTOOL.Sleep(1000);
  851.  
  852. $('body').append('' +
  853. '<div id="left_navbar">' +
  854. '<div class="javaex-menu-container"> ' +
  855. ' <div id="menu" class="javaex-menu"> ' +
  856. ' <ul> ' +
  857. ' <li class="javaex-menu-item alone hover" > ' +
  858. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  859. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  860. ' </li> ' +
  861. ' </ul> ' +
  862. ' <ul> ' +
  863. ' <li class="javaex-menu-item"> ' +
  864. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  865. ' <ul> ' +
  866. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  867. ' </ul> ' +
  868. ' </li> ' +
  869. ' <li id="chackList" class="javaex-menu-item"> ' +
  870. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  871. ' <ul> ' +
  872. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  873. ' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  874. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  875. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  876. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  877. ' </ul> ' +
  878. ' </li> ' +
  879. ' <li class="javaex-menu-item"> ' +
  880. ' <a href="javascript:;">工具<i class="icon-angle-down"></i></a> ' +
  881. ' <ul> ' +
  882. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  883. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  884. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  885. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  886. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  887. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑</a></li> ' +
  888. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  889. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  890. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  891. ' <li id="" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' +//likeInDynamicComments
  892. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  893. ' </ul> ' +
  894. ' </li> ' +
  895. ' <li class="javaex-menu-item"> ' +
  896. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  897. ' <ul> ' +
  898. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  899. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  900. ' </ul> ' +
  901. ' </li> ' +
  902.  
  903. ' </ul> ' +
  904. ' </div> ' +
  905. '</div>' +
  906. '</div>');
  907. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  908.  
  909. javaex.menu({
  910. id: "menu",
  911. isShowAll: false
  912. });
  913.  
  914. }
  915.  
  916.  
  917. let addStyle = function () {
  918. const animate = GM_getResourceText('animate');
  919. const common = GM_getResourceText('common');
  920. const defaultCss = GM_getResourceText('defaultCss');
  921. //const icomoonex = GM_getResourceText('icomoonex');
  922. //const AllCss = animate + common + defaultCss + icomoonex;
  923. const AllCss = animate + common + defaultCss;
  924. const style = document.createElement('style');
  925. style.innerHTML = AllCss;
  926. return document.getElementsByTagName('head')[0].appendChild(style);
  927. }
  928.  
  929. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  930.  
  931.  
  932. /*-----------------------------------------------常用API--------------------------------------------------*/
  933.  
  934. let HNAPI = {
  935.  
  936. getMyJson: function (url) {
  937. return new Promise((resolve) => {
  938. GM_xmlhttpRequest({
  939. method: "GET",
  940. url: url,
  941. onload: function (response) {
  942. const res = HNTOOL.strToJson((response || {}).responseText)
  943. resolve(res);
  944. }
  945. });
  946. })
  947. },
  948.  
  949.  
  950. userInfo: function (mid) {
  951.  
  952. Ajax.get({
  953. url: BILIBLI_PATH.api + '/x/space/acc/info',
  954. queryStringsObj: {
  955. mid: mid
  956. },
  957. hasCookies: true,
  958. success: responseText => {
  959.  
  960. var json = JSON.parse(responseText);
  961.  
  962. if (json.code != 0) {
  963.  
  964.  
  965. }
  966. }
  967. });
  968.  
  969. },
  970.  
  971. sendQmsg: function (key, msg) {
  972.  
  973. GM_xmlhttpRequest({
  974. method: "GET",
  975. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  976. onload: function (response) {
  977.  
  978. let json = JSON.parse(response.response);
  979. if (json.code == 0) {
  980.  
  981. javaex.tip({
  982. content: "自动动态中奖提醒成功!" + json.reason,
  983. type: "success"
  984. });
  985. } else {
  986. console.log("自动动态中奖提醒失败!" + json.reason);
  987. javaex.tip({
  988. content: "自动动态中奖提醒失败!" + json.reason,
  989. type: "error"
  990. });
  991. }
  992.  
  993. }
  994. });
  995.  
  996. },
  997.  
  998. /**
  999. * 批量关注和拉黑 batchModify
  1000. *
  1001. * https://api.bilibili.com/x/relation/batch/modify
  1002. * @param uid
  1003. */
  1004.  
  1005. batchModify: function (uids, act) {
  1006.  
  1007.  
  1008. Ajax.post({
  1009. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  1010. hasCookies: true,
  1011. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1012. data: {
  1013.  
  1014. "fids": uids,
  1015. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  1016. "re_src": 151,
  1017. csrf: Live_info.csrf_token,
  1018. },
  1019. success: responseText => {
  1020.  
  1021. let json = JSON.parse(responseText);
  1022.  
  1023. if (/^{"code":0/.test(responseText)) {
  1024.  
  1025. javaex.tip({
  1026. content: "执行成功!" + "---失败名单:" + json.data.failed_fids,
  1027. type: "success"
  1028. });
  1029.  
  1030. } else {
  1031. javaex.tip({
  1032. content: "关注失败!" + json.message,
  1033. type: "error"
  1034. });
  1035. }
  1036. }
  1037. })
  1038. },
  1039.  
  1040.  
  1041. /**
  1042. * //https://api.bilibili.com/x/relation/modify
  1043. *
  1044. * @param UID
  1045. */
  1046. disUserByUid: function (vmid) {
  1047.  
  1048. Ajax.post({
  1049. url: BILIBLI_PATH.api + '/x/relation/modify',
  1050. data: {
  1051. fid: parseInt(vmid),
  1052. re_src: 11,
  1053. act: 5,
  1054. jsonp: "jsonp",
  1055. csrf: Live_info.csrf_token,
  1056. },
  1057. hasCookies: true,
  1058. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1059. success: responseText => {
  1060.  
  1061. var json = JSON.parse(responseText);
  1062.  
  1063. if (json.code != 0) {
  1064.  
  1065. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  1066. javaex.tip({
  1067. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  1068. type: "error"
  1069. });
  1070.  
  1071. } else {
  1072. console.log("拉黑用户成功 uid:" + vmid);
  1073. javaex.tip({
  1074. content: "拉黑用户成功 uid:" + vmid,
  1075. type: "success"
  1076. });
  1077. }
  1078. }
  1079. });
  1080.  
  1081. },
  1082. /**
  1083. * http://api.bilibili.com/x/web-interface/view
  1084. * @param BV
  1085. * 心跳间隔15秒
  1086. */
  1087. playOneVideo: function (BV, MID) {
  1088.  
  1089. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  1090. Ajax.post({
  1091. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  1092. hasCookies: true,
  1093. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1094. data: {
  1095.  
  1096. "bvid": BV,
  1097. "part": 1,
  1098. "mid": Live_info.uid,
  1099. "lv": 2,
  1100. "jsonp": "jsonp",
  1101. "type": 3,
  1102. "sub_type": 0
  1103. },
  1104. success: responseText => {
  1105.  
  1106. let json = JSON.parse(responseText);
  1107.  
  1108. if (/^{"code":0/.test(responseText)) {
  1109. //发送一次心跳
  1110. HNAPI.sendHeartbeat(BV, MID);
  1111.  
  1112. } else {
  1113. javaex.tip({
  1114. content: "视频" + data.bvid + "播放失败!" + json.message,
  1115. type: "error"
  1116. });
  1117. }
  1118. }
  1119. })
  1120.  
  1121.  
  1122. },
  1123.  
  1124. //上报视频播放心跳(web端)
  1125. /**
  1126. * http://api.bilibili.com/x/click-interface/web/heartbeat
  1127. * @param json
  1128. */
  1129. sendHeartbeat: function (bvid, MID) {
  1130.  
  1131. Ajax.post({
  1132. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  1133. hasCookies: true,
  1134. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1135. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  1136. data: {
  1137. "bvid": bvid,
  1138. "type": 3,
  1139. "dt": 2,
  1140. "played_time": HNTOOL.random(12, 40),
  1141. "realtime": HNTOOL.random(12, 40),
  1142. "play_type": 0
  1143. },
  1144. success: responseText => {
  1145.  
  1146. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  1147.  
  1148. javaex.tip({
  1149. content: "视频BV" + bvid + "播放一次!",
  1150. type: "success"
  1151. });
  1152. }
  1153. }
  1154. })
  1155.  
  1156. },
  1157.  
  1158. //获取up所有投稿视频
  1159. /**
  1160. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  1161. * @param mid
  1162. */
  1163. getUpAllBV: function (mid, pn, ps) {
  1164. ps = (ps === undefined ? 30 : ps); // a默认值为1
  1165. Ajax.get({
  1166. url: BILIBLI_PATH.api + '/x/space/arc/search',
  1167. queryStringsObj: {
  1168. mid: mid,
  1169. tid: 0,
  1170. order: 'pubdate',
  1171. jsonp: 'jsonp',
  1172. pn: pn,
  1173. ps: ps
  1174. },
  1175. hasCookies: true,
  1176. success: responseText => {
  1177.  
  1178. var json = JSON.parse(responseText);
  1179.  
  1180. if (json.code != 0) {
  1181.  
  1182. javaex.tip({
  1183. content: "获取up所有投稿视频失败!" + json.message,
  1184. type: "success"
  1185. });
  1186.  
  1187. } else {
  1188. BiliData.BVList = json.data.list.vlist;
  1189.  
  1190. }
  1191. }
  1192. });
  1193.  
  1194. },
  1195.  
  1196.  
  1197. /**
  1198. *
  1199. * @param path
  1200. * @param data
  1201. * @param saveObj
  1202. * @param Func
  1203. */
  1204. publicGet: function (path, queryStringsObj) {
  1205.  
  1206. if (typeof (queryStringsObj) != "undefined") {
  1207. queryStringsObj = {};
  1208. }
  1209. Ajax.get({
  1210. url: BILIBLI_PATH.api + path,
  1211. queryStringsObj: queryStringsObj,
  1212. hasCookies: true,
  1213. success: responseText => {
  1214.  
  1215. let json = JSON.parse(responseText);
  1216. if (chackCode(json.code) && json.code == 0) {
  1217.  
  1218. return json.data;
  1219. }
  1220.  
  1221. return false;
  1222.  
  1223. }
  1224. })
  1225.  
  1226. },
  1227.  
  1228. /**
  1229. * 导航栏用户信息
  1230. */
  1231. getUserNav: async function () {
  1232.  
  1233. GM_xmlhttpRequest({
  1234. method: "GET",
  1235. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  1236. //timeout:3000,
  1237. onload: function (response) {
  1238.  
  1239. let json = JSON.parse(response.response);
  1240. console.log(json);
  1241. BiliData.login_code = json.code;
  1242. BiliData.login_message = json.message;
  1243. BiliData.LoginData = json.data;
  1244.  
  1245. }
  1246. });
  1247.  
  1248. },
  1249.  
  1250. /**
  1251. * 获取某up详细信息
  1252. * http://api.bilibili.com/x/web-interface/card
  1253. */
  1254. getUpCard: function (mid) {
  1255.  
  1256. Ajax.get({
  1257. url: BILIBLI_PATH.api + '/x/web-interface/card',
  1258. queryStringsObj: {
  1259. mid: mid,
  1260. photo: false
  1261. },
  1262. hasCookies: true,
  1263. success: responseText => {
  1264.  
  1265. var json = JSON.parse(responseText);
  1266.  
  1267. if (json.code != 0) {
  1268.  
  1269. javaex.tip({
  1270. content: "查询失败!" + json.message,
  1271. type: "success"
  1272. });
  1273. return false;
  1274. } else {
  1275. BiliData.upCard = json;
  1276.  
  1277. }
  1278.  
  1279.  
  1280. }
  1281. })
  1282.  
  1283. },
  1284.  
  1285. /**
  1286. *
  1287. * @param uid 用户uid
  1288. * @param ps 每页视频个数 默认30个
  1289. * @param pn 第几页
  1290. */
  1291. getUpAllVideo: function (uid, ps, pn) {
  1292.  
  1293. },
  1294. getChallenge: async function () {
  1295.  
  1296.  
  1297. },
  1298. /**
  1299. * 硬币记录
  1300. * @returns {Promise<void>}
  1301. */
  1302. getCoinLog: async function () {
  1303.  
  1304. GM_xmlhttpRequest({
  1305. method: "GET",
  1306. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  1307. //url: "http://api.bilibili.com/x/member/web/coin/log",
  1308. onload: function (response) {
  1309.  
  1310. let json = JSON.parse(response.response);
  1311. if (json.code == 0) {
  1312.  
  1313. console.log("硬币记录" + json);
  1314. BiliData.CoinLog = json.data;
  1315.  
  1316. return true;
  1317. }
  1318.  
  1319. }
  1320. });
  1321. },
  1322. /**
  1323. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  1324. * @returns {Promise<void>}
  1325. */
  1326. getUnread: async function () {
  1327.  
  1328. Ajax.get({
  1329. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1330. hasCookies: true,
  1331. success: responseText => {
  1332.  
  1333. let json = JSON.parse(responseText);
  1334. if (chackCode(json.code) && json.code == 0) {
  1335.  
  1336. BiliData.Unread = json.data;
  1337. showUnreadMsg();
  1338. }
  1339.  
  1340. return false;
  1341.  
  1342. }
  1343. })
  1344.  
  1345. /* GM_xmlhttpRequest({
  1346. method: "GET",
  1347. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1348. onload: function (response) {
  1349.  
  1350. let json = JSON.parse(response.response);
  1351.  
  1352. if (chackCode(json.code) && json.code == 0) {
  1353.  
  1354. BiliData.Unread = json.code;
  1355. showUnreadMsg();
  1356.  
  1357. }
  1358.  
  1359. }
  1360. });*/
  1361. },
  1362. /**
  1363. *
  1364. * @param type reply:回复我的 at @我的
  1365. */
  1366. getMsgfeed: function (type) {
  1367. Ajax.get({
  1368. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  1369. queryStringsObj: {
  1370. build: 0,
  1371. mobi_app: 'web'
  1372. },
  1373. hasCookies: true,
  1374. success: responseText => {
  1375.  
  1376. var json = JSON.parse(responseText);
  1377.  
  1378. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  1379. return false;
  1380. } else {
  1381. chackAtMsg(json.data.items);
  1382.  
  1383. return true;
  1384. }
  1385.  
  1386.  
  1387. }
  1388. })
  1389.  
  1390. },
  1391.  
  1392. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  1393. * @returns {Promise<void>}
  1394. */
  1395. getUnrewad: async function () {
  1396.  
  1397. GM_xmlhttpRequest({
  1398. method: "GET",
  1399. data: {
  1400. "mid": 99439379,
  1401. "pn": 1,
  1402. "ps": 5,
  1403. },
  1404. url: BILIBLI_PATH.api + "/x/space/arc/search",
  1405. onload: function (response) {
  1406.  
  1407. let json = JSON.parse(response.response);
  1408. if (json.code == 0) {
  1409.  
  1410. BiliData.Video = json.data;
  1411. console.log("未读消息数" + json);
  1412. }
  1413.  
  1414. }
  1415. });
  1416. },
  1417.  
  1418. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  1419. * @param {number} oid
  1420. * @param {nbumber} rpid
  1421. * @param {number} action
  1422. * @returns {Promise<void>}
  1423. * type: 11
  1424. * ordering: heat
  1425. * jsonp: jsonp
  1426. * csrf: 54a******* CSRF Token(位于cookie)
  1427. */
  1428.  
  1429. likeInDynamicComments: async function (oid, rpid, action) {
  1430.  
  1431.  
  1432. Ajax.post({
  1433. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  1434. hasCookies: true,
  1435. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1436. data: {
  1437. "oid": oid,
  1438. "type": 11,
  1439. "rpid": rpid,
  1440. "action": action,
  1441. "ordering": "heat",
  1442. "jsonp": "jsonp",
  1443. "csrf": Live_info.csrf_token,
  1444. },
  1445. success: responseText => {
  1446.  
  1447. if (/^{"code":0/.test(responseText)) {
  1448.  
  1449. BiliData.replyAction = JSON.parse(responseText);
  1450. console.log("点赞成功!" + responseText);
  1451. }
  1452. }
  1453. })
  1454.  
  1455. }
  1456.  
  1457.  
  1458. }
  1459.  
  1460. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  1461.  
  1462.  
  1463. let HNTOOL = {
  1464. /**
  1465. * s数组去重并排序
  1466. */
  1467.  
  1468. arrUnique:function (ary) {
  1469.  
  1470. let obj = {};
  1471. for ( let i = 0; i<ary.length; i++) {//this 指向方法.前的对象ary
  1472. let item = ary[i]
  1473. obj.hasOwnProperty(item)?(ary[i]=ary[ary.length-1],ary.pop(),i--):obj[item]=item
  1474. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  1475. // 如果没有 将这个元素添加到对象中
  1476. ary.sort((a,b)=>{return a-b})// 数组去重后 按升序排列
  1477. obj = null;
  1478. return ary;
  1479.  
  1480. },
  1481.  
  1482. split_array: function (arr, len) {
  1483.  
  1484. let arr_length = arr.length;
  1485. let newArr = [];
  1486. for (let i = 0; i < arr_length; i += len) {
  1487. newArr.push(arr.slice(i, i + len));
  1488. }
  1489. return newArr;
  1490. },
  1491. strToJson: function (params) {
  1492. const isJSON = (str => {
  1493. if (typeof str === 'string') {
  1494. try {
  1495. const obj = JSON.parse(str);
  1496. return typeof obj === 'object' ? obj : false
  1497. } catch (_) {
  1498. console.log(str);
  1499. return false;
  1500. }
  1501. } else {
  1502. console.log(`${str}\nIt is not a string!`);
  1503. return false;
  1504. }
  1505. })(params);
  1506. return isJSON ? isJSON : {}
  1507. },
  1508.  
  1509. chackAtMsg: function () {
  1510.  
  1511. let config = HNTOOL.getConfig();
  1512. if (config.qmsg_checked == true && config.qmsg_key) {
  1513.  
  1514. document.getElementById("getAtMsg").click();
  1515.  
  1516. }
  1517.  
  1518. },
  1519.  
  1520. cssChecked: function (id, dom) {
  1521.  
  1522. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  1523.  
  1524.  
  1525. },
  1526. getConfig: function () {
  1527.  
  1528. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  1529.  
  1530. if (CONFIG == null) {
  1531. CONFIG = HN_SETUP_CONFIG;
  1532. }
  1533.  
  1534. return CONFIG;
  1535. },
  1536.  
  1537. /**
  1538. * 获取cookie 中某个键对应的值
  1539. * @param name
  1540. */
  1541.  
  1542. getCookie: function (name) {
  1543. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  1544. if (arr != null) return unescape(arr[2]);
  1545. return false;
  1546. },
  1547. /**
  1548. * 得到一个字符串数组的中随机一个
  1549. * @param {List} list
  1550. */
  1551. getRandomWordOfList: function (list) {
  1552. var L = list.length;
  1553. var i = Math.ceil(Math.random() * L);
  1554.  
  1555. return list[i];
  1556. },
  1557. random: function (min, max) {
  1558.  
  1559. return Math.floor(Math.random() * (max - min)) + min;
  1560. },
  1561.  
  1562. Sleep: function (ms) {
  1563. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  1564. }
  1565.  
  1566. }
  1567.  
  1568. let errorMsg = {
  1569. "-1": "应用程序不存在或已被封禁!",
  1570. "-2": "Access Key错误!",
  1571. "-3": "API校验密匙错误!",
  1572. "-4": "调用方对该Method没有权限!",
  1573. "-101": "账号未登录!",
  1574. "-102": "账号被封停!",
  1575. "-103": "积分不足!",
  1576. "-104": "硬币不足!",
  1577. "-105": "验证码错误!",
  1578. "-106": "账号非正式会员或在适应期!",
  1579. "-107": "应用不存在或者被封禁!",
  1580. "-108": "未绑定手机!",
  1581. "-109": "未知!",
  1582. "-110": "未绑定手机!",
  1583. "-111": "csrf 校验失败!",
  1584. "-112": "系统升级中!",
  1585. "-113": "账号尚未实名认证!",
  1586. "-114": "请先绑定手机!",
  1587. "-115": "请先完成实名认证!",
  1588. "-304": "木有改动!",
  1589. "-307": "撞车跳转!",
  1590. "-400": "请求错误!",
  1591. "-401": "未认证!",
  1592. "-403": "访问权限不足!",
  1593. "-404": "啥都木有!",
  1594. }
  1595.  
  1596. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  1597. /**
  1598. *
  1599. * @param code
  1600. * @constructor
  1601. */
  1602. let chackCode = function (code) {
  1603.  
  1604. let emsg = errorMsg[code + ""];
  1605. if (emsg != null) {
  1606. javaex.tip({content: emsg, type: "error"});
  1607.  
  1608. return false;
  1609. }
  1610.  
  1611. return true;
  1612. }
  1613.  
  1614.  
  1615. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  1616. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  1617.  
  1618. /*window.onbeforeunload = function() {
  1619. if (!canLeavePage()) {
  1620. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  1621. }
  1622. };*/
  1623.  
  1624.  
  1625. /**
  1626. * Ajax请求对象
  1627. */
  1628. const Ajax = (() => {
  1629. /**
  1630. * 检查options是否符合要求
  1631. * @param {object} options
  1632. * @returns {boolean}
  1633. */
  1634. function checkOptions(options) {
  1635. let result = false;
  1636. if (typeof options !== 'object') {
  1637. console.warn('类型错误: typeof Options !== Object');
  1638. return result;
  1639. } else {
  1640. if (typeof options.url !== 'string') {
  1641. console.warn('类型错误: typeof Link !== Strings');
  1642. return result;
  1643. } else {
  1644. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  1645. if (!reg.test(options.url)) {
  1646. console.warn('url字符串须为完整http链接');
  1647. return result;
  1648. }
  1649. result = true;
  1650. }
  1651. }
  1652. return result;
  1653. }
  1654.  
  1655. /**
  1656. * 对象转URL编码
  1657. * @param {object} data
  1658. */
  1659. function objToURLCode(data) {
  1660. var _result = [];
  1661. for (var key in data) {
  1662. var value = data[key];
  1663. if (value instanceof Array) {
  1664. value.forEach(function (_value) {
  1665. _result.push(key + "=" + _value);
  1666. });
  1667. } else {
  1668. _result.push(key + '=' + value);
  1669. }
  1670. }
  1671. return _result.join('&');
  1672. }
  1673.  
  1674. /**
  1675. * 请求
  1676. * @param {string} method
  1677. * @param {object} options
  1678. */
  1679. function request(method, options) {
  1680. if (checkOptions(options)) {
  1681. let xhr = new XMLHttpRequest();
  1682. const {url: _url, queryStringsObj, data, dataType, hasCookies} = options
  1683. , url = typeof queryStringsObj === 'object' ?
  1684. _url + '?' + objToURLCode(queryStringsObj) : _url;
  1685. switch (method) {
  1686. case 'GET':
  1687. xhr.open("GET", url);
  1688. break;
  1689. case 'POST':
  1690. xhr.open("POST", url);
  1691. xhr.setRequestHeader('Content-Type', dataType);
  1692. break;
  1693. default:
  1694. break;
  1695. }
  1696. if (hasCookies) xhr.withCredentials = true;
  1697. xhr.timeout = 3000;
  1698. xhr.addEventListener('load', () => {
  1699. if (xhr.status === 200) {
  1700. options.success(xhr.responseText)
  1701. } else {
  1702. console.error(`status:${xhr.status}`);
  1703. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  1704. }
  1705. })
  1706. xhr.addEventListener('error', () => {
  1707. console.error('ajax请求出错')
  1708. options.success('{"code":-1,"msg":"ajax请求出错"}');
  1709. })
  1710. xhr.addEventListener('timeout', () => {
  1711. console.error('请求超时')
  1712. options.success('{"code":-1,"msg":"请求超时"}');
  1713. })
  1714. switch (method) {
  1715. case 'GET':
  1716. xhr.send()
  1717. break;
  1718. case 'POST':
  1719. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  1720. break;
  1721. default:
  1722. break;
  1723. }
  1724. }
  1725. }
  1726.  
  1727. return {
  1728. /**
  1729. * 发送Get请求
  1730. * @param {Object} options
  1731. */
  1732. get(options) {
  1733. request("GET", options);
  1734. },
  1735. /**
  1736. * 发送Post请求
  1737. * @param {object} options
  1738. */
  1739. post(options) {
  1740. request("POST", options);
  1741. }
  1742. }
  1743. })()