- // ==UserScript==
- // @name -哔哩猫-(试用版)
- // @description 注:练手作品,多多包涵,不接受恶意差评,有问题群内咨询(Q群1031014013):批量播放视频;批量拉黑;批量关注;动态艾特消息提醒(友情天选群746790091 )
- // @namespace http://tampermonkey.net/
- // @version 1.8.8
- // @iconURL https://gitee.com/java_cn/BILIBLI_RES/raw/master/PIC/PC_1606377718.gif
- // @author 荒年(QQ:2019676120)
- // @match *://space.bilibili.com/*
- // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
- // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex.min.js
- // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex-formVerify.js
- // @resource animate http://cdn.javaex.cn/javaex/pc/css/animate.css
- // @resource common http://cdn.javaex.cn/javaex/pc/css/common.css
- // @resource defaultCss http://cdn.javaex.cn/javaex/pc/css/skin/default.css
- // @grant unsafeWindow
- // @grant GM_getValue
- // @grant GM_setValue
- // @grant GM_xmlhttpRequest
- // @grant GM_getResourceText
- // @grant GM_openInTab
- // @grant GM_addStyle
- // @run-at document-idle
- // @license MIT License
- // @connect github.com
- // @connect gitee.com
- // @connect api.bilibili.com
- // @connect qmsg.zendee.cn
- // @connect passport.bilibili.com
- // @connect api.live.bilibili.com
- // @namespace http://tampermonkey.net/
- // ==/UserScript==
-
-
-
-
- GM_addStyle(
- `
-
- #switch-qsmg:before {
- content: "开关";
- letter-spacing: 16px;
- top: 4px;
- left: 10px;
- }
- #left_navbar{
- z-index: 1000;
- position: absolute;
- top: 100px;
- left: 5px;
- }
- button[hnBtn="btn_open"] {
- z-index: 1001;
- z-index: 1000px;
- position: absolute;
- top: 58px;
- left: 220px;
- }
- .javaex-panel.javaex-panel-right.javaex-animated-zoom-in {
- top: 60px;
- }
- .javaex-menu-container {
- border: 1px solid #eee;
- }
- .javaex-panel-box p {
- text-align: center;
- background: #fb7299;
- }
- .fontbold{
- color: #00a1d6;
- font-weight: bold;
- cursor: pointer;
- }
- `
- );
-
-
- let HN_SETUP_CONFIG = {
-
- qmsg_key: null, //后期改为kull 存储到本地
- qmsg_checked: false,
-
-
- }
-
- let Live_info = {
- room_id: undefined,
- uid: undefined,
- blocked: undefined,
- csrf_token: undefined,
- SESSDATA: undefined,
- visit_id: undefined,
- rnd: undefined,
- ruid: undefined,
- uname: undefined,
- user_level: undefined,
- ruid: undefined,
- };
-
- let BILIBLI_PATH = {
-
- "live": "https://api.live.bilibili.com",
- "passport": "https://passport.bilibili.com",
- "api": "https://api.bilibili.com",
- "video": "https://www.bilibili.com/video/",
- "single_unread": "http://api.vc.bilibili.com/"
- }
-
- let BILIBILI_URL = {
- // 导航栏用户信息
- "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
- }
-
- let BiliData = {
-
- this_uid: window.location.href.split("/")[3], //当前页面uid
- author_uid: 99439379,
- login_code: null,
- login_message: "",
- LoginData: {},
- CoinLog: {},
- Unread: null,
- Video: {},
- replyAction: {},
- upCard: {},
- BVList: [],
- }
-
- window.onload = function() {
-
-
- //界面显示
- init();
-
-
- }
-
-
- function init() {
-
- Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
- Live_info.uid = HNTOOL.getCookie("DedeUserID");
- Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
-
- addStyle();
- addSetPage();
-
- HNTOOL.chackAtMsg();
-
- $("#getCoinLog").bind("click", async function() {
-
-
- if (HNAPI.getCoinLog()) {
-
- await HNTOOL.Sleep(500);
- let html = '';
- html += '<div class="javaex-panel-box" style="width: 250px;">';
- html += ' <ul>';
- html += ` <p style="color: #FFF;">硬币使用记录</p>`;
-
- BiliData.CoinLog.list.forEach(function(item) {
-
- let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
- if (BV.indexOf("BV") != -1) {
- html += `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
- }
- html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
-
-
- });
- html += ' <hr class="javaex-divider"></hr>';
- html += ' </ul>';
- html += '</div>';
-
- javaex.panel(this, {
- position: "right",
- //offsetTop: "104",
- content: html
- });
- javaex.tip({
- content: "获取用户成功!",
- type: "success"
- });
-
- } else {
- javaex.tip({
- content: "获取硬币记录失败,请稍后重试!",
- type: "error"
- });
- }
-
-
- });
-
- $("#getUnread").bind("click", async function() {
-
- javaex.tip({
- content: "获取中,请稍候...",
- type: "submit"
- });
- HNAPI.getUnread();
-
-
- });
-
-
- $("#likeInDynamicComments").bind("click", async function() {
-
- let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get("likeInDynamic_PRID");
- let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get("likeInDynamic_OID");
-
- let html = '';
-
- html += '<div style="padding: 10px 10px 10px 0px;">'
- html += '<form id="likeInDynamic_form">'
- html += ' <div class="javaex-unit clear">'
- html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
- html += ' <div class="javaex-unit-right">'
- html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
- html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
- html += ' </div>'
- html += ' </div>'
- html += ' <div class="javaex-unit clear">'
- html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
- html += ' <div class="javaex-unit-right">'
- html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
- html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
- html += ' </div>'
- html += ' </div>'
- html += ' <div class="javaex-unit clear tc">'
- html +=
- ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
- html +=
- ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
- html += ' </div>'
- html += '</form>';
- html += '<hr class="javaex-divider"></hr>';
- html += '</div>';
-
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
-
- // 监听点击保存按钮事件
- $("#likeInDynamic_yes").click(async function() {
- // 表单验证函数
- if (javaexVerify()) {
-
- HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex.getSelectVal(
- "#likeInDynamic_PRID"), 1);
- await HNTOOL.Sleep(1000);
-
- if (BiliData.replyAction.code == 0) {
-
- LocalData.set("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
- LocalData.set("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
-
- javaex.tip({
- content: "评论区点赞成功!",
- type: "success"
- });
- } else {
- javaex.tip({
- content: "评论区点赞失败!",
- type: "error"
- });
- }
- if (BiliData.replyAction.code == 65006) {
- javaex.tip({
- content: "请勿重复点赞!",
- type: "error"
- });
- }
- }
- });
-
- // 监听点击返回按钮事件
- $("#likeInDynamic_no").click(async function() {
-
- if (javaexVerify()) {
-
- HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +javaex.getLocalStorage(
- "#likeInDynamic_PRID"), 0);
- await HNTOOL.Sleep(500);
-
- if (BiliData.replyAction.code == 0) {
-
- javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
- javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
-
- javaex.tip({
- content: "评论区取消点赞成功!",
- type: "success"
- });
- } else {
- javaex.tip({
- content: "评论区取消点赞失败!",
- type: "error"
- });
- }
- if (BiliData.replyAction.code == 65006) {
- javaex.tip({
- content: "请勿重复取消点赞!",
- type: "error"
- });
- }
- }
- });
-
- });
-
- $("#biliUserMsg").bind("click", async function() {
-
-
- //刷新信息
- HNAPI.getUserNav();
- await HNTOOL.Sleep(500);
-
- let isLogin = "未登录";
- let vipType = "无";
- //判断是否成功
- if (BiliData.login_code == 0) {
-
-
- if (BiliData.LoginData.isLogin) {
- isLogin = "已登录";
- }
-
- if (BiliData.LoginData.vipType == 1) {
- vipType = "月度大会员";
- } else if (BiliData.LoginData.vipType == 2) {
- vipType = "年度大会员";
- }
-
- let html = '';
- html += '<div class="javaex-panel-box" style="width: 250px;">';
- html += ' <ul>';
- html += ` <p style="color: #FFF;">用户信息</p>`;
- html += ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
- html += ` <li>用户状态:${isLogin} </li> `;
- html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
- html +=
- ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
- html += ` <li>UID:${BiliData.LoginData.mid} </li> `;
- html += ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
- html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
- html += ` <li>会员:${vipType} </li> `;
- html += ' <hr class="javaex-divider"></hr>';
- html += ' </ul>';
- html += '</div>';
-
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
- javaex.tip({
- content: "获取用户成功!",
- type: "success"
- });
-
- } else {
- javaex.tip({
- content: "获取用户信息失败!",
- type: "error"
- });
- }
-
-
- });
-
- $("#getAtMsg").bind("click", async function() {
-
- if (HNAPI.getMsgfeed("at") && typeof(HNAPI.getMsgfeed("at")) != "undefined") {
-
- javaex.tip({
- content: "可能中奖了!!!",
- type: "success"
- });
- }
- });
-
-
- $("#disUser").bind("click", async function() {
-
- let html = '';
- html += '<div class="javaex-panel-box" style="width: 500px;">';
- html += ' <div class="javaex-unit clear">';
- html += ' <div class="javaex-unit-left ml-10 mt-10">*UID列表</div>';
- html += ' <div class="javaex-unit-right mr-10 mt-10">';
- html +=
- ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
- html += ' </div>';
- html += ' </div>';
- html += ' <div class="javaex-unit clear tc">';
- html += ' <input type="button" id="disUser_block" class="javaex-btn yes" value="拉黑" />';
- html += ' <input type="button" id="disUser_cancelAtt_uid" class="javaex-btn yes" value="UID取关" />';
- html += ' <input type="button" id="disUser_cancelAtt_room" class="javaex-btn yes" value="房间号取关" />';
- html += ' </div>';
- html += '</div>';
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
- let disUser_str;
- //拉黑
- $("#disUser_block").bind("click", async function() {
-
- disUser_str = javaex.getSelectVal("#disUser_uidList");
- let disUser_uidList = disUser_str.split(",");
- let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
-
- for (const vmid of disUserStr) {
-
- HNAPI.batchModify(vmid.toString(), 5);
- await HNTOOL.Sleep(2000);
- }
- });
- //取关uid
- $("#disUser_cancelAtt_uid").bind("click", async function() {
- disUser_str = javaex.getSelectVal("#disUser_uidList");
- let disUser_uidList = disUser_str.split(",");
-
- javaex.tip({
- content: "根据uid批量取关开始!!!",
- type: "success"
- });
-
- /*
- let disuidList = [];
- let PN = 100;
- PN = disUser_uidList.length == 1 ? 0 : PN;
-
- for (var i = 0; i < PN; i++) {
-
- let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
- javaex.tip({
- content: "获取第" + i + "页黑名单成功!",
- type: "success"
- });
- await HNTOOL.Sleep(1000);
-
- if (uidList.length == 0) {
- break;
- }
- if (uidList == null) {
- continue;
- }
-
- for (let disuid of uidList) {
- if (disuidList.indexOf(disuid.mid) == -1) {
- disuidList.push(disuid.mid + "");
- }
- }
-
-
- } */
- let J = 1;
-
- for (let uid of disUser_uidList) {
-
- /* let uidType = "未在黑名单";
- if (disuidList.indexOf(uid) == -1) {
-
- await HNAPI.cancelAtt(uid, 2);
- } else {
-
- await HNAPI.cancelAtt(uid, 6, 116);
- uidType = "黑名单用户";
- } */
- await HNAPI.cancelAtt(uid, 2);
-
- javaex.tip({
- content: "【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" + disUser_uidList.length + ")",
- type: "success"
- });
- await HNTOOL.Sleep(1000);
- }
-
-
- alert("根据uid批量取关完成!");
-
- /* javaex.alert({
- content: "根据uid批量取关完成!",
- confirm: function() {
-
- //return false;
- }
- }); */
-
- });
- //取关room
- $("#disUser_cancelAtt_room").bind("click", async function() {
-
- javaex.tip({
- content: "根据房间号批量取关开始!!!",
- type: "success"
- });
-
- disUser_str = javaex.getSelectVal("#disUser_uidList");
- let disUser_roomList = disUser_str.split(",");
- /* let disuidList = [];
- let PN = 100;
- PN = disUser_roomList.length == 1 ? 0 : PN;
-
- for (var i = 0; i < PN; i++) {
-
- let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
- javaex.tip({
- content: "获取第" + i + "页黑名单成功!",
- type: "success"
- });
- await HNTOOL.Sleep(1000);
-
- if (uidList.length == 0) {
- break;
- }
- if (uidList == null) {
- continue;
- }
-
- for (let disuid of uidList) {
-
- if (disuidList.indexOf(disuid.mid) == -1) {
- disuidList.push(disuid.mid);
- }
-
- }
-
-
- } */
- let J = 1;
- for (let room of disUser_roomList) {
-
- let uid = await HNAPI.getRoomMsg(room);
-
- await HNTOOL.Sleep(1000);
-
- if (uid == false) {
- javaex.tip({
- content: "uid查询失败跳过!",
- type: "error"
- });
- continue;
- }
- /* let uidType = "未在黑名单";
- if (disuidList.indexOf(uid) == -1) {
-
- await HNAPI.cancelAtt(uid, 2);
- } else {
-
- await HNAPI.cancelAtt(uid, 6, 116);
- uidType = "黑名单用户";
- } */
- await HNAPI.cancelAtt(uid, 2);
-
- javaex.tip({
- content: "Room:" + room + "-【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" + disUser_roomList.length +
- ")",
- type: "success"
- });
- await HNTOOL.Sleep(1000);
-
-
- }
- alert("根据房间号批量取关完成!");
- /* javaex.alert({
- content: ,
- confirm: function() {
-
- return false;
- }
- }); */
-
- });
-
- });
-
- $("#getNeetCookie").bind("click", async function() {
-
- let html = '';
- html += '<div class="javaex-panel-box" style="width: 750px;">';
- html += ' <div class="javaex-unit clear">';
- html += ' <div class="javaex-unit-left ml-10 mt-10">*cookie</div>';
- html += ' <div class="javaex-unit-right mr-10 mt-10">';
- html +=
- ' <textarea id="neetCookie" class="javaex-desc" placeholder="获取需要的cookie,注意需要取消掉application->cookie>SESSDATA httpOnly 的对钩"></textarea>';
- html += ' </div>';
- html += ' </div>';
- html += ' <div class="javaex-unit clear tc">';
- html += ' <input type="button" id="getCookie_type1" class="javaex-btn yes" value="方式一" />';
- html += ' <input type="button" id="getCookie_type2" class="javaex-btn yes" value="方式二" />';
- html += ' <input type="button" id="getCookie_type3" class="javaex-btn yes" value="方式三" />';
- html += ' <input type="button" id="getCookie_copy" class="javaex-btn yes" value="复制" />';
- html += ' </div>';
- html += '</div>';
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
- $('#getCookie_copy').bind('click', function() {
-
- HNTOOL.copyText("neetCookie");
-
- });
-
- Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
- Live_info.uid = HNTOOL.getCookie("DedeUserID");
- Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
-
-
- $("#getCookie_type1").bind("click", async function() {
-
- var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA.replace(/%25/g, "%") +
- "; bili_jct=" + Live_info.csrf_token +
- "; "
- document.getElementById("neetCookie").value = cookie01;
-
- });
- $("#getCookie_type3").bind("click", async function() {
-
- var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA.replace(/%25/g, "%%") +
- "; bili_jct=" + Live_info.csrf_token +
- "; "
- document.getElementById("neetCookie").value = cookie01;
-
- });
-
- $("#getCookie_type2").bind("click", async function() {
-
- var cookie02 = Live_info.uid + "\n" + Live_info.SESSDATA.replace(/%25/g, "%") + "\n" + Live_info.csrf_token;
- document.getElementById("neetCookie").value = cookie02;
- });
-
- });
-
- $("#arrUnique").bind("click", async function() {
-
- let html = '';
- html += '<div class="javaex-panel-box" style="width: 500px;">';
- html += ' <div class="javaex-unit clear">';
- html += ' <div id="arrNub" class="javaex-unit-left ml-10 mt-10">*数组0</div>';
- html += ' <div class="javaex-unit-right mr-10 mt-10">';
- html += ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
- html += ' </div>';
- html += ' </div>';
- html += ' <div class="javaex-unit clear tc">';
- html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="去重" />';
- //html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="粘贴" />';
- html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="复制" />';
- html += ' </div>';
- html += '</div>';
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
- $('#arrUnique_str').bind('input propertychange', function() {
-
- $('#arrNub').text("*数组" + $(this).val().split(",").length);
-
- });
- $('#arrUnique_copy').bind('click', function() {
-
- HNTOOL.copyText("arrUnique_str");
-
- });
-
-
-
-
- $("#arrUnique_beg").bind("click", async function() {
-
- let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
- let arrUnique_uidList = arrUnique_str.split(",");
-
- let new_arr = HNTOOL.arrUnique(arrUnique_uidList);
-
- document.getElementById("arrUnique_str").value = new_arr.toString();
-
- $('#arrNub').text("*数组" + new_arr.length);
-
- });
-
- });
-
- $("#batchFollow").bind("click", async function() {
-
- var thisUPName = $("#h-name").text();
-
-
- let html = '';
- html += '<div class="javaex-panel-box" style="width: 600px;">';
- html += ' <div class="javaex-unit clear">';
- html += ' <div id="followNub" class="javaex-unit-left ml-10 mt-10">*关注列表0</div>';
- html += ' <div class="javaex-unit-right mr-10 mt-10">';
- html +=
- ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
- html += ' </div>';
- html += ' </div>';
- html += ' <div class="javaex-unit clear tc" >';
- html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
- html += ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="爬取关注" />';
- html += ` <input type="button" id="Follow_thisUp" class="javaex-btn yes tc" value="关注${thisUPName}" />`;
- html += ` <input type="button" id="disFollow_thisUp" class="javaex-btn yes tc" value="拉黑${thisUPName}" /> `;
- html += ' </div>';
- html += '</div>';
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
- $('#batchFollow_uidList').bind('input propertychange', function() {
-
- $('#followNub').text("*关注列表" + $(this).val().split(",").length);
-
- });
-
- $("#disFollow_thisUp").bind("click", async function() {
-
- HNAPI.batchModify(BiliData.this_uid, 5);
-
- });
-
- $("#Follow_thisUp").bind("click", async function() {
-
- HNAPI.batchModify(BiliData.this_uid);
-
- });
-
- $("#batchFollow_beg").bind("click", async function() {
-
- let mid_str = javaex.getSelectVal("#batchFollow_uidList");
- mid_list = mid_str.split(",");
-
- let mid_Lists = HNTOOL.split_array(mid_list, 15);
- for (const mids of mid_Lists) {
-
- HNAPI.batchModify(mids.toString());
- await HNTOOL.Sleep(8000);
- }
-
- alert("关注完成!")
-
- });
-
- $("#crawler_follow").bind("click", async function() {
-
- //x/space/myinfo
- let myinfoData = await HNAPI.getMyinfo();
- await HNAPI.getUpCard(myinfoData.mid);
- await HNTOOL.Sleep(1000);
- let len = parseInt(BiliData.upCard.data.card.attention / 20);
- let followData = [];
-
- for (let i = 0; i < len; i++) {
- if (BiliData.upCard.code != 0) {
- javaex.tip({
- content: `爬取关注出现异常 终止爬取!{BiliData.upCard.message}`,
- type: "error"
- });
- break;
- }
-
- javaex.tip({
- content: `正在爬取` + myinfoData.mid + `的` + i + `页的关注!!!`,
- type: "success"
- });
-
- let followList = await HNAPI.getMyFollow(myinfoData.mid, i);
- if (followList != null) {
- for (const fl of followList.list) {
-
- if (fl.official_verify.type != 1 || fl.vip.vipType == 0) {
- continue;
- }
-
- followData.push(fl.mid);
-
- }
- }
-
-
- await HNTOOL.Sleep(3000);
- }
-
- document.getElementById("batchFollow_uidList").value = followData.toString();
-
- });
-
-
- });
-
- $("#batchTargetMedal").bind("click", async function() {
-
-
- let html = '';
- html += '<div class="javaex-panel-box" style="width: 600px;">';
- html += ' <div class="javaex-unit clear">';
- html += ' <div id="targetNub" class="javaex-unit-left ml-10 mt-10">*房间列表0</div>';
- html += ' <div class="javaex-unit-right mr-10 mt-10">';
- html +=
- ' <textarea id="batchTargetMedal_roomlist" class="javaex-desc" placeholder="特别注意:请填写用户真实房间号,多个用英文逗号,隔开!!"></textarea>';
- html += ' </div>';
- html += ' </div>';
- html += ' <div class="javaex-unit clear tc" >';
- html += ' <input type="button" id="batchTargetMedal_beg" class="javaex-btn yes" value="开始" />';
- html += ' </div>';
- html += '</div>';
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
- $('#batchTargetMedal_roomlist').bind('input propertychange', function() {
-
- $('#targetNub').text("*房间列表" + $(this).val().split(",").length);
-
- });
-
- $("#batchTargetMedal_beg").bind("click", async function() {
-
- let room_str = javaex.getSelectVal("#batchTargetMedal_roomlist");
- let room_list = room_str.split(",");
-
-
- for (const room of room_list) {
-
- let uid = await HNAPI.getRoomMsg(room);
- await HNTOOL.Sleep(500);
-
- if (uid == false) {
-
- javaex.tip({
- content: room + "获取勋章失败!",
- type: "error"
- });
-
- continue;
- }
-
- let result = await HNAPI.getFansMedalInfo(uid, room);
-
- if (result) {
- javaex.tip({
- content: room + "勋章已经存在!",
- type: "success"
- });
- continue;
- }
- //获取包裹列表
- let giftRes = await HNAPI.getGiftList(room);
-
- if (giftRes == false) {
-
- continue;
- }
-
- let bag_id = null;
-
- for (let gr of giftRes) {
-
- if (gr.gift_id == 3) {
-
- bag_id = gr.bag_id;
- break;
- }
-
- }
- if (bag_id != null) {
-
- await HNAPI.bagSendGift(uid, room, bag_id);
- }
-
-
-
- await HNTOOL.Sleep(5000);
- }
-
- alert("批量送b克拉完毕!")
-
-
- });
-
-
- });
-
-
- $("#HNSetup").bind("click", async function() {
-
- var CONFIG = HNTOOL.getConfig();
-
-
- let html = '';
-
- html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
- html += '<form id="HNGG_SETUP">'
- html += ' <div class="javaex-unit clear">'
- html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Qmsg-key</p></div>'
- html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
- html += ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
- html += ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
- html += ' </div>'
- html += ' <div class="javaex-unit-left mr-10">'
- html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
- html += ' </div>'
- html += ' </div>'
- html += '</form>';
- html += '<div class="javaex-unit clear tc">';
- html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
- html += '</div>';
- html += '<hr class="javaex-divider"></hr>';
- html += '</div>';
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
-
- HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
-
- $("#switch-qsmg").bind("click", function() {
-
- HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
-
- })
-
-
- $("#HNSetup_save").bind("click", async function() {
-
-
- HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
-
- localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
-
- javaex.tip({
- content: "设置成功!",
- type: "success"
- });
-
- });
-
- });
-
- //
- $("#getUpMassage").bind("click", async function() {
-
-
- let html = '';
-
- html += '<div style="padding: 10px 10px 10px 0px;">'
- html += '<form id="getUpMassage_form">'
- html += ' <div class="javaex-unit clear">'
- html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
- html += ' <div class="javaex-unit-left mr-10">'
- html +=
- ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
- html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
- html += ' </div>'
- html += ' <div class="javaex-unit-right mr-10">'
- html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
- html += ' </div>'
- html += ' </div>'
- html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
- html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
- html += ' <thead>'
- html += ' <tr><th>内容</th><th>详情</th></tr>'
- html += ' </thead>'
- html += ' <tbody id="upMsgTbody">'
-
- html += ' </tbody>'
- html += '</table> '
- html += '</div>'
- html += '</form>';
- html += '<hr class="javaex-divider"></hr>';
- html += '</div>';
-
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
- javaex.table({
- id: "upMsgTable",
- isDragColWidth: true, // 是否允许拖动改变列宽
- mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
- leftFixedColNum: 2, // 左侧固定列数
- rightFixedColNum: 1, // 右侧固定列数
- sort: {
- "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
- "2": "update_time"
- },
- sortCallback: function(rtn) {
- //console.log(rtn.sortArr);
- }
- });
-
- //
- $("#getUpMsg").click(async function() {
-
- let thismid = javaex.getSelectVal("#up_uid");
- await HNAPI.userInfo(thismid)
-
- let temp = await HNAPI.getUpCard(thismid);
-
-
- await HNTOOL.Sleep(500);
-
-
- if (temp != false) {
- let data = BiliData.upCard.data;
-
- let html = ``;
- html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
- html += `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
- html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
- html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
- html +=
- `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
- html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
- html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
- html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
- html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
- html +=
- `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
- html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
- html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
-
-
- $("#upMsgTbody").empty();
- $("#upMsgTbody").append(html);
- }
-
-
- });
- //点击放大
- /* $("img").click(function() {
- javaex.dialog({
- type : "image", // 弹出层类型
- url : $(this).attr("src") // 图片地址
- });
- });*/
-
- });
-
-
- $("#everyDayTask").bind("click", async function() {
-
- let videoAid = 758643487;
- let videoCid = 357521682;
- let videoBvid = "BV1V64y1d7ed";
- let videoMid = 99439379;
- //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
- await HNAPI.DoSign();
- await HNTOOL.Sleep(3000);
-
-
- //2.每日观看视频 获取分区最新视频列表 http://api.bilibili.com/x/web-interface/dynamic/region pn=1 ps=20 rid=21
- let archivesList = await HNAPI.dynamicRegion();
- await HNTOOL.Sleep(2000);
-
- let num = HNTOOL.random(0, archivesList.length - 1);
-
- if (archivesList == true && num != 2) {
-
- videoAid = archivesListp[num].aid;
- videoCid = archivesListp[num].bvid;
- videoBvid = archivesListp[num].cid;
- videoMid = archivesListp[num].owner.mid;
- }
-
- await HNAPI.playOneVideo(videoBvid, videoMid);
-
- await HNAPI.addCoin(videoAid);
- await HNTOOL.Sleep(3000);
-
- await HNAPI.addShare(videoAid);
- await HNTOOL.Sleep(3000);
-
- await HNAPI.clickNow();
-
-
- });
-
- $("#reserveActivity").bind("click", async function() {
-
-
- let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSid.json";
- let myjson = await HNAPI.getMyJson(url);
-
-
- for (const sid in myjson) {
-
- let siddata = myjson[sid];
-
- console.log("时间:" + javaex.dateFormat(siddata.livePlanStartTime, 'yyyy-MM-dd HH:mm:ss') + "---upUID:" + siddata.upmid +
- "---奖品:" + siddata.prizeInfo.text);
-
-
- await HNAPI.reserveActivity(sid);
- await HNTOOL.Sleep(3000);
-
- javaex.tip({
- content: "时间:" + javaex.dateFormat(siddata.livePlanStartTime, 'yyyy-MM-dd HH:mm:ss') + "--upUID:" + siddata.upmid +
- "--奖品:" + siddata.prizeInfo.text,
- type: "success"
- });
-
- }
-
- alert("预约抽奖结束");
- });
-
- $("#plateActivity").bind("click", async function() {
-
- //获取轮盘数据
-
- let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
- let myjson = await HNAPI.getMyJson(url);
- let lmt = 0;
- let k = 20; //重试次数 防止卡主
- let giftArr = [];
- let endAtion = [];
-
- javaex.tip({
- content: "开始参加轮盘!!!",
- type: "success"
- });
-
- await HNAPI.getUserNav();
- await HNTOOL.Sleep(1500);
-
-
- for (const json of myjson) {
- //let x = json.name;
- for (let i = 0; i < 20; i++) {
- //结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
- let resout = await HNAPI.addLotteryTimes(json.sid);
-
- await HNTOOL.Sleep(200);
- if (resout == 1) {
-
- endAtion.push(json.name + ":活动已结束!");
- javaex.tip({
- content: json.name + "活动已结束!",
- type: "success"
- });
-
- break;
- }
- if (resout != 0 && resout != 1) {
-
- javaex.tip({
- content: json.name + resout,
- type: "error"
- });
-
- break;
- }
-
- if (resout == 0) {
-
- lmt = await HNAPI.getLotteryMytimes(json.sid);
- continue;
- }
-
- }
-
- javaex.tip({
- content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
- type: "success"
- });
-
- await HNTOOL.Sleep(1500);
-
- for (let i = 0; i < lmt; i++) {
-
- let gift = await HNAPI.lotteryDo(json.sid);
-
-
- if (gift == true) {
-
- javaex.tip({
- content: "点击过快,9秒后自动重试!!!",
- type: "error"
- });
-
- i--;
- k--;
- }
-
- if (gift == false || k == 0) {
- break;
- }
-
- if (gift != "未中奖0" && gift != true) {
- giftArr.push(json.name + "奖品为:" + gift);
- break;
- } else {
- javaex.tip({
- content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
- type: "success"
- });
- }
- await HNTOOL.Sleep(9000);
-
- }
-
-
- }
-
-
- HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
- 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
-
- alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
- 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
-
-
- });
-
- $("#addPlay").bind("click", async function() {
-
-
- let html = '';
-
- html += '<div style="padding: 10px 10px 10px 0px;">'
- html += '<form id="getUpMassage_form">'
-
- html += ' <div class="javaex-unit clear">'
- html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
- html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
- html +=
- ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
- html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
- html += ' </div>'
- html += ' </div>'
- html += ' <div class="javaex-unit clear">'
- html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
- html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
- html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
- html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
- html += ' </div>'
- html += ' </div>'
- html += '</form>';
- html += ' <div class="javaex-unit clear tc">'
- html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
- html += ' </div>'
- html += '<hr class="javaex-divider"></hr>';
- html += '</div>';
-
-
- javaex.panel(this, {
- position: "right",
- content: html
- });
-
- $("#addPlay_bgn").click(async function() {
-
- let MID = javaex.getSelectVal("#addPlay_uid")
- let BV = javaex.getSelectVal("#addPlay_bv");
- let bvArr = [];
- let bvArr2 = [];
-
- MID = javaex.ifnull(MID, BiliData.author_uid);
-
-
- if (BV == "0") {
-
- //1.查询up所有视频BV号 2.发送心跳间隔2s
- HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
- await HNTOOL.Sleep(500);
- bvArr2 = BiliData.BVList;
-
- for (let i = 1; i > 0; i++) {
-
- HNAPI.getUpAllBV(MID, i);
-
- await HNTOOL.Sleep(500);
-
- if (BiliData.BVList.length == 0) {
- if (bvArr.length == 0) {
- javaex.tip({
- content: "该用户无投稿视频,请确认是否有误!",
- type: "success"
- });
- await HNTOOL.Sleep(2000);
- }
- //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
- bvArr = bvArr.concat(bvArr2);
- break;
- }
-
- bvArr = bvArr.concat(BiliData.BVList);
- }
-
-
- if (bvArr.length != 0) {
-
- for (const emt of bvArr) {
-
- HNAPI.playOneVideo(emt.bvid, MID);
-
- await HNTOOL.Sleep(2000);
-
- }
-
- alert("播放完成!!!");
-
- }
-
-
- } else {
- //1.调用点击播放接口
- //2.发送心跳
-
- await HNTOOL.Sleep(500);
-
- HNAPI.playOneVideo(BV);
- }
-
-
- });
-
-
- });
-
- }
-
-
- let addSetPage = async function() {
-
- HNTOOL.Sleep(1000);
-
- $('body').append('' +
- '<div id="left_navbar">' +
- '<div class="javaex-menu-container"> ' +
- ' <div id="menu" class="javaex-menu"> ' +
- ' <ul> ' +
- ' <li class="javaex-menu-item alone hover" > ' +
- ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
- ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
- ' </li> ' +
- ' </ul> ' +
- ' <ul> ' +
- ' <li class="javaex-menu-item"> ' +
- ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
- ' <ul> ' +
- ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
- ' </ul> ' +
- ' </li> ' +
- ' <li id="chackList" class="javaex-menu-item"> ' +
- ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
- ' <ul> ' +
- ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
- //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
- ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
- ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
- ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
- ' </ul> ' +
- ' </li> ' +
- ' <li class="javaex-menu-item"> ' +
- ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
- ' <ul> ' +
- ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
- ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
- ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
- ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
- //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
- //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
- ' </ul> ' +
- ' </li> ' +
- ' <li class="javaex-menu-item"> ' +
- ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
- ' <ul> ' +
- ' <li id="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
- //' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
- //' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
- //' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
- ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
- ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
- //' <li id="" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
- ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
- ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
- ' </ul> ' +
- ' </li> ' +
- ' <li class="javaex-menu-item"> ' +
- ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
- ' <ul> ' +
- ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
- ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
- ' </ul> ' +
- ' </li> ' +
-
- ' </ul> ' +
- ' </div> ' +
- '</div>' +
- '</div>');
- //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
-
- javaex.menu({
- id: "menu",
- isShowAll: false
- });
-
- }
-
-
-
-
- let showUnreadMsg = function() {
-
- var html = '';
- html += '<div class="javaex-panel-box" style="width: 250px;">';
- html += ' <ul>';
- html += ` <p style="color: #FFF;">用户消息</p>`;
- html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
- html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
- html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
- html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
- html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
- html += ' <hr class="javaex-divider"></hr>';
- html += ' </ul>';
- html += '</div>';
-
-
- javaex.panel(document.getElementById("getUnread"), {
- position: "right",
- content: html
- });
-
- javaex.tip({
- content: "查询用户通知成功!",
- type: "success"
- });
-
- }
-
- /**
- * 检查 艾特信息
- * @returns {Promise<void>}
- */
- let chackAtMsg = async function(items) {
-
- await HNTOOL.Sleep(500);
-
- if (items != false && typeof(items) != "undefined") {
-
-
- var html = '';
- html += '<div class="javaex-panel-box" style="width: auto;">';
- html += ' <ul>';
- html += ` <p style="color: #FFF;">@信息</p>`;
- items.forEach(function(item) {
-
- var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
- HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
- `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
-
- html +=
- ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
- html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
- html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
- html += ' <hr class="javaex-divider"></hr>';
- });
- html += ' </ul>';
- html += '</div>';
-
-
- if (($("#chackList").attr("class")).indexOf("hover") > -1) {
- javaex.panel(document.getElementById("getAtMsg"), {
- position: "right",
- content: html
- });
- } else {
- javaex.panel(document.getElementById("chackList"), {
- position: "right",
- content: html
- });
- }
-
-
- }
-
- }
-
-
- let addStyle = function() {
- const animate = GM_getResourceText('animate');
- const common = GM_getResourceText('common');
- const defaultCss = GM_getResourceText('defaultCss');
- //const icomoonex = GM_getResourceText('icomoonex');
- //const AllCss = animate + common + defaultCss + icomoonex;
- const AllCss = animate + common + defaultCss;
- const style = document.createElement('style');
- style.innerHTML = AllCss;
- return document.getElementsByTagName('head')[0].appendChild(style);
- }
-
- /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
-
-
- /*-----------------------------------------------常用API--------------------------------------------------*/
-
- let HNAPI = {
-
- /**
- * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
- */
- clickNow: async function() {
- return new Promise((resolve) => {
- Ajax.get({
-
- url: BILIBLI_PATH.api + '/x/report/click/now',
- queryStringsObj: {
- jsonp:"jsonp"
- },
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- javaex.tip({
- content: "每日登录" + res.data.text,
- type: "success"
- });
- resolve(true);
-
- } else {
-
- javaex.tip({
- content: res.message,
- type: "error"
- });
-
- resolve(false);
- }
- }
- })
- });
- },
-
- /**
- * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
- * @param {number} videoAid
- */
- addShare: async function(videoAid) {
- return new Promise((resolve) => {
- Ajax.post({
- url: BILIBLI_PATH.api + '/x/web-interface/share/add',
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
- aid: videoAid,
- csrf: Live_info.csrf_token
- },
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- javaex.tip({
- content: "每日分享视频成功",
- type: "success"
- });
-
- resolve(true);
- } else {
-
- javaex.tip({
- content: res.message,
- type: "error"
- });
-
- resolve(false);
- }
- }
- })
- });
- },
-
- /**
- * 每日投币 post https://api.bilibili.com/x/web-interface/coin/add
- * @param {number} videoAid
- */
- addCoin: async function(videoAid) {
- return new Promise((resolve) => {
- Ajax.post({
- url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
- aid: videoAid,
- multiply: 2,
- select_like: 0,
- cross_domain: true,
- csrf: Live_info.csrf_token
- },
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- javaex.tip({
- content: "投币成功",
- type: "success"
- });
-
- resolve(true);
- } else {
-
- javaex.tip({
- content: res.message,
- type: "error"
- });
-
- resolve(false);
- }
- }
- })
- });
- },
-
-
- //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
-
- DoSign: async function() {
- return new Promise((resolve) => {
- Ajax.get({
-
- url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
- queryStringsObj: {
-
- },
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- javaex.tip({
- content: "签到成功:" + res.data.text,
- type: "success"
- });
- resolve(true);
-
- } else if (res.code === 1011040) {
-
- javaex.tip({
- content: res.message,
- type: "success"
- });
-
- resolve(true);
- } else {
-
- javaex.tip({
- content: res.message,
- type: "error"
- });
-
- resolve(false);
- }
- }
- })
- });
- },
-
-
- /**
- * // 获取分区最新视频列表
- */
- dynamicRegion: async function() {
- return new Promise((resolve) => {
- Ajax.get({
-
- url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
- queryStringsObj: {
- "pn": 1,
- "ps": 20,
- "rid": 21
- },
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- javaex.tip({
- content: "获取分区最新视频成功",
- type: "success"
- });
- resolve(res.data.archives);
-
- } else {
-
- javaex.tip({
- content: "获取分区最新视频失败" + res.message,
- type: "error"
- });
-
- resolve(false);
- }
- }
- })
- });
- },
-
- /**
- * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
- * @param {Object} sid
- */
- reserveActivity: async function(sid) {
- return new Promise((resolve) => {
- Ajax.post({
- url: BILIBLI_PATH.api + '/x/space/reserve',
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
- sid: sid, //当前用户
- jsonp: "jsonp",
- csrf: Live_info.csrf_token
- },
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- /* javaex.tip({
- content: sid + "参加成功!" + res.message,
- type: "success"
- }); */
-
- resolve(true);
- } else {
-
- javaex.tip({
- content: res.message,
- type: "error"
- });
-
- resolve(false);
- }
- }
- })
- });
- },
-
- getGiftList: async function(room) {
- return new Promise((resolve) => {
- Ajax.get({
-
- url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
- queryStringsObj: {
- "room_id": room
- },
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- resolve(res.data.list);
- } else {
-
- javaex.tip({
- content: "查询包裹失败!" + res.message,
- type: "error"
- });
-
- resolve(false)
- }
- }
- })
- });
- },
-
- /**
- * 送银B克拉
- * @param {Object} ruid
- * @param {Object} roomid
- */
- bagSendGift: async function(ruid, roomid, bag_id) {
- return new Promise((resolve) => {
- Ajax.post({
- url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
- uid: Live_info.uid, //当前用户
- gift_id: 3,
- ruid: ruid,
- send_ruid: 0,
- gift_num: 1,
- bag_id: bag_id,
- //rnd: Math.round(new Date() / 1000); //时间戳,
- platform: 'pc',
- biz_code: 'Live',
- biz_id: roomid,
- storm_beat_id: 0,
- price: 0,
- csrf_token: Live_info.csrf_token,
- csrf: Live_info.csrf_token
-
- },
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- javaex.tip({
- content: roomid + "赠送b克拉成功!" + res.message,
- type: "success"
- });
-
- resolve(true);
- } else {
-
- javaex.tip({
- content: res.message,
- type: "error"
- });
-
- resolve(false);
- }
- }
- })
- });
- },
-
-
- /**
- * 判断是否有勋章
- * @param {Object} uid
- * @param {Object} room
- */
-
- getFansMedalInfo: async function(uid, room) {
- return new Promise((resolve) => {
- Ajax.get({
-
- url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
- queryStringsObj: {
- "target_id": uid,
- "room_id": room
- },
- //dataType:'application/json, text/plain, */*',
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- if (res.data.my_fans_medal.level == 0) {
- resolve(false)
- } else {
- resolve(true)
- }
-
- } else {
-
- javaex.tip({
- content: "查询勋章失败!" + res.message,
- type: "error"
- });
-
- resolve(false)
- }
- }
- })
- });
- },
-
-
-
-
- getDisuidList: async function(re_version, pn) {
- return new Promise((resolve) => {
- Ajax.get({
-
- url: BILIBLI_PATH.api + '/x/relation/blacks',
- queryStringsObj: {
- "re_version": re_version,
- "pn": pn
- },
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
- resolve(res.data.list)
- } else {
-
- javaex.tip({
- content: "查询黑名单失败!" + res.message,
- type: "error"
- });
-
- resolve(null)
- }
- }
- })
- });
- },
-
- /**
- * @param {Object} uid
- * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
- */
- cancelAtt: async function(uid, act, re_src) {
- return new Promise((resolve) => {
- Ajax.post({
- url: BILIBLI_PATH.api + '/x/relation/modify',
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
- fid: uid,
- act: act,
- re_src: re_src == undefined ? 11 : 116,
- jsonp: "jsonp",
- csrf: Live_info.csrf_token,
- },
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- //HNAPI.cancelAtt(uid, 6);
-
- javaex.tip({
- content: "取关成功!" + res.message,
- type: "success"
- });
-
- resolve(true);
- } else if (res.code === 22003) {
-
- HNAPI.cancelAtt(uid, 6);
-
- javaex.tip({
- content: "取消拉黑" + res.message,
- type: "success"
- });
- resolve(true);
- } else {
-
- javaex.tip({
- content: res.message,
- type: "error"
- });
-
- resolve(false);
- }
- }
- })
- });
- },
-
- getRoomMsg: async function(roomid) {
- return new Promise((resolve) => {
- Ajax.get({
-
- url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
- queryStringsObj: {
- "roomid": roomid
- },
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
- resolve(res.data.info.uid)
- } else {
- resolve(false)
- }
- }
- })
- });
- },
-
- /**
- *
- * @param sid
- * @returns {Promise<unknown>}
- */
- lotteryDo: async function(sid) {
- return new Promise((resolve) => {
- Ajax.post({
- url: BILIBLI_PATH.api + '/x/activity/lottery/do',
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
-
- sid: sid,
- type: 1,
- csrf: Live_info.csrf_token,
- },
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
- resolve((res.data)[0].gift_name);
-
- } else if (res.code === 75400) {
-
- resolve(true);
- } else {
- javaex.tip({
- content: "本次抽奖失败!" + res.message,
- type: "error"
- });
- resolve(false);
- }
- }
- })
- });
- },
-
-
- getLotteryMytimes: async function(sid) {
- return new Promise((resolve) => {
- Ajax.get({
- url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
- queryStringsObj: {
- sid: sid
- },
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
- resolve(res.data.times)
- } else {
- resolve(0)
- }
- }
- })
- });
- },
-
- /**
- * 增加抽奖次数一般是分享
- * @param sid 活动sid
- * @returns {Promise<unknown>} 0 成功 1:活动结束
- */
- addLotteryTimes: async function(sid) {
- return new Promise((resolve) => {
- Ajax.post({
- url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
-
- sid: sid,
- action_type: 3,
- csrf: Live_info.csrf_token,
- },
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
-
- resolve(0)
- } else if (res.code === 75003) {
-
- resolve(1)
-
- } else {
-
- resolve(res.message);
- }
- }
- })
- });
- },
- /**
- * 查询用户关注 默认一次查询50
- * @param vmid 用户uid
- * @param pn 页码
- * @returns {Promise<unknown>}
- */
- getMyFollow: async function(vmid, pn) {
- return new Promise((resolve) => {
- Ajax.get({
- url: BILIBLI_PATH.api + '/x/relation/followings',
- queryStringsObj: {
- vmid: vmid,
- pn: pn
- },
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
- resolve(res.data)
- } else {
- resolve(null)
- }
- }
- })
- });
- },
-
-
- getMyinfo: function() {
- return new Promise((resolve) => {
- Ajax.get({
- url: BILIBLI_PATH.api + '/x/space/myinfo',
- queryStringsObj: {},
- hasCookies: true,
- success: responseText => {
- let res = HNTOOL.strToJson(responseText);
- if (res.code === 0) {
- resolve(res.data)
- } else {
- resolve(null)
- }
- }
- })
- });
- },
-
- getMyJson: function(url) {
- return new Promise((resolve) => {
- GM_xmlhttpRequest({
- method: "GET",
- url: url,
- onload: function(response) {
- const res = HNTOOL.strToJson((response || {}).responseText)
- resolve(res);
- }
- });
- })
- },
-
-
- userInfo: function(mid) {
-
- Ajax.get({
- url: BILIBLI_PATH.api + '/x/space/acc/info',
- queryStringsObj: {
- mid: mid
- },
- hasCookies: true,
- success: responseText => {
-
- var json = JSON.parse(responseText);
-
- if (json.code != 0) {
-
-
- }
- }
- });
-
- },
-
- sendQmsg: async function(key, msg) {
-
- $.ajax({
- url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
-
- success: function(result) {
-
- }
- });
-
-
- /*GM_xmlhttpRequest({
- method: "GET",
- url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
- onload: function (response) {
-
- let json = JSON.parse(response.response);
- if (json.code == 0) {
-
- javaex.tip({
- content: "自动动态中奖提醒成功!" + json.reason,
- type: "success"
- });
- } else {
- console.log("自动动态中奖提醒失败!" + json.reason);
- javaex.tip({
- content: "自动动态中奖提醒失败!" + json.reason,
- type: "error"
- });
- }
-
- }
- });*/
-
- },
-
- /**
- * 批量关注和拉黑 batchModify
- *
- * https://api.bilibili.com/x/relation/batch/modify
- * @param uid
- */
-
- batchModify: function(uids, act) {
-
-
- Ajax.post({
- url: BILIBLI_PATH.api + "/x/relation/batch/modify",
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
-
- "fids": uids,
- "act": act == undefined ? 1 : act, //1 关注 5 拉黑
- "re_src": 151,
- csrf: Live_info.csrf_token,
- },
- success: responseText => {
-
- let json = JSON.parse(responseText);
-
- if (/^{"code":0/.test(responseText)) {
-
- javaex.tip({
- content: `执行成功!---失败(` + json.data.failed_fids.length + `/15)名单:` + json.data.failed_fids,
- type: "success"
- });
-
- } else {
- javaex.tip({
- content: "关注失败!" + json.message,
- type: "error"
- });
- }
- }
- })
- },
-
-
- /**
- * //https://api.bilibili.com/x/relation/modify
- *
- * @param UID
- */
- disUserByUid: function(vmid) {
-
- Ajax.post({
- url: BILIBLI_PATH.api + '/x/relation/modify',
- data: {
- fid: parseInt(vmid),
- re_src: 11,
- act: 5,
- jsonp: "jsonp",
- csrf: Live_info.csrf_token,
- },
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- success: responseText => {
-
- var json = JSON.parse(responseText);
-
- if (json.code != 0) {
-
- console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
- javaex.tip({
- content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
- type: "error"
- });
-
- } else {
- console.log("拉黑用户成功 uid:" + vmid);
- javaex.tip({
- content: "拉黑用户成功 uid:" + vmid,
- type: "success"
- });
- }
- }
- });
-
- },
- /**
- * http://api.bilibili.com/x/web-interface/view
- * @param BV
- * 心跳间隔15秒
- */
- playOneVideo: function(BV, MID) {
-
- //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
- Ajax.post({
- url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
-
- "bvid": BV,
- "part": 1,
- "mid": Live_info.uid,
- "lv": 2,
- "jsonp": "jsonp",
- "type": 3,
- "sub_type": 0
- },
- success: responseText => {
-
- let json = JSON.parse(responseText);
-
- if (/^{"code":0/.test(responseText)) {
- //发送一次心跳
- HNAPI.sendHeartbeat(BV, MID);
-
- } else {
- javaex.tip({
- content: "视频" + data.bvid + "播放失败!" + json.message,
- type: "error"
- });
- }
- }
- })
-
-
- },
-
- //上报视频播放心跳(web端)
- /**
- * http://api.bilibili.com/x/click-interface/web/heartbeat
- * @param json
- */
- sendHeartbeat: function(bvid, MID) {
-
- Ajax.post({
- url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
- data: {
- "bvid": bvid,
- "type": 3,
- "dt": 2,
- "played_time": HNTOOL.random(12, 40),
- "realtime": HNTOOL.random(12, 40),
- "play_type": 0
- },
- success: responseText => {
-
- if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
-
- javaex.tip({
- content: "视频BV" + bvid + "播放一次!",
- type: "success"
- });
- }
- }
- })
-
- },
-
- //获取up所有投稿视频
- /**
- * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
- * @param mid
- */
- getUpAllBV: function(mid, pn, ps) {
- ps = (ps === undefined ? 30 : ps); // a默认值为1
- Ajax.get({
- url: BILIBLI_PATH.api + '/x/space/arc/search',
- queryStringsObj: {
- mid: mid,
- tid: 0,
- order: 'pubdate',
- jsonp: 'jsonp',
- pn: pn,
- ps: ps
- },
- hasCookies: true,
- success: responseText => {
-
- var json = JSON.parse(responseText);
-
- if (json.code != 0) {
-
- javaex.tip({
- content: "获取up所有投稿视频失败!" + json.message,
- type: "success"
- });
-
- } else {
- BiliData.BVList = json.data.list.vlist;
-
- }
- }
- });
-
- },
-
-
- /**
- *
- * @param path
- * @param data
- * @param saveObj
- * @param Func
- */
- publicGet: function(path, queryStringsObj) {
-
- if (typeof(queryStringsObj) != "undefined") {
- queryStringsObj = {};
- }
- Ajax.get({
- url: BILIBLI_PATH.api + path,
- queryStringsObj: queryStringsObj,
- hasCookies: true,
- success: responseText => {
-
- let json = JSON.parse(responseText);
- if (chackCode(json.code) && json.code == 0) {
-
- return json.data;
- }
-
- return false;
-
- }
- })
-
- },
-
- /**
- * 导航栏用户信息
- */
- getUserNav: async function() {
-
- GM_xmlhttpRequest({
- method: "GET",
- url: BILIBLI_PATH.api + "/x/web-interface/nav",
- //timeout:3000,
- onload: function(response) {
-
- let json = JSON.parse(response.response);
- console.log(json);
- BiliData.login_code = json.code;
- BiliData.login_message = json.message;
- BiliData.LoginData = json.data;
-
- }
- });
-
- },
-
- /**
- * 获取某up详细信息
- * http://api.bilibili.com/x/web-interface/card
- */
- getUpCard: function(mid) {
-
- Ajax.get({
- url: BILIBLI_PATH.api + '/x/web-interface/card',
- queryStringsObj: {
- mid: mid,
- photo: false
- },
- hasCookies: true,
- success: responseText => {
-
- var json = JSON.parse(responseText);
-
- if (json.code != 0) {
-
- javaex.tip({
- content: "查询失败!" + json.message,
- type: "success"
- });
- return false;
- } else {
- BiliData.upCard = json;
-
- }
-
-
- }
- })
-
- },
-
- /**
- *
- * @param uid 用户uid
- * @param ps 每页视频个数 默认30个
- * @param pn 第几页
- */
- getUpAllVideo: function(uid, ps, pn) {
-
- },
- getChallenge: async function() {
-
-
- },
- /**
- * 硬币记录
- * @returns {Promise<void>}
- */
- getCoinLog: async function() {
-
- GM_xmlhttpRequest({
- method: "GET",
- url: BILIBLI_PATH.api + "/x/member/web/coin/log",
- //url: "http://api.bilibili.com/x/member/web/coin/log",
- onload: function(response) {
-
- let json = JSON.parse(response.response);
- if (json.code == 0) {
-
- console.log("硬币记录" + json);
- BiliData.CoinLog = json.data;
-
- return true;
- }
-
- }
- });
- },
- /**
- * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
- * @returns {Promise<void>}
- */
- getUnread: async function() {
-
- Ajax.get({
- url: BILIBLI_PATH.api + "/x/msgfeed/unread",
- hasCookies: true,
- success: responseText => {
-
- let json = JSON.parse(responseText);
- if (chackCode(json.code) && json.code == 0) {
-
- BiliData.Unread = json.data;
- showUnreadMsg();
- }
-
- return false;
-
- }
- })
-
- /* GM_xmlhttpRequest({
- method: "GET",
- url: BILIBLI_PATH.api + "/x/msgfeed/unread",
- onload: function (response) {
-
- let json = JSON.parse(response.response);
-
- if (chackCode(json.code) && json.code == 0) {
-
- BiliData.Unread = json.code;
- showUnreadMsg();
-
- }
-
- }
- });*/
- },
- /**
- *
- * @param type reply:回复我的 at @我的
- */
- getMsgfeed: function(type) {
- Ajax.get({
- url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
- queryStringsObj: {
- build: 0,
- mobi_app: 'web'
- },
- hasCookies: true,
- success: responseText => {
-
- var json = JSON.parse(responseText);
-
- if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
- return false;
- } else {
- chackAtMsg(json.data.items);
-
- return true;
- }
-
-
- }
- })
-
- },
-
- /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
- * @returns {Promise<void>}
- */
- getUnrewad: async function() {
-
- GM_xmlhttpRequest({
- method: "GET",
- data: {
- "mid": 99439379,
- "pn": 1,
- "ps": 5,
- },
- url: BILIBLI_PATH.api + "/x/space/arc/search",
- onload: function(response) {
-
- let json = JSON.parse(response.response);
- if (json.code == 0) {
-
- BiliData.Video = json.data;
- console.log("未读消息数" + json);
- }
-
- }
- });
- },
-
- /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
- * @param {number} oid
- * @param {nbumber} rpid
- * @param {number} action
- * @returns {Promise<void>}
- * type: 11
- * ordering: heat
- * jsonp: jsonp
- * csrf: 54a******* CSRF Token(位于cookie)
- */
-
- likeInDynamicComments: async function(oid, rpid, action) {
-
-
- Ajax.post({
- url: BILIBLI_PATH.api + "/x/v2/reply/action",
- hasCookies: true,
- dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
- data: {
- "oid": oid,
- "type": 11,
- "rpid": rpid,
- "action": action,
- "ordering": "heat",
- "jsonp": "jsonp",
- "csrf": Live_info.csrf_token,
- },
- success: responseText => {
-
- if (/^{"code":0/.test(responseText)) {
-
- BiliData.replyAction = JSON.parse(responseText);
- console.log("点赞成功!" + responseText);
- }
- }
- })
-
- }
-
-
- }
-
- /*-----------------------------------------------常用工具函数--------------------------------------------------*/
-
-
- let HNTOOL = {
-
-
- copyText: function(domId) {
- let btn = document.getElementById(domId);
- btn.select();
- if (document.execCommand('copy')) {
- document.execCommand('copy');
- javaex.tip({
- content: "复制成功!",
- type: "success"
- });
- }
-
- },
- /**
- * s数组去重并排序
- */
-
- arrUnique: function(ary) {
-
- let obj = {};
- for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
- let item = ary[i]
- obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
- } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
- // 如果没有 将这个元素添加到对象中
- ary.sort((a, b) => {
- return a - b
- }) // 数组去重后 按升序排列
- obj = null;
-
- javaex.tip({
- content: "已去重!",
- type: "success"
- });
- return ary;
-
- },
-
- split_array: function(arr, len) {
-
- let arr_length = arr.length;
- let newArr = [];
- for (let i = 0; i < arr_length; i += len) {
- newArr.push(arr.slice(i, i + len));
- }
- return newArr;
- },
- strToJson: function(params) {
- const isJSON = (str => {
- if (typeof str === 'string') {
- try {
- const obj = JSON.parse(str);
- return typeof obj === 'object' ? obj : false
- } catch (_) {
- console.log(str);
- return false;
- }
- } else {
- console.log(`${str}\nIt is not a string!`);
- return false;
- }
- })(params);
- return isJSON ? isJSON : {}
- },
-
- chackAtMsg: function() {
-
- let config = HNTOOL.getConfig();
- if (config.qmsg_checked == true && config.qmsg_key) {
-
- document.getElementById("getAtMsg").click();
-
- }
-
- },
-
- cssChecked: function(id, dom) {
-
- dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
-
-
- },
- getConfig: function() {
-
- let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
-
- if (CONFIG == null) {
- CONFIG = HN_SETUP_CONFIG;
- }
-
- return CONFIG;
- },
-
- /**
- * 获取cookie 中某个键对应的值
- * @param name
- */
-
- getCookie: function(name) {
- let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
- if (arr != null) return escape(arr[2]);
- return false;
- },
- /**
- * 得到一个字符串数组的中随机一个
- * @param {List} list
- */
- getRandomWordOfList: function(list) {
- var L = list.length;
- var i = Math.ceil(Math.random() * L);
-
- return list[i];
- },
- random: function(min, max) {
-
- return Math.floor(Math.random() * (max - min)) + min;
- },
-
- Sleep: function(ms) {
- return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
- }
-
- }
-
- let errorMsg = {
- "-1": "应用程序不存在或已被封禁!",
- "-2": "Access Key错误!",
- "-3": "API校验密匙错误!",
- "-4": "调用方对该Method没有权限!",
- "-101": "账号未登录!",
- "-102": "账号被封停!",
- "-103": "积分不足!",
- "-104": "硬币不足!",
- "-105": "验证码错误!",
- "-106": "账号非正式会员或在适应期!",
- "-107": "应用不存在或者被封禁!",
- "-108": "未绑定手机!",
- "-109": "未知!",
- "-110": "未绑定手机!",
- "-111": "csrf 校验失败!",
- "-112": "系统升级中!",
- "-113": "账号尚未实名认证!",
- "-114": "请先绑定手机!",
- "-115": "请先完成实名认证!",
- "-304": "木有改动!",
- "-307": "撞车跳转!",
- "-400": "请求错误!",
- "-401": "未认证!",
- "-403": "访问权限不足!",
- "-404": "啥都木有!",
- }
-
- /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
- /**
- *
- * @param code
- * @constructor
- */
- let chackCode = function(code) {
-
- let emsg = errorMsg[code + ""];
- if (emsg != null) {
- javaex.tip({
- content: emsg,
- type: "error"
- });
-
- return false;
- }
-
- return true;
- }
-
-
- /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
- //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
-
- /*window.onbeforeunload = function() {
- if (!canLeavePage()) {
- return ('确认离开当前页面吗?未保存的数据将会丢失!');
- }
- };*/
-
-
- /**
- * Ajax请求对象
- */
- const Ajax = (() => {
- /**
- * 检查options是否符合要求
- * @param {object} options
- * @returns {boolean}
- */
- function checkOptions(options) {
- let result = false;
- if (typeof options !== 'object') {
- console.warn('类型错误: typeof Options !== Object');
- return result;
- } else {
- if (typeof options.url !== 'string') {
- console.warn('类型错误: typeof Link !== Strings');
- return result;
- } else {
- const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
- if (!reg.test(options.url)) {
- console.warn('url字符串须为完整http链接');
- return result;
- }
- result = true;
- }
- }
- return result;
- }
-
- /**
- * 对象转URL编码
- * @param {object} data
- */
- function objToURLCode(data) {
- var _result = [];
- for (var key in data) {
- var value = data[key];
- if (value instanceof Array) {
- value.forEach(function(_value) {
- _result.push(key + "=" + _value);
- });
- } else {
- _result.push(key + '=' + value);
- }
- }
- return _result.join('&');
- }
-
- /**
- * 请求
- * @param {string} method
- * @param {object} options
- */
- function request(method, options) {
- if (checkOptions(options)) {
- let xhr = new XMLHttpRequest();
- const {
- url: _url,
- queryStringsObj,
- data,
- dataType,
- hasCookies
- } = options, url = typeof queryStringsObj === 'object' ?
- _url + '?' + objToURLCode(queryStringsObj) : _url;
- switch (method) {
- case 'GET':
- xhr.open("GET", url);
- break;
- case 'POST':
- xhr.open("POST", url);
- xhr.setRequestHeader('Content-Type', dataType);
- break;
- default:
- break;
- }
- if (hasCookies) xhr.withCredentials = true;
- xhr.timeout = 3000;
- xhr.addEventListener('load', () => {
- if (xhr.status === 200) {
- options.success(xhr.responseText)
- } else {
- console.error(`status:${xhr.status}`);
- options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
- }
- })
- xhr.addEventListener('error', () => {
- console.error('ajax请求出错')
- options.success('{"code":-1,"msg":"ajax请求出错"}');
- })
- xhr.addEventListener('timeout', () => {
- console.error('请求超时')
- options.success('{"code":-1,"msg":"请求超时"}');
- })
- switch (method) {
- case 'GET':
- xhr.send()
- break;
- case 'POST':
- xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
- break;
- default:
- break;
- }
- }
- }
-
- return {
- /**
- * 发送Get请求
- * @param {Object} options
- */
- get(options) {
- request("GET", options);
- },
- /**
- * 发送Post请求
- * @param {object} options
- */
- post(options) {
- request("POST", options);
- }
- }
- })()