"use strict"; // ==UserScript== // @name DouyuEx-斗鱼直播间增强插件 // @namespace https://github.com/qianjiachun // @icon https://s2.ax1x.com/2020/01/12/loQI3V.png // @version 2020.12.29.02 // @description 弹幕自动变色防检测循环发送 一键续牌 查看真实人数/查看主播数据 已播时长 一键签到(直播间/车队/鱼吧/客户端) 一键领取鱼粮(宝箱/气泡/任务) 一键寻宝 送出指定数量的礼物 一键清空背包 屏蔽广告 调节弹幕大小 自动更新 同屏画中画/多直播间小窗观看/可在斗鱼看多个平台直播(虎牙/b站) 获取真实直播流地址 自动抢礼物红包 背包信息扩展 简洁模式 夜间模式 开播提醒 幻神模式 关键词回复 关键词禁言 自动谢礼物 自动抢宝箱 弹幕右键信息扩展 防止下播自动跳转 影院模式 直播时间流控制 弹幕投票 直播滤镜 // @author 小淳 // @match *://*.douyu.com/0* // @match *://*.douyu.com/1* // @match *://*.douyu.com/2* // @match *://*.douyu.com/3* // @match *://*.douyu.com/4* // @match *://*.douyu.com/5* // @match *://*.douyu.com/6* // @match *://*.douyu.com/7* // @match *://*.douyu.com/8* // @match *://*.douyu.com/9* // @match *://*.douyu.com/topic/* // @match *://msg.douyu.com/* // @require https://cdn.jsdelivr.net/npm/flv.js@1.5.0/dist/flv.min.js // @require https://cdn.jsdelivr.net/npm/svgaplayerweb@2.3.1/build/svga.min.js // @grant GM_openInTab // @grant GM_xmlhttpRequest // @grant GM_setClipboard // @grant unsafeWindow // @connect douyucdn.cn // @connect douyu.com // @connect 122.51.5.63 // @connect qq.com // @connect ddocr.com // @connect douyuex.com // @connect bojianger.com // @connect greasyfork.org // @connect bilibili.com // @connect huya.com // @connect jsdelivr.net // @downloadURL none // ==/UserScript== function init() { initPkg_Night_Set_Fast(); removeAD(); initPkg_Statistics(); initPkg_Console(); initPkg_FollowList(); } function initPkg() { initPkg_ExIcon(); initPkg_ExPanel(); initPkg_RealAudience(); initPkg_CopyRealLive(); initPkg_RemoveAD(); initPkg_BagInfo(); initPkg_Update(); initPkg_MiniProgram(); initPkg_PopupPlayer(); initPkg_LiveTool(); initPkg_VideoTools(); initPkg_ExpandTool(); initPkg_Night(); initPkg_Refresh(); initPkg_BarrageLoop(); initPkg_FansContinue(); initPkg_FishFood(); initPkg_Sign(); initPkg_BarragePanel(); initPkg_AdVideo(); } function initPkg_Timer() { initPkg_FishPond_Timer(); } function initTimer() { initPkg_Timer(); exTimer = setInterval(initPkg_Timer, 20000); } function initStyles() { let style = document.createElement("style"); style.appendChild(document.createTextNode(` .bag-info { position: absolute; background-color: rgba(0, 0, 0, 0.6); color: white; width: 20px; font-weight: 800; height: 20px; text-align: center;}.bag-button { position: relative; color: rgb(255, 255, 255); text-align: center; height: 15px; line-height: 15px; cursor: pointer; margin-left: 5px; background: rgb(70, 171, 255); border-radius: 9px; padding: 0px 10px; float: right; right: 20px;}.bloop { background-color: rgba(255,255,255,0.9); width: 100%; height: 200px; position: relative; bottom: 200px; display: none;}.bloop__switch { position: absolute; right: 0; bottom: 0;}.bloop__mode { display: inline-block;}.barragePanel__funcPanel { position: absolute; width: 232px; height: 270px; display: block; background: white; overflow-y: scroll;}.barragePanel__funcPanel::-webkit-scrollbar {display:none}.barragePanel__muteTime { position: absolute; left: 25px; top: 123px; z-index: 5;}#copy-real-live { cursor: pointer;}.ex-icon { display: inline-block; vertical-align: middle; margin-right: 8px; -moz-user-select:none; /*火狐*/ -webkit-user-select:none; /*webkit浏览器*/ -ms-user-select:none; /*IE10*/ -khtml-user-select:none; /*早期浏览器*/ user-select:none;}.extool { background-color: rgba(255,255,255,0.9); width: 100%; height: 200px; position: relative; bottom: 200px; display: none;}.extool__switch { position: absolute; right: 0; bottom: 0;}.extool__bsize,.extool__sendgift { margin-bottom: 5px;}.extool__redpacket_room,.extool__gold { display: inline-block;}.ex_giftAnimation { width: 100%; height: 100%; position: absolute; z-index: 50; pointer-events: none;}.ex-panel { position: absolute; bottom: 35px; right: 38px; background-color: rgba(255,255,255,0.9); display: none; border: 2px rgb(234,173,26) solid; z-index: 7777; user-select: none;}.ex-panel__wrap { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;}.ex-panel__icon { margin: 0 10px; display: block; position: relative; padding: 5px; transition: 0.5s;}.ex-panel__icon:hover { transform: scale(1.15);}.ex-panel__tip { display:none; background:#f00; border-radius:50%; width:8px; height:8px; top:0px; right:0px; position:absolute;}#refreshFollowList { color: grey;position: absolute;right: 5px;top:0px;cursor: default;}.enter__panel { width: 100%; display: none; margin-top: 4px;}#enter__title { cursor: pointer;}#enter__select { width: 190px;}.enter__option { margin-top: 5px;}#enter__enterId { width: 40px;}#enter__reply { width: 150px;}#enter__word { width: 140px;}#enter__level { width: 25px; text-align: center;}.gift__panel { width: 100%; display: none; margin-top: 4px;}#gift__title { cursor: pointer;}#gift__select { width: 190px;}.gift__option { margin-top: 5px;}#gift__giftId { width: 40px;}#gift__reply { width: 150px;}.livetool { background-color: rgba(255,255,255,0.9); width: 100%; height: 290px; position: relative; bottom: 290px; display: none;}.livetool__cell { position: relative; display: -webkit-box; display: -webkit-flex; display: flex; box-sizing: border-box; width: 100%; padding: 10px 16px; overflow: hidden; color: #323233; font-size: 14px; line-height: 24px; background-color: #fff; border-bottom: 1px solid rgba(0,0,0,0.2); flex-wrap: wrap; -webkit-flex-wrap: wrap;}.livetool__cell_title { flex: 1; -webkit-box-flex: 1;}.livetool__cell_option { flex: 1; -webkit-box-flex: 1; text-align: right;}.livetool__cell_switch { float: right;}.mute__panel { width: 100%; display: none; margin-top: 4px;}#mute__title { cursor: pointer;}#mute__idlist { cursor: pointer; color: royalblue; margin-left: 10px;}#mute__select { width: 110px;}.mute__option { margin-top: 5px;}#mute__word { width: 70px;}#mute__count { width: 30px;}#mute__time { width: 65px;}.reply__panel { width: 100%; display: none; margin-top: 4px;}#reply__title { cursor: pointer;}#reply__select { width: 190px;}.reply__option { margin-top: 5px;}#reply__word { width: 70px;}#reply__reply { width: 147px;}.livetool__Treasure { width: 100%; position: relative; z-index: 999;}.vote__panel { width: 100%; display: none; margin-top: 4px;}#vote__title { cursor: pointer;}#vote__select { width: 100px;}.vote__option { margin-top: 5px;}#vote__theme { width: 70px;}#vote__options { width: 133px;}#vote__time { width: 35px;}#vote__show-result { cursor: pointer; color: royalblue; margin-left: 10px;}.vote__result { position: absolute; top: 0px; width: 300px; background: rgba(255,255,255,0.85); left: 0px; z-index: 999; padding: 5px; border-radius: 10px; user-select: none; display: none;}#vote__result-theme { font-size: 20px; font-weight: 600; margin-bottom: 10px;}#vote__result-close { position: absolute; top: 5px; right: 10px; font-size: 14px; cursor: pointer; color: gray;}.vote__option-wrap { margin-bottom: 10px;}.vote__option-choice { display: inline-block; font-size: 14px;}.vote__option-num { float: right; font-size: 14px;}.vote__progress { width: 100%; background-color: #ddd; border-radius: 10px;}.vote__progress-bar { width: 0%; height: 14px; background-color: #4CAF50; text-align: center; line-height: 30px; border-radius: 10px;}.miniprogram__panel { position: absolute; right: 43px; bottom: 100px; animation: move-in 0.75s; z-index: 101; text-align: center; display: none;}.miniprogram__wrap { overflow: hidden; background-color: white; border-radius: 5%; width: 200px; box-shadow: 0px 2px 20px 0px #888888; font-size: 14px;}.miniprogram__triangle { width: 0px; height: 0px; border-color: white transparent transparent transparent; border-style: solid; border-width: 10px; position: absolute; left: 100px;}#ex-point { cursor: pointer; float: left; line-height: 30px; -moz-user-select:none; /*火狐*/ -webkit-user-select:none; /*webkit浏览器*/ -ms-user-select:none; /*IE10*/ -khtml-user-select:none; /*早期浏览器*/ user-select:none;}#point__value { color: #333;}#ex-exchange { position: absolute; left: 0; bottom: 37px; z-index: 100;}.exchange__panel { width: 400px; height: 500px; position: relative;}.exchange__wrap { width: 400px; height: 500px; background-color: white; border-radius: 3%; overflow-y: scroll; overflow-x: hidden; box-shadow: 0px 0px 20px 0px #888888;}.exchange__wrap::-webkit-scrollbar { display:none}.exchange__close { position: absolute; color: rgb(127, 127, 137); right: 10px; top: 5px; font-size: 15px; cursor: pointer; z-index: 101;}.item__wrap { width: 100%; height: 130px; border-bottom: 1px solid rgba(121,127,137,0.4); position: relative;}.item__pic { left: 10px; top: 10px; position: absolute; height: 110px; width: 110px;}.item__name { position: absolute; top: 7px; left: 130px; color: #353536;; font-size: 15px; margin-right: 10px;}.item__description { position: absolute; top: 32px; left: 130px; font-size: 12px; margin-right: 10px; color: #969799;}.item__num { position: absolute; bottom: 27px; left: 130px; font-size: 12px; color: #969799;}.item__price { position: absolute; bottom: 7px; left: 130px; font-size: 14px; color: rgb(255,93,35); font-weight: 600;}.item__exchange { position: absolute; bottom: 8px; right: 10px; font-size: 14px; color: white; text-align: center; width: 80px; height: 25px; background-color: rgb(255,93,35); border-radius: 999px; cursor: pointer;}#ex-pointlist { position: absolute; width: 300px; height: 400px; background-color: white; border-radius: 3%; overflow: auto; z-index: 100; bottom: 37px;}#ex-pointlist::-webkit-scrollbar { display:none}.pointlist__wrap { width: 100%; height: 100%; margin: 15px 0; position: absolute;}.pointlist__close { position: absolute; color: rgb(127, 127, 137); right: 7px; font-size: 15px; cursor: pointer;}.pointlist__wrap table { border-collapse: collapse; margin: 0 auto; text-align: center;}.pointlist__wrap td,.pointlist__wrap th { border: 1px solid #cad9ea; color: #666; height: 30px; width: 85px;}.pointlist__wrap thead th { background-color: #CCE8EB; width: 100px;}.pointlist__wrap tr:nth-child(odd) { background: #fff;}.pointlist__wrap tr:nth-child(even) { background: #F5FAFA;}.point__panel { position: absolute; left: 0px; bottom: 37px; display: none; animation: move-in 0.75s; z-index: 101;}@keyframes move-in { 0% { opacity: 0; } 100% { opacity: 0.95; }}.panel__wrap { overflow: hidden; background-color: white; border-radius: 5%; width: 120px; box-shadow: 0px 2px 20px 0px #888888; font-size: 14px;}.panel__cell { width: 100%; height: 37px; line-height: 37px; border-bottom: 1px solid rgba(121,127,137,0.4); text-align: center; cursor: pointer;}.panel__cell:hover { background-color: rgb(217, 217, 217); transition: 0.75s;}.panel__triangle { width: 0px; height: 0px; border-color: white transparent transparent transparent; border-style: solid; border-width: 10px; position: absolute; left: 35px;}#ex-record { width: 300px; height: 400px; position: absolute; bottom: 67px; z-index: 100;}.record__close { position: absolute; color: rgb(127, 127, 137); right: -20px; font-size: 15px; cursor: pointer;}.records__wrap { width: 100%; height: 100%; background-color: white; border-radius: 3%; box-shadow: 0px 0px 20px 0px #888888; padding: 15px; overflow-y: scroll; overflow-x: hidden;}.records__wrap::-webkit-scrollbar { display:none}.record__wrap { height: 50px; width: 100%; border: 1px solid rgba(121,127,137,0.4); margin-bottom: 10px; display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex; transition: 0.75s; cursor: pointer;}.record__wrap:hover { background-color: #e9f5ff;}.record__left { flex: 1; position: relative;}.record__name { position: absolute; flex: 1; color: #353536;; font-size: 15px; top: 2px; margin-left: 5px;}.record__updatetime { position: absolute; margin-left: 5px; font-size: 12px; bottom: 2px; color: #969799;}.record__price { line-height: 50px; color: rgb(255,93,35); margin-right: 10px;}.record__pagenav { display: -webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex; width: 310px; position: absolute; bottom: -20px; padding-left: 10px; padding-right: 10px; cursor: pointer;}.record__prev { flex: 1; text-align: center; border: 1px solid rgba(121,127,137,0.8); transition: 0.75s; color: white; background-color: rgb(57,169,237);}.record__prev:hover { background-color: #7167ff;}.record__next { flex: 1; text-align: center; border: 1px solid rgba(121,127,137,0.8); transition: 0.75s; background-color: rgb(57,169,237); color: white;}.record__next:hover { background-color: #7167ff;}.exVideoDiv { width: 400px; height: 200px; background-color: rgba(255, 255, 255, 0); position: absolute; z-index: 7777;}.exVideoPlayer { width: 100%; height: 100%; cursor: move;}.exVideoScale { width: 10px; height: 10px; overflow: hidden; cursor: se-resize; position: absolute; right: 0; bottom: 0; background-color: rgb(231, 57, 57);}.exVideoInfo { width: 100%; height: 30px; background-color: gray; position: absolute; top: -30px; line-height: 30px;}.exVideoClose { width: 30px; float: right; color: white;}.exVideoQn, .exVideoCDN { margin-left: 5px;}.exVideoRID { margin: 0px 5px; font-weight: 800; font-size: medium;}#popup-player__prompt { display: none;}.real-audience { cursor: pointer; display: flex; padding: 0 7px; line-height: 33px;}#refresh-video { float: left; width: 24px; height: 24px; margin-right: 5px; cursor: pointer; background-size: contain;}.refresh-barrage { display: inline-block; vertical-align: top; margin: 0 2px; padding: 0 8px; height: 22px; line-height: 21px; background-color: #fff; border: 1px solid #e5e4e4; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; cursor: pointer;}#refresh-barrage__svg { vertical-align: middle;}#ex-cinema { float: left; width: 24px; height: 24px; margin-right: 10px; cursor: pointer; background-size: contain;}.cinema__wrap { display: none; position: relative; height: 100%; margin-right: -15px; border-radius: 4px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; float: left; right: -12px;}.cinema__panel { position: absolute; border: 1px solid #000; border-radius: 4px; transform: translateY(calc(-4px - 100%)) translateX(-50%); left: 33%; background-color: #000; opacity: .75; width: 70px;}.cinema__panel li { padding: 0 2px; white-space: nowrap; color: #fff; text-align: center; cursor: pointer;}.cinema__panel li:hover { background-color: rgb(85, 85, 85);} #ex-filter { float: left; width: 24px; height: 24px; margin-right: 10px; cursor: pointer; background-size: contain;}.filter__wrap { display: none; position: relative; height: 100%; margin-right: -15px; border-radius: 4px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; float: left; right: -12px;}.filter__panel { position: absolute; border: 1px solid #000; border-radius: 4px; transform: translateY(calc(-4px - 100%)) translateX(-50%); left: 33%; background-color: #000; opacity: .75; width: 300px; padding-top: 10px; padding-left: 10px; padding-right: 10px;}.filter__panel li { padding: 0 2px; white-space: nowrap; color: #fff; text-align: center; cursor: pointer;}.filter__panel li:hover { background-color: rgb(85, 85, 85);}.filter__scroll { width: 255px; height: 5px; background: #ccc; position: relative; display: inline-block;}.filter__scroll-bar { width: 15px; height: 15px; background: #369; position: absolute; top: -5px; left: 100px; cursor: pointer; border-radius: 100%;}.filter__scroll-mask { position: absolute; left: 0; top: 0; background: #369; width: 100px; height: 5px;}.filter__title { color: white; display: inline-block; cursor: initial; margin-right: 2px;}#filter__select { width: 260px; float: right;}.filter__filter { margin-top: 5px;}#ex-videospeed { float: left; width: 24px; height: 24px; margin-right: 10px; cursor: pointer; background-size: contain;}.videospeed__wrap { display: none; position: relative; height: 100%; margin-right: -15px; border-radius: 4px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; float: left; right: -12px;}.videospeed__panel { position: absolute; border: 1px solid #000; border-radius: 4px; transform: translateY(calc(-4px - 100%)) translateX(-50%); left: 33%; background-color: #000; opacity: .75; width: 70px;}.videospeed__panel li { padding: 0 2px; white-space: nowrap; color: #fff; text-align: center; cursor: pointer;}.videospeed__panel li:hover { background-color: rgb(85, 85, 85);} #ex-videosync { float: left; width: 24px; height: 24px; margin-left: 20px; cursor: pointer; background-size: contain;}/* Notice.css*/.noticejs-top{top:0;width:100%!important}.noticejs-top .item{border-radius:0!important;margin:0!important}.noticejs-topRight{top:10px;right:10px}.noticejs-topLeft{top:10px;left:10px}.noticejs-topCenter{top:10px;left:50%;transform:translate(-50%)}.noticejs-middleLeft,.noticejs-middleRight{right:10px;top:50%;transform:translateY(-50%)}.noticejs-middleLeft{left:10px}.noticejs-middleCenter{top:50%;left:50%;transform:translate(-50%,-50%)}.noticejs-bottom{bottom:0;width:100%!important}.noticejs-bottom .item{border-radius:0!important;margin:0!important}.noticejs-bottomRight{bottom:10px;right:10px}.noticejs-bottomLeft{bottom:10px;left:10px}.noticejs-bottomCenter{bottom:10px;left:50%;transform:translate(-50%)}.noticejs{font-family:Helvetica Neue,Helvetica,Arial,sans-serif}.noticejs .item{margin:0 0 10px;border-radius:3px;overflow:hidden}.noticejs .item .close{float:right;font-size:18px;font-weight:700;line-height:1;color:#fff;text-shadow:0 1px 0 #fff;opacity:1;margin-right:7px}.noticejs .item .close:hover{opacity:.5;color:#000}.noticejs .item a{color:#fff;border-bottom:1px dashed #fff}.noticejs .item a,.noticejs .item a:hover{text-decoration:none}.noticejs .success{background-color:#64ce83}.noticejs .success .noticejs-heading{background-color:#3da95c;color:#fff;padding:10px}.noticejs .success .noticejs-body{color:#fff;padding:10px}.noticejs .success .noticejs-body:hover{visibility:visible!important}.noticejs .success .noticejs-content{visibility:visible}.noticejs .info{background-color:#3ea2ff}.noticejs .info .noticejs-heading{background-color:#067cea;color:#fff;padding:10px}.noticejs .info .noticejs-body{color:#fff;padding:10px}.noticejs .info .noticejs-body:hover{visibility:visible!important}.noticejs .info .noticejs-content{visibility:visible}.noticejs .warning{background-color:#ff7f48}.noticejs .warning .noticejs-heading{background-color:#f44e06;color:#fff;padding:10px}.noticejs .warning .noticejs-body{color:#fff;padding:10px}.noticejs .warning .noticejs-body:hover{visibility:visible!important}.noticejs .warning .noticejs-content{visibility:visible}.noticejs .error{background-color:#e74c3c}.noticejs .error .noticejs-heading{background-color:#ba2c1d;color:#fff;padding:10px}.noticejs .error .noticejs-body{color:#fff;padding:10px}.noticejs .error .noticejs-body:hover{visibility:visible!important}.noticejs .error .noticejs-content{visibility:visible}.noticejs .progressbar{width:100%}.noticejs .progressbar .bar{width:1%;height:30px;background-color:#4caf50}.noticejs .success .noticejs-progressbar{width:100%;background-color:#64ce83;margin-top:-1px}.noticejs .success .noticejs-progressbar .noticejs-bar{width:100%;height:5px;background:#3da95c}.noticejs .info .noticejs-progressbar{width:100%;background-color:#3ea2ff;margin-top:-1px}.noticejs .info .noticejs-progressbar .noticejs-bar{width:100%;height:5px;background:#067cea}.noticejs .warning .noticejs-progressbar{width:100%;background-color:#ff7f48;margin-top:-1px}.noticejs .warning .noticejs-progressbar .noticejs-bar{width:100%;height:5px;background:#f44e06}.noticejs .error .noticejs-progressbar{width:100%;background-color:#e74c3c;margin-top:-1px}.noticejs .error .noticejs-progressbar .noticejs-bar{width:100%;height:5px;background:#ba2c1d}@keyframes noticejs-fadeOut{0%{opacity:1}to{opacity:0}}.noticejs-fadeOut{animation-name:noticejs-fadeOut}@keyframes noticejs-modal-in{to{opacity:.3}}@keyframes noticejs-modal-out{to{opacity:0}}.noticejs-rtl .noticejs-heading{direction:rtl}.noticejs-rtl .close{float:left!important;margin-left:7px;margin-right:0!important}.noticejs-rtl .noticejs-content{direction:rtl}.noticejs{position:fixed;z-index:10050;width:320px}.noticejs ::-webkit-scrollbar{width:8px}.noticejs ::-webkit-scrollbar-button{width:8px;height:5px}.noticejs ::-webkit-scrollbar-track{border-radius:10px}.noticejs ::-webkit-scrollbar-thumb{background:hsla(0,0%,100%,.5);border-radius:10px}.noticejs ::-webkit-scrollbar-thumb:hover{background:#fff}.noticejs-modal{position:fixed;width:100%;height:100%;background-color:#000;z-index:10000;opacity:.3;left:0;top:0}.noticejs-modal-open{opacity:0;animation:noticejs-modal-in .3s ease-out}.noticejs-modal-close{animation:noticejs-modal-out .3s ease-out;animation-fill-mode:forwards}/** * PostbirdAlertBox.js * - 原生javascript弹框插件 * Author: Postbird - http://www.ptbird.cn * License: MIT * Date: 2017-09-23 */.postbird-box-container { width: 100%; height: 100%; overflow: hidden; position: fixed; top: 0; left: 0; z-index: 9999; background-color: rgba(0, 0, 0, 0.2); display: block; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none}.postbird-box-container.active { display: block}.postbird-box-content { min-width: 400px; max-width: 600px; min-height: 150px; background-color: #fff; border: solid 1px #dfdfdf; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); margin-top: -100px}.postbird-box-header { width: 100%; padding: 10px 15px; position: relative; font-size: 1.1em; letter-spacing: 2px}.postbird-box-close-btn { cursor: pointer; font-weight: 700; color: #000; float: right; opacity: .5; font-size: 1.3em; margin-top: -3px; display: none}.postbird-box-close-btn:hover { opacity: 1}.postbird-box-text { box-sizing: border-box; width: 100%; padding: 0 10%; text-align: center; line-height: 40px; font-size: 20px; letter-spacing: 1px}.postbird-box-footer { width: 100%; position: absolute; padding: 0; margin: 0; bottom: 0; display: flex; display: -webkit-flex; justify-content: space-around; border-top: solid 1px #dfdfdf; align-items: flex-end}.postbird-box-footer .btn-footer { line-height: 44px; border: 0; cursor: pointer; background-color: #fff; color: #0e90d2; font-size: 1.1em; letter-spacing: 2px; transition: background-color .5s; -webkit-transition: background-color .5s; -o-transition: background-color .5s; -moz-transition: background-color .5s; outline: 0}.postbird-box-footer .btn-footer:hover { background-color: #e5e5e5}.postbird-box-footer .btn-block-footer { width: 100%}.postbird-box-footer .btn-left-footer,.postbird-box-footer .btn-right-footer { position: relative; width: 100%}.postbird-box-footer .btn-left-footer::after { content: ""; position: absolute; right: 0; top: 0; background-color: #e5e5e5; height: 100%; width: 1px}.postbird-box-footer .btn-footer-cancel { color: #333}.postbird-prompt-input { width: 100%; padding: 5px; font-size: 16px; border: 1px solid #ccc; outline: 0}.onoffswitch { position: relative; width: 45px; -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;}.onoffswitch-checkbox { position: absolute; opacity: 0; pointer-events: none;}.onoffswitch-label { display: block; overflow: hidden; cursor: pointer; height: 20px; padding: 0; line-height: 20px; border: 2px solid #E3E3E3; border-radius: 20px; background-color: #FFFFFF; transition: background-color 0.3s ease-in;}.onoffswitch-label:before { content: ""; display: block; width: 20px; margin: 0px; background: #FFFFFF; position: absolute; top: 0; bottom: 0; right: 23px; border: 2px solid #E3E3E3; border-radius: 20px; transition: all 0.3s ease-in 0s; }.onoffswitch-checkbox:checked + .onoffswitch-label { background-color: #3AAD38;}.onoffswitch-checkbox:checked + .onoffswitch-label, .onoffswitch-checkbox:checked + .onoffswitch-label:before { border-color: #3AAD38;}.onoffswitch-checkbox:checked + .onoffswitch-label:before { right: 0px; }.layui-timeline { padding-left: 5px;}.layui-timeline-item { position: relative; padding-bottom: 20px;}li { list-style: none;}.layui-timeline-item:first-child::before { display: block;}.layui-timeline-item:last-child::before { content: ''; position: absolute; left: 5px; top: 0; z-index: 0; width: 0; height: 100%;}.layui-timeline-item::before { content: ''; position: absolute; left: 5px; top: 0; z-index: 0; width: 1px; height: 100%;}.layui-timeline-item::before,hr { background-color: #e6e6e6;}.layui-timeline-axis { position: absolute; left: -5px; top: 0; z-index: 10; width: 20px; height: 20px; line-height: 20px; background-color: #fff; color: #5FB878; border-radius: 50%; text-align: center; cursor: pointer;}.layui-icon { font-family: layui-icon !important; font-size: 16px; font-style: normal;}.layui-timeline-content { padding-left: 25px;}.layui-text { line-height: 22px; font-size: 14px; color: rgb(85,85,85);}.layui-timeline-title { position: relative;} `)); document.head.appendChild(style); } (function() { initRouter(window.location.href); })(); // 全局变量及公共函数 var exTimer = 0; // 总时钟句柄 var url = document.getElementsByTagName('html')[0].innerHTML; var urlLen = ("$ROOM.room_id =").length; var ridPos = url.indexOf('$ROOM.room_id ='); var rid = url.substring(ridPos + urlLen, url.indexOf(';', ridPos + urlLen)); rid = rid.trim(); url = null; urlLen = null; ridPos = null; var my_uid = getCookieValue("acf_uid"); // 自己的uid var dyToken = getToken(); function showExPanel() { // 显示功能条 let a = document.getElementsByClassName("ex-panel")[0]; if (a.style.display != "block") { a.style.display = "block"; } else { a.style.display = "none"; } } function sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)); } function formatSeconds(value) { let secondTime = parseInt(value); let minuteTime = 0; let hourTime = 0; if (secondTime > 60) { minuteTime = parseInt(secondTime / 60); secondTime = parseInt(secondTime % 60); if (minuteTime > 60) { hourTime = parseInt(minuteTime / 60); minuteTime = parseInt(minuteTime % 60); } } let result = "" + parseInt(secondTime) + "秒"; if (minuteTime > 0) { result = "" + parseInt(minuteTime) + "分" + result; } if (hourTime > 0) { result = "" + parseInt(hourTime) + "小时" + result; } return result; } async function verifyFans(room_id, level) { return true; // 2020年12月22日18:28:18 let ret = false; let doc = await fetch('https://www.douyu.com/member/cp/getFansBadgeList',{ method: 'GET', mode: 'no-cors', cache: 'default', credentials: 'include', }).then(res => { return res.text(); }).catch(err => { console.log("请求失败!", err); }) doc = (new DOMParser()).parseFromString(doc, 'text/html'); let a = doc.getElementsByClassName("fans-badge-list")[0].lastElementChild; let n = a.children.length; for (let i = 0; i < n; i++) { let rid = a.children[i].getAttribute("data-fans-room"); let rlv = a.children[i].getAttribute("data-fans-level"); if (rid == room_id && rlv >= level) { ret = true; break; } else { ret = false; } } return ret; } function getStrMiddle(str, before, after) { let m = str.match(new RegExp(before + '(.*?)' + after)); return m ? m[1] : false; } function getToken() { // let cookie = document.cookie; // let ret = getStrMiddle(cookie, "acf_uid=", ";") + "_" + getStrMiddle(cookie, "acf_biz=", ";") + "_" + getStrMiddle(cookie, "acf_stk=", ";") + "_" + getStrMiddle(cookie, "acf_ct=", ";") + "_" + getStrMiddle(cookie, "acf_ltkid=", ";"); let ret = getCookieValue("acf_uid") + "_" + getCookieValue("acf_biz") + "_" + getCookieValue("acf_stk") + "_" + getCookieValue("acf_ct") + "_" + getCookieValue("acf_ltkid"); return ret; } function getDyDid() { // let cookie = document.cookie; // let ret = getStrMiddle(cookie, "dy_did=", ";"); let ret = getCookieValue("dy_did"); return ret; } function setCookie(cookiename, value){ let exp = new Date(); exp.setTime(exp.getTime() + 3*60*60*1000); document.cookie = cookiename + "="+ escape (value) + "; path=/; expires=" + exp.toGMTString(); } function getCookieValue(name){    let arr,reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");     if (arr = document.cookie.match(reg)) {         return unescape(arr[2]);     } else {         return null;     } } function getCCN() { // let cookie = document.cookie; // let ret = getStrMiddle(cookie, "acf_ccn=", ";"); let ret = getCookieValue("acf_ccn"); if (ret == null) { setCookie("acf_ccn", "1"); ret = "1"; } return ret; } function getCTN() { // let cookie = document.cookie; // let ret = getStrMiddle(cookie, "acf_ccn=", ";"); let ret = getCookieValue("acf_ctn"); if (ret == null) { setCookie("acf_ctn", "1"); ret = "1"; } return ret; } function getUID() { let ret = getCookieValue("acf_uid"); return ret; } function showMessage(msg, type) { // type: success[green] error[red] warning[orange] info[blue] new NoticeJs({ text: msg, type: type, position: 'bottomRight', }).show(); } function openPage(url, b) { GM_openInTab(url, { active: b }); } function closePage() { if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") != -1) { window.location.href = "about:blank"; window.close(); } else { window.opener = null; window.open("", "_self"); window.close(); } } function getQueryString(name) { let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); if (window.location.hash.indexOf("?") < 0) { return null; } let r = window.location.hash.split("?")[1].match(reg); if (r != null) return decodeURIComponent(r[2]); return null; } function dateFormat(fmt, date) { let o = { "M+": date.getMonth() + 1, "d+": date.getDate(), "h+": date.getHours(), "m+": date.getMinutes(), "s+": date.getSeconds(), "q+": Math.floor((date.getMonth() + 3) / 3), "S": date.getMilliseconds() }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); for (let k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; } function getRandom(min, max) { return Math.floor(Math.random() * (max - min) + min); } function isRid(str) { if (/^[0-9]+$/.test(str)) { return true; } else { return false; } } function getAvailableSheet(index) { let ret = -1; for (let i = index; i < document.styleSheets.length - index; i++) { if (document.styleSheets[i].href == null) { ret = i; break; } else { ret = -1; } } return ret; } function showMessageWindow(title, content, callback){ if(window.Notification && Notification.permission !== "denied") { Notification.requestPermission(function(status) { var notice_ = new Notification(title, { body: content }); notice_.onclick = function() { callback(); } }); } } function getUserName() { return new Promise(resovle => { fetch('https://www.douyu.com/member/cp',{ method: 'GET', mode: 'no-cors', credentials: 'include', }).then(res => { return res.text(); }).then(txt => { txt = (new DOMParser()).parseFromString(txt, 'text/html'); let ret = txt.getElementsByClassName("uname_con")[0].title; resovle(ret); }).catch(err => { console.error('请求失败', err); }) }) } function initPkg_AdVideo() { initPkg_Sign_Ad_FishPond(); } function initPkg_AdVideo_Xiaoxiaole() { startGetXiaoxiaoleFishBall(); } async function startGetXiaoxiaoleFishBall() { let status = await getXiaoxiaoleStatus(); if (status.error == "0") { let completeNum = Number(status.data['20201021xiaoxiaole_T1'].curCompleteNum); let limitNum = Number(status.data['20201021xiaoxiaole_T1'].taskLimitNum); let leftNum = limitNum - completeNum; if (leftNum > 0) { showMessage(`【消消乐】开始领取鱼丸,剩余${leftNum}次`, "info") } for (let i = 0; i < leftNum; i++) { await getFishBall_Xiaoxiaole(); } } } async function getFishBall_Xiaoxiaole() { let adWatchcer = new DyWacthAd("1134396", dyToken, rid); let isStart = await adWatchcer.start(); if (isStart == true) { await sleep(15000).then(async () => { let isFinish = await adWatchcer.finish(); if (isFinish == true) { showMessage("【消消乐】成功领取40鱼丸", "success"); } }) } } function getXiaoxiaoleStatus() { return new Promise(resolve => { fetch("https://www.douyu.com/japi/carnival/nc/actTask/userStatus", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: `tasks=20201021xiaoxiaole_T1&token=${dyToken}` }).then(res => { return res.json(); }).then(ret => { resolve(ret); }).catch(err => { console.log("请求失败!", err); }) }) } function initPkg_Sign_Ad_FishPond() { getFishBall_Ad_FishPond(); } function getFishBall_Ad_FishPond() { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/tasksys/ytxb/userStatusV3?client_sys=android", data: "roomId=" + rid + "&token=" + dyToken, responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded" }, onload: async function(response) { let ret = response.response.data.taskList; for (let i = 0; i < ret.length; i++) { if (ret[i].task.id == "182") { if (ret[i].task.status == "3") { // showMessage("【鱼塘鱼丸】已领取", "warning"); // initPkg_Sign_Ad_666(); initPkg_Sign_Ad_Yuba(); } else { let posid_Ad_FishPond = "1114268"; let token = dyToken; let uid = getUID(); let info = await getFishBall_Ad_FishPond_info(posid_Ad_FishPond, token, uid); if (info == false) { // initPkg_Sign_Ad_666(); initPkg_Sign_Ad_Yuba(); return; } let mid = info.mid; let infoBack = info.infoBack; let isStart = await getFishBall_Ad_FishPond_start(posid_Ad_FishPond, token, uid, mid, infoBack); if (isStart == false) { isStart = await getFishBall_Ad_FishPond_start(posid_Ad_FishPond, token, uid, mid, infoBack); if (isStart == false) { isStart = await getFishBall_Ad_FishPond_start(posid_Ad_FishPond, token, uid, mid, infoBack); // 偷个懒,直接三次重试 } } if (isStart == true) { showMessage("【鱼塘鱼丸】开始领取鱼塘鱼丸,需等待15秒", "info"); await sleep(15555).then(async () => { let isFinish = await getFishBall_Ad_FishPond_finish(posid_Ad_FishPond, token, uid, mid, infoBack); if (isFinish == false) { isFinish = await getFishBall_Ad_FishPond_finish(posid_Ad_FishPond, token, uid, mid, infoBack); if (isFinish == false) { isFinish = await getFishBall_Ad_FishPond_finish(posid_Ad_FishPond, token, uid, mid, infoBack); } } if (isFinish == true) { let isGet = await getFishBall_Ad_FishPond_Bubble(token); } }) } // initPkg_Sign_Ad_666(); initPkg_Sign_Ad_Yuba(); } } } } }); } function getFishBall_Ad_FishPond_info(posid_Ad_FishPond, token, uid) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://rtbapi.douyucdn.cn/japi/sign/app/getinfo?token=" + token + "&mdid=phone" + "&client_sys=android", data: "posid=" + posid_Ad_FishPond + "&roomid=" + rid + "&cate1=1&cate2=1&chanid=30" + '&device={"nt":"1"}', responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { if (ret.data.length == 0) { resolve(false); return; } let mid = ret.data[0].mid; let infoBack = encodeURIComponent(JSON.stringify(ret.data)); resolve({mid: mid, infoBack: infoBack}); } } }); }) } function getFishBall_Ad_FishPond_start(posid_Ad_FishPond, token, uid, mid, infoBack) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/start?client_sys=android", data: "token=" + token + "&uid=" + uid + "&roomId=" + rid + "&posCode=" + posid_Ad_FishPond + "&clientType=1&creativeId=" + mid + "&infoBack=" + infoBack, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { resolve(true); } } }); }) } function getFishBall_Ad_FishPond_finish(posid_Ad_FishPond, token, uid, mid, infoBack) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/finish?client_sys=android", data: "uid=" + uid + "&clientType=1&posCode=" + posid_Ad_FishPond + "&creativeId=" + mid + "&roomId=" + rid + "&token=" + token + "&infoBack=" + infoBack, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { resolve(true); } } }); }) } function getFishBall_Ad_FishPond_Bubble(token) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/tasksys/ytxb/getPrize?client_sys=android", data: "token=" + token + "&id=182", responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { showMessage("【鱼塘鱼丸】" + ret.data.msg, "success"); } else { showMessage("【鱼塘鱼丸】" + ret.msg, "error"); } resolve(ret.error); } }); }) } function initPkg_Sign_Ad_Guess() { getFishBall_Ad_Guess(); } async function getFishBall_Ad_Guess() { let chance = await getFishBall_Ad_Guess_chance(); if (chance > 0) { for (let i = 0; i < chance; i++) { let adWatcher = new DyWacthAd("1114337", dyToken, rid); let isStart = await adWatcher.start(); if (isStart == true) { showMessage("【预言鱼丸】开始领取预言鱼丸,需等待15秒", "info"); await sleep(15555).then(async () => { if (await adWatcher.finish() == true) { showMessage("【预言鱼丸】成功领取40鱼丸", "success"); } await sleep(1000); }) } } } else { // showMessage("【预言鱼丸】今日次数已用完", "warning"); } initPkg_AdVideo_Xiaoxiaole(); } function getFishBall_Ad_Guess_chance() { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/chance?client_sys=android", data: "token=" + dyToken + "&uid=" + getUID() + "&posCode=1114337&clientType=1", responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: async function(response) { let ret = response.response; if (ret.error == "0") { let chance = ret.data.chanceNum; resolve(chance); } else { resolve(0); } } }); }) } function initPkg_Sign_Ad_Search() { getFishBall_Ad_Search(); } function getFishBall_Ad_Search() { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/chance?client_sys=android", data: "token=" + dyToken + "&uid=" + getUID() + "&posCode=1124343&clientType=1", responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: async function(response) { let ret = response.response; if (ret.error == "0") { let chance = ret.data.chanceNum; if (chance > 0) { for (let i = 0; i < chance; i++) { let posid_Ad_Search = "1124343"; let token = dyToken; let uid = getUID(); let info = await getFishBall_Ad_Search_info(posid_Ad_Search, token, uid); if (info == false) { initPkg_Sign_Ad_Guess(); return; } let mid = info.mid; let infoBack = info.infoBack; let isStart = await getFishBall_Ad_Search_start(posid_Ad_Search, token, uid, mid, infoBack); if (isStart == true) { showMessage("【搜索鱼丸】开始领取搜索鱼丸,需等待15秒", "info"); await sleep(15555).then(async () => { let isFinish = await getFishBall_Ad_Search_finish(posid_Ad_Search, token, uid, mid, infoBack); if (isFinish == true) { showMessage("【搜索鱼丸】成功领取40鱼丸", "success"); await sleep(1000); } }) } } } else { // showMessage("【搜索鱼丸】今日次数已用完", "warning"); initPkg_Sign_Ad_Guess(); return; } } initPkg_Sign_Ad_Guess(); } }); } function getFishBall_Ad_Search_info(posid_Ad_Search, token, uid) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://rtbapi.douyucdn.cn/japi/sign/app/getinfo?token=" + token + "&mdid=phone" + "&client_sys=android", data: "posid=" + posid_Ad_Search + "&roomid=" + rid + "&cate1=1&cate2=1&chanid=30" + '&device={"nt":"1"}', responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { if (ret.data.length == 0) { resolve(false); return; } let mid = ret.data[0].mid; let infoBack = encodeURIComponent(JSON.stringify(ret.data)); resolve({mid: mid, infoBack: infoBack}); } } }); }) } function getFishBall_Ad_Search_start(posid_Ad_Search, token, uid, mid, infoBack) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/start?client_sys=android", data: "token=" + token + "&uid=" + uid + "&roomId=" + rid + "&posCode=" + posid_Ad_Search + "&clientType=1&creativeId=" + mid + "&infoBack=" + infoBack, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { resolve(true); } } }); }) } function getFishBall_Ad_Search_finish(posid_Ad_Search, token, uid, mid, infoBack) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/finish?client_sys=android", data: "uid=" + uid + "&clientType=1&posCode=" + posid_Ad_Search + "&creativeId=" + mid + "&roomId=" + rid + "&token=" + token + "&infoBack=" + infoBack, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { if (ret.data == "1") { resolve(true); } } } }); }) } function initPkg_Sign_Ad_Yuba() { getFishBall_Ad_Yuba(); } function getFishBall_Ad_Yuba() { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/chance?client_sys=android", data: "token=" + dyToken + "&uid=" + getUID() + "&posCode=1042329&clientType=1", responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: async function(response) { let ret = response.response; if (ret.error == "0") { let chance = ret.data.chanceNum; if (chance > 0) { for (let i = 0; i < chance; i++) { let posid_Ad_Yuba = "1042329"; let token = dyToken; let uid = getUID(); let info = await getFishBall_Ad_Yuba_info(posid_Ad_Yuba, token, uid); if (info == false) { initPkg_Sign_Ad_Search(); return; } let mid = info.mid; let infoBack = info.infoBack; let isStart = await getFishBall_Ad_Yuba_start(posid_Ad_Yuba, token, uid, mid, infoBack); if (isStart == true) { showMessage("【鱼吧鱼丸】开始领取鱼吧鱼丸,需等待15秒", "info"); await sleep(15555).then(async () => { let isFinish = await getFishBall_Ad_Yuba_finish(posid_Ad_Yuba, token, uid, mid, infoBack); if (isFinish == true) { showMessage("【鱼吧鱼丸】成功领取40鱼丸", "success"); await sleep(1000); } }) } } } else { // showMessage("【鱼吧鱼丸】今日次数已用完", "warning"); initPkg_Sign_Ad_Search(); return; } } initPkg_Sign_Ad_Search(); } }); } function getFishBall_Ad_Yuba_info(posid_Ad_Yuba, token, uid) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://rtbapi.douyucdn.cn/japi/sign/app/getinfo?token=" + token + "&mdid=phone" + "&client_sys=android", data: "posid=" + posid_Ad_Yuba + "&roomid=" + rid + "&cate1=1&cate2=1&chanid=30" + '&device={"nt":"1"}', responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { if (ret.data.length == 0) { resolve(false); return; } let mid = ret.data[0].mid; let infoBack = encodeURIComponent(JSON.stringify(ret.data)); resolve({mid: mid, infoBack: infoBack}); } } }); }) } function getFishBall_Ad_Yuba_start(posid_Ad_Yuba, token, uid, mid, infoBack) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/start?client_sys=android", data: "token=" + token + "&uid=" + uid + "&roomId=" + rid + "&posCode=" + posid_Ad_Yuba + "&clientType=1&creativeId=" + mid + "&infoBack=" + infoBack, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { resolve(true); } } }); }) } function getFishBall_Ad_Yuba_finish(posid_Ad_Yuba, token, uid, mid, infoBack) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/finish?client_sys=android", data: "uid=" + uid + "&clientType=1&posCode=" + posid_Ad_Yuba + "&creativeId=" + mid + "&roomId=" + rid + "&token=" + token + "&infoBack=" + infoBack, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { if (ret.data == "1") { resolve(true); } } } }); }) } let timeout; function initPkg_BagInfo() { initPkg_BagInfo_Func(); } function initPkg_BagInfo_Func() { document.getElementsByClassName("BackpackButton")[0].addEventListener("click", function() { clearTimeout(timeout); timeout = setTimeout(() => { if (document.getElementsByClassName("Backpack JS_Backpack").length > 0) { getBagGifts(rid, (ret) => { let chunkNum = ret.data.list.length; if (chunkNum > 0) { let totalPrice = 0; let totalIntimate = 0; for (let i = 0; i < chunkNum; i++) { let chunk = document.getElementsByClassName("Backpack-prop")[i]; let isValuable = ret.data.list[i].isValuable; // 判断是否是有价值的礼物 let expiry = ret.data.list[i].expiry; // 过期时间 let price = ret.data.list[i].price; // 注意这个要除100才是真实价格,否则是亲密度 let intimate = ret.data.list[i].intimate; // 亲密度 let count = ret.data.list[i].count; // 数量 if (isValuable == "1") { totalPrice = totalPrice + Number(price) * Number(count); } totalIntimate = totalIntimate + Number(intimate) * Number(count); let expiryDiv = document.createElement("div"); expiryDiv.className = "bag-info"; expiryDiv.innerHTML = expiry; chunk.insertBefore(expiryDiv, chunk.childNodes[0]); } document.getElementsByClassName("Backpack-space")[0].innerText = "总价值:" + String(Number(totalPrice / 100).toFixed(2)) + " 总亲密度:" + String(totalIntimate); let a = document.getElementsByClassName("Backpack-title")[0]; let b = document.createElement("div"); b.className = "bag-button"; b.id = "Backpack__clearbag"; b.innerText = "清空背包"; a.appendChild(b); document.getElementById("Backpack__clearbag").addEventListener("click", () => { if (confirm("确认清空?") != true) { return; } showMessage("【清空背包】执行中...", "info"); getBagGifts(rid, (ret) => { clearBagGifts(ret, rid); }) }) } }); } }, 500); }); } async function clearBagGifts(bagGiftsJson, room_id) { // 赠送背包内所有的礼物 let chunkNum = bagGiftsJson.data.list.length; if (chunkNum > 0) { for (let i = 0; i < chunkNum; i++) { let gift_id = bagGiftsJson.data.list[i].id; let gift_cnt = bagGiftsJson.data.list[i].count; if (Object.keys(bagGiftsJson.data.list[i].batchInfo).length > 0) { await sleep(100).then(() => { sendGift_bag(gift_id, gift_cnt, room_id); }) } else { for (let j = 0; j < gift_cnt; j++) { await sleep(100).then(() => { sendGift_bag(gift_id, 1, room_id); }) } } } showMessage("【清空背包】执行完毕!", "success"); } else { showMessage("背包礼物为空", "error"); } } let barrageColorArr = []; let barrageArr = []; let barrageColorLength = 0; let barrageLength = 0; let bloopTimer; let barrageOffset = 0; let barrageColorOffset = 0; let isChangeColor = true; let isMatch = false; //是否为赛事直播间 let bloopStopTimer; function initPkg_BarrageLoop() { initPkg_BarrageLoop_Dom(); initPkg_BarrageLoop_Func(); initPkg_BarrageLoop_Set(); } function BarrageLoop_insertModal() { let html = ""; let a = document.createElement("div"); a.className = "bloop"; html += '
'; html += '
'; html += ''; html += '
~
'; html += '
'; html += '
'; html += '
'; a.innerHTML = html; let b = document.getElementsByClassName("layout-Player-chat")[0]; b.insertBefore(a, b.childNodes[0]); } function BarrageLoop_insertIcon() { let a = document.createElement("div"); a.className = "bloop-icon"; a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function getBarrageColorArr() { // 获取已解锁的弹幕颜色 barrageColorArr.length = 0;// 清空数组 barrageColorLength = 0; let a = document.getElementsByClassName("FansBarrageSwitcher"); let nobleIcon = document.getElementsByClassName("NobleBarrageSwitcher is-active"); let isNoble = false; if (nobleIcon.length > 0) { isNoble = true; } if (a.length == 0) { isMatch = true; let b = document.getElementsByClassName("MatchSystemFansBarrageSwitcher")[0]; if (b != undefined) { b.click(); a = document.getElementsByClassName("MatchSystemFansBarrageColor-item"); } else { isMatch = false; } } else { a[0].click(); a = document.getElementsByClassName("FansBarrageColor-item"); isMatch = false; } for (let i = 0; i < a.length; i++) { let itemClassName = a[i].className; if (itemClassName.indexOf("is-lock") == -1) { barrageColorArr.push(i); barrageColorLength++; } } barrageColorLength = barrageColorLength - 1; if (isNoble == true) { document.getElementsByClassName("NobleBarrageSwitcher")[0].click(); } } function getBarrageArr() { // 获取即将发送的弹幕数组 barrageArr.length = 0; barrageLength = 0; let a = document.getElementById("bloop__textarea").value; barrageArr = a.split("\n"); barrageLength = barrageArr.length - 1; } function selectBarrageColor(index) { // 选择粉丝弹幕 let a; if (isMatch == false) { document.getElementsByClassName("FansBarrageSwitcher")[0].click(); a = document.getElementsByClassName("FansBarrageColor-item")[index]; } else{ document.getElementsByClassName("MatchSystemFansBarrageSwitcher")[0].click(); a = document.getElementsByClassName("MatchSystemFansBarrageColor-item")[index]; } if (a != undefined) { a.click(); } } function sendBarrage(text) { // 发送弹幕 document.getElementsByClassName("ChatSend-txt")[0].value = text; document.getElementsByClassName("ChatSend-button")[0].click(); } function getSpeed() { let min = document.getElementById("bloop__text_speed1").value; let max = document.getElementById("bloop__text_speed2").value; let ret = getRandom(Number(min), Number(max)); return ret; } function saveData_BarrageLoop() { let speed1 = document.getElementById("bloop__text_speed1").value; let speed2 = document.getElementById("bloop__text_speed2").value; let stopTime = document.getElementById("bloop__text_stoptime").value; let tiangouMode = document.getElementById("bloop__checkbox_tiangou").checked; if (speed1 == "undefined") { speed1 = 2000; } if (speed2 == "undefined") { speed2 = 3000; } if (stopTime == "undefined") { stopTime = 5; } let data = { text: document.getElementById("bloop__textarea").value, speed1: speed1, speed2: speed2, stopTime: stopTime, isChangeColor: isChangeColor, isTiangouMode: tiangouMode, } localStorage.setItem("ExSave_BarrageLoop", JSON.stringify(data)); // 存储弹幕列表 } function getStopTime() { let a = document.getElementById("bloop__text_stoptime").value; return Number(a) * 60 * 1000; } async function doLoopBarrage() { if (isChangeColor == true) { selectBarrageColor(barrageColorOffset); barrageColorOffset++; if (barrageColorOffset > barrageColorLength) { barrageColorOffset = 0; } } if (document.getElementById("bloop__checkbox_tiangou").checked == true) { let tiangouBarrage = await getBarrageTxt_Tiangou(); tiangouBarrage = String(tiangouBarrage).replace(/他/g,"她"); sendBarrage(tiangouBarrage); } else { sendBarrage(barrageArr[barrageOffset]); barrageOffset++; if (barrageOffset > barrageLength) { barrageOffset = 0; } } bloopTimer = setTimeout(doLoopBarrage, getSpeed()); } function initPkg_BarrageLoop_Func() { // 函数初始化 // 将onclick事件绑定在这里 document.getElementsByClassName("bloop-icon")[0].addEventListener("click", function() { let a = document.getElementsByClassName("bloop")[0]; if (a.style.display != "block") { a.style.display = "block"; if (document.getElementsByClassName("extool")[0].style.display == "block") { document.getElementsByClassName("extool")[0].style.display = "none"; } if (document.getElementsByClassName("livetool")[0].style.display == "block") { document.getElementsByClassName("livetool")[0].style.display = "none"; } } else { a.style.display = "none"; } }); document.getElementById("bloop__checkbox_changeColor").addEventListener("click", function() { isChangeColor = document.getElementById("bloop__checkbox_changeColor").checked; }); document.getElementById("bloop__checkbox_startSend").addEventListener("click", function() { let ischecked = document.getElementById("bloop__checkbox_startSend").checked; if (ischecked == true) { // 开始发送 barrageOffset = 0; barrageColorOffset = 0; getBarrageArr(); getBarrageColorArr(); saveData_BarrageLoop(); bloopTimer = setTimeout(doLoopBarrage, getSpeed()); bloopStopTimer = setTimeout(() => { document.getElementById("bloop__checkbox_startSend").checked = false; clearTimeout(bloopTimer); }, getStopTime()); } else{ // 停止发送 clearTimeout(bloopTimer); clearTimeout(bloopStopTimer); // clearInterval(bloopTimer); } }); document.getElementById("bloop__checkbox_tiangou").addEventListener("click", function() { let ischecked = document.getElementById("bloop__checkbox_tiangou").checked; if (ischecked == true) { // 开启舔狗模式 document.getElementById("bloop__textarea").disabled = true; } else{ // 关闭舔狗模式 document.getElementById("bloop__textarea").disabled = false; } saveData_BarrageLoop(); }); } function initPkg_BarrageLoop_Dom() { // Dom初始化 BarrageLoop_insertModal(); BarrageLoop_insertIcon(); } function initPkg_BarrageLoop_Set() { // 设置初始化 let ret = localStorage.getItem("ExSave_BarrageLoop"); if (ret != null) { let retJson = JSON.parse(ret); if ("speed1" in retJson == false) { retJson.speed1 = 2000; } if ("speed2" in retJson == false) { retJson.speed2 = 3000; } if ("stopTime" in retJson == false) { retJson.stopTime = 5; } if ("isTiangouMode" in retJson == false) { retJson.isTiangouMode = false; } document.getElementById("bloop__textarea").value = retJson.text; document.getElementById("bloop__checkbox_changeColor").checked = retJson.isChangeColor; isChangeColor = Boolean(retJson.isChangeColor); document.getElementById("bloop__text_speed1").value = retJson.speed1; document.getElementById("bloop__text_speed2").value = retJson.speed2; document.getElementById("bloop__text_stoptime").value = retJson.stopTime; if (retJson.isTiangouMode == true) { document.getElementById("bloop__checkbox_tiangou").checked = retJson.isTiangouMode; document.getElementById("bloop__textarea").disabled = true; } } } function getBarrageTxt_Tiangou() { return new Promise(resolve => { GM_xmlhttpRequest({ method: "GET", url: "https://chp.shadiao.app/api.php", responseType: "text", onload: function(response) { let ret = response.response; if (ret != "") { resolve(ret); } } }); }) } function initPkg_BarragePanel() { let timer = setInterval(() => { if (document.getElementsByClassName("danmuTips-1ee820").length > 0) { clearInterval(timer); document.getElementsByClassName("danmuTips-1ee820")[0].parentElement.id = "Ex_BarragePanel"; setBarragePanelCallBack(); } }, 1500); initPkg_BarragePanel_Tip(); } function setBarragePanelCallBack() { let a = new DomHook("#Ex_BarragePanel", true, (m) => { let isAttributes = false; if (m.length > 0) { for (let i = 0; i < m.length; i++) { if (m[i].type == "attributes") { isAttributes = true; break; } } if (isAttributes == false) { let addedNodes = m[0].addedNodes; if (addedNodes.length > 0) { let barragePanel = addedNodes[0]; if ("getElementsByClassName" in barragePanel == false) { return; } let userNameDom = barragePanel.getElementsByClassName("danmuAuthor-3d7b4a"); let id = ""; if (userNameDom.length > 0) { id = userNameDom[0].innerText; setUserFansMedal(userNameDom[0], id); setMuteButton(barragePanel); setSearchBarrageButton(barragePanel); setMuteTimeButton(barragePanel); setReplyBarrageButton(barragePanel); setBarrgePanelFunc(barragePanel, id); } } } else { let tmp = document.getElementsByClassName("barragePanel__funcPanel"); if (tmp.length > 0) { tmp[0].remove(); } let barragePanel = document.getElementsByClassName("danmudiv-32f498")[0]; let userNameDom = barragePanel.getElementsByClassName("danmuAuthor-3d7b4a"); let id = ""; if (userNameDom.length > 0) { id = userNameDom[0].innerText; setUserFansMedal(userNameDom[0], id); setMuteButton(barragePanel); setSearchBarrageButton(barragePanel); setMuteTimeButton(barragePanel); setReplyBarrageButton(barragePanel); setBarrgePanelFunc(barragePanel, id); } } } }); } function getUserFansMedal(userName) { let ret = false; let barrageList = document.getElementsByClassName("Barrage-listItem"); for (let i = barrageList.length - 1; i >= 0; i--) { let barragePanel = barrageList[i].lastElementChild; if (barragePanel != null && barragePanel != undefined && barragePanel.innerHTML.indexOf(userName) != -1) { let fansElement = barragePanel.getElementsByClassName("FansMedal"); if (fansElement.length > 0) { ret = fansElement[0].cloneNode(true); break; } } } return ret; } function getUserLevelText(userName) { let ret = ""; let barrageList = document.getElementsByClassName("Barrage-listItem"); for (let i = barrageList.length - 1; i >= 0; i--) { let barragePanel = barrageList[i].lastElementChild; if (barragePanel != null && barragePanel != undefined && barragePanel.innerHTML.indexOf(userName) != -1) { let roomAdmin = barragePanel.getElementsByClassName("Barrage-icon--roomAdmin"); if (roomAdmin.length > 0) { ret += "【房管】"; } let noble = barragePanel.getElementsByClassName("Barrage-nobleImg"); if (noble.length > 0) { ret += `【${ noble[0].title }】`; } let level = barragePanel.getElementsByClassName("UserLevel"); if (level.length > 0) { ret += level[0].title; } break; } } return ret; } function setUserFansMedal(dom, userName) { if (document.getElementById("barragePanel__id") == undefined) { dom.removeChild(dom.childNodes[0]); let userLevel = getUserLevelText(userName); let a = document.createElement("span"); a.innerHTML = userName; a.title = userLevel; a.id = "barragePanel__id"; dom.insertBefore(a, dom.childNodes[0]); } let fansMedal = getUserFansMedal(userName); if (fansMedal != false) { a = document.createElement("div"); a.style = "display:inline-block"; a.appendChild(fansMedal); dom.insertBefore(a, dom.childNodes[0]); } } function setMuteButton(dom) { if (document.getElementById("barragePanel__mute") != null) { return; } let a = document.createElement("div"); a.className = "ReportButton-41fa9e"; a.id = "barragePanel__mute"; a.innerText = "禁言"; a.style = "margin-top:120px;z-index:5"; dom.insertBefore(a, dom.childNodes[0]); } function setSearchBarrageButton(dom) { if (document.getElementById("barragePanel__search") != null) { return; } let a = document.createElement("div"); a.className = "HideButton-d22988"; a.innerText = "查弹幕"; a.id = "barragePanel__search"; a.style = "margin-top:120px;z-index:5"; dom.insertBefore(a, dom.childNodes[0]); } function setReplyBarrageButton(dom) { if (document.getElementById("barragePanel__reply") != null) { return; } let a = document.createElement("div"); a.className = "HideButton-d22988"; a.innerText = "回复"; a.id = "barragePanel__reply"; a.style = "margin-top:90px;z-index:5"; dom.insertBefore(a, dom.childNodes[0]); } function setMuteTimeButton(dom) { if (document.getElementsByClassName("barragePanel__muteTime").length > 0) { return; } let a = document.createElement("div"); a.className = "barragePanel__muteTime"; a.innerHTML = ` `; dom.insertBefore(a, dom.childNodes[0]); } function setBarrgePanelFunc(parentDom, id) { document.getElementById("barragePanel__reply").onclick = () => { let txt = parentDom.getElementsByClassName("danmuContent-25f266")[0].innerText; if (txt != "") { document.getElementsByClassName("ChatSend-txt")[0].value = `@${ id }:${ txt }`; } }; document.getElementById("barragePanel__mute").onclick = async () => { let value = document.getElementById("barragePanel__muteSelect").value || "1"; let ret = await addMuteUser(rid, id, value); if (ret.msg == "添加成功") { showMessage(`【禁言】${id}已被禁言${value}分钟`, "success"); } else { showMessage(ret.msg, "error"); } }; document.getElementById("barragePanel__search").onclick = async () => { insertBarragePanel_SearchBarrage_Dom(parentDom); barragePanelLastName = id; let ret = await getUserRecentBarrage(id); let retJson = JSON.parse(ret.data); let panel = document.getElementById("barragePanel__searchPanel"); if(retJson.msg == "成功") { if ("danmuVoList" in retJson.data == false) { return; } for (let i = 0; i < retJson.data.danmuVoList.length; i++) { let item = retJson.data.danmuVoList[i]; let a = document.createElement("li"); a.className = "layui-timeline-item"; a.innerHTML = `

${item.time}

${item.anchorName}:
${item.txt}

`; if (panel != null || panel != undefined) { panel.appendChild(a); } } let end = document.createElement("li"); end.className = "layui-timeline-item"; end.innerHTML = `
`; if (panel != null || panel != undefined) { panel.appendChild(end); } } else { showMessage("【查弹幕】查询失败", "error"); } }; } function insertBarragePanel_SearchBarrage_Dom(parentDom) { let pMarginLeft = parseInt(parentDom.style.marginLeft); let newMarginLeft = "-237px"; if (pMarginLeft > 237) { newMarginLeft = "-237px"; } else { newMarginLeft = "237px"; } let a = document.createElement("div"); a.className = "barragePanel__funcPanel"; a.style = `margin-left:${newMarginLeft}`; a.innerHTML = ` `; parentDom.insertBefore(a, parentDom.childNodes[0]); } function getUserRecentBarrage(name) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "GET", url: "https://dyapi.fz996.com/api/Wx/GetDataBarrage?keyword=" + name, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; resolve(ret); } }); }); } function initPkg_BarragePanel_Tip() { setBarragePanelTipCallBack(); } function setBarragePanelTipCallBack() { let a = new DomHook("#comment-dzjy-container", false, (m) => { if (m.length <= 0) { return; } if (m[0].addedNodes.length <= 0) { return; } let dom = m[0].addedNodes[0]; renderBarragePanelTip(dom); setBarragePanelTipFunc(); }) } function renderBarragePanelTip(dom) { let a = document.createElement("div"); a.style.display = "inline-block"; document.getElementsByClassName("btnscontainer-4e2ed0")[0].insertBefore(a, dom.childNodes[0]); a = document.createElement("p"); a.className = "sugun-e3fbf6"; a.innerText = "|"; dom.appendChild(a); a = document.createElement("div"); a.className = "labelfisrt-407af4"; a.id = "barrage-panel-tip__+1" a.innerText = "+1"; dom.appendChild(a); } function setBarragePanelTipFunc() { document.getElementById("barrage-panel-tip__+1").onclick = () => { let txt = document.getElementById("comment-higher-container").innerText; sendBarrage(txt); } } function initPkg_Console() { console_watermark_douyEx(); } function console_watermark_douyEx() { return; } function initPkg_CopyRealLive() { initPkg_CopyRealLive_Dom(); initPkg_CopyRealLive_Func(); } function initPkg_CopyRealLive_Dom() { CopyRealLive_insertIcon(); } function CopyRealLive_insertIcon() { let a = document.createElement("div"); a.className = "Title-blockInline"; a.id = "copy-real-live"; a.innerHTML = '
复制直播流
'; let b = document.getElementsByClassName("Title-col")[4]; if (b.childNodes.length > 1) { b.insertBefore(a, b.childNodes[1]); } } function initPkg_CopyRealLive_Func() { document.getElementById("copy-real-live").addEventListener("click", function() { getRealLive_Douyu(rid, false, "777", (lurl) => { if (lurl == "None") { showMessage("房间未开播或其他错误", "error"); } else { GM_setClipboard(String(lurl).replace("https", "http")); showMessage("复制成功", "success"); } }) }); document.getElementsByClassName("Title-header")[0].addEventListener("click", function() { getRealLive_Douyu(rid, false, "777", (lurl) => { if (lurl == "None") { showMessage("房间未开播或其他错误", "error"); } else { GM_setClipboard(String(lurl).replace("https", "http")); showMessage("复制成功", "success"); } }) }); let titNode = document.getElementsByClassName("RecommendViewTit-04ebd8"); let tit = ""; if (titNode.length > 0) { tit = titNode[0].innerText + "\n"; } document.getElementsByClassName("Title-header")[0].style.cursor = "pointer"; document.getElementsByClassName("Title-header")[0].title = tit + "点击复制直播流"; } function initPkg_ExIcon() { initPkg_ExIcon_insertDom(); initPkg_ExIcon_Func(); } function initPkg_ExIcon_insertDom() { let a = document.createElement("div"); a.className = "ex-icon"; a.innerHTML = ''; let b = document.getElementsByClassName("PlayerToolbar-Wealth")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_ExIcon_Func() { document.getElementsByClassName("ex-icon")[0].addEventListener("click", showExPanel); } function ExIcon_showTip(a) { let d = document.getElementById("ex-icon__tip"); if (a == true) { d.style.display = "block"; } else { d.style.display = "none"; } } function initPkg_ExpandTool() { initPkg_ExpandTool_Dom(); initPkg_ExpandTool_Func(); initPkg_ExpandTool_Module(); } function initPkg_ExpandTool_Module() { // initPkg_ExpandTool_RedPacket_Motorcade(); initPkg_ExpandTool_Treasure(); initPkg_ExpandTool_Gold(); initPkg_ExpandTool_RedPacket_Room(); initPkg_ExpandTool_ClearBag(); initPkg_ExpandTool_SendGift(); initPkg_ExpandTool_BarrageSize(); } function initPkg_ExpandTool_Dom() { // Dom初始化 ExpandTool_insertModal(); ExpandTool_insertIcon(); } function ExpandTool_insertModal() { let a = document.createElement("div"); a.className = "extool"; let b = document.getElementsByClassName("layout-Player-chat")[0]; b.insertBefore(a, b.childNodes[0]); } function ExpandTool_insertIcon() { let a = document.createElement("div"); a.className = "extool-icon"; a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_ExpandTool_Func() { // 函数初始化 // 将onclick事件绑定在这里 document.getElementsByClassName("extool-icon")[0].addEventListener("click", function() { let a = document.getElementsByClassName("extool")[0]; if (a.style.display != "block") { a.style.display = "block"; if (document.getElementsByClassName("bloop")[0].style.display == "block") { document.getElementsByClassName("bloop")[0].style.display = "none"; } if (document.getElementsByClassName("livetool")[0].style.display == "block") { document.getElementsByClassName("livetool")[0].style.display = "none"; } } else { a.style.display = "none"; } }); } function initPkg_ExpandTool_BarrageSize() { ExpandTool_BarrageSize_insertDom(); ExpandTool_BarrageSize_insertFunc(); initPkg_ExpandTool_BarrageSize_Set(); setBarrageSize(getBarrageSize()); } function ExpandTool_BarrageSize_insertDom() { let a = document.createElement("div"); a.className = "extool__bsize"; a.innerHTML = ''; let b = document.getElementsByClassName("extool")[0]; b.insertBefore(a, b.childNodes[0]); } function setBarrageSize(s) { cancelBarrageSize(); StyleHook_set("Ex_Style_DanmuSize", ".danmuItem-31f924{font-size:" + s + "px !important;}"); } function cancelBarrageSize() { StyleHook_remove("Ex_Style_DanmuSize"); } function getBarrageSize() { return document.getElementById("extool__bsize_value").value; } function ExpandTool_BarrageSize_insertFunc() { document.getElementById("extool__bsize_btn").addEventListener("click", function() { setBarrageSize(getBarrageSize()); saveData_BarrageSize(); }); } function saveData_BarrageSize() { let data = { size: getBarrageSize() } localStorage.setItem("ExSave_BarrageSize", JSON.stringify(data)); // 存储弹幕列表 } function initPkg_ExpandTool_BarrageSize_Set() { // 设置初始化 let ret = localStorage.getItem("ExSave_BarrageSize"); if (ret != null) { let retJson = JSON.parse(ret); document.getElementById("extool__bsize_value").value = retJson.size; } } function initPkg_ExpandTool_ClearBag() { ExpandTool_ClearBag_insertDom(); ExpandTool_ClearBag_insertFunc(); } function ExpandTool_ClearBag_insertDom() { let html = ""; html += '礼物id示例
'; html += ''; html += ''; html += ''; // html += ''; let a = document.createElement("div"); a.className = "extool__clearbag"; a.innerHTML = html; let b = document.getElementsByClassName("extool")[0]; b.insertBefore(a, b.childNodes[0]); } function ExpandTool_ClearBag_insertFunc() { document.getElementById("extool__clearbag_sendbtn").addEventListener("click", async function() { if (confirm("确认送出?") != true) { return; } let id = document.getElementById("extool__clearbag_id").value; let n = Number(document.getElementById("extool__clearbag_cnt").value); showMessage("【背包送礼】执行中...", "info"); for (let i = 0; i < n; i++) { await sleep(100).then(() => { sendGift_bag(id, 1, rid).then(data => { if (data.msg != "success") { showMessage("【背包送礼】" + rid + "赠送失败 " + data.msg, "error"); console.log(rid, data); } }).catch(err => { showMessage("【背包送礼】" + rid + "赠送失败", "error"); console.log(rid, err); }) }) } showMessage("【背包送礼】执行完毕!", "success"); }); // document.getElementById("extool__clearbag_clearbtn").addEventListener("click", function() { // if (confirm("确认清空?") != true) { // return; // } // showMessage("【清空背包】执行中...", "info"); // getBagGifts(rid, (ret) => { // clearBagGifts(ret, rid); // }) // }); document.getElementById("extool__clearbag_showid").addEventListener("click", function() { getBagGifts(rid, (ret) => { let chunkNum = ret.data.list.length; if (chunkNum > 0) { for (let i = 0; i < chunkNum; i++) { let gift_id = ret.data.list[i].id; let gift_name = ret.data.list[i].name; console.log("【" + gift_name + "】 id:" + gift_id); } showMessage("请按F12到控制台(console)查看背包礼物id", "success"); } else { showMessage("背包礼物为空", "error"); } }); }); } function getBagGifts(room_id, callback) { // 获取背包内所有礼物信息(json),传给回调函数 fetch('https://www.douyu.com/japi/prop/backpack/web/v1?rid=' + room_id, { method: 'GET', mode: 'no-cors', credentials: 'include', headers: {'Content-Type':'application/x-www-form-urlencoded'}, }).then(result => { return result.json(); }).then(ret => { callback(ret); }).catch(err => { console.log("请求失败!", err) }) } let user_name; let animationNum = 0; let goldBarrageHook; let goldBarrageListHook; let goldGiftHook; function initPkg_ExpandTool_Gold() { ExpandTool_Gold_insertDom(); ExpandTool_Gold_insertGiftDom(); ExpandTool_Gold_insertFunc(); ExpandTool_Gold_Set(); } function ExpandTool_Gold_insertDom() { let html = ""; html += ''; html += ''; let a = document.createElement("div"); a.className = "extool__gold"; a.innerHTML = html; let b = document.getElementsByClassName("extool")[0]; b.insertBefore(a, b.childNodes[0]); } function ExpandTool_Gold_insertGiftDom() { let a = document.createElement("div"); a.className = "ex_giftAnimation"; let b = document.getElementsByClassName("Barrage-main")[0]; b.insertBefore(a, b.childNodes[0]); } function ExpandTool_Gold_insertFunc() { document.getElementById("extool__gold_start").addEventListener("click", async function() { let ischecked = document.getElementById("extool__gold_start").checked; if (ischecked == true) { // 开启幻神模式 goldBarrageHook = new DomHook(".danmu-6e95c1", true, goldBarrage); goldBarrageListHook = new DomHook(".Barrage-list", true, goldBarrageList); goldFansMedal(); } else{ // 停止幻神模式 goldBarrageHook.closeHook(); goldBarrageListHook.closeHook(); } saveData_Gold(); }); document.getElementById("extool__goldGift_start").addEventListener("click", async function() { user_name = await getUserName(); let ischecked = document.getElementById("extool__goldGift_start").checked; if (ischecked == true) { goldGiftHook = new DomHook(".BarrageBanner", true, fansToSuperRocket); } else{ goldGiftHook.closeHook(); } saveData_GoldGift(); }); } function saveData_Gold() { let isGold = document.getElementById("extool__gold_start").checked; let data = { isGold: isGold } localStorage.setItem("ExSave_Gold", JSON.stringify(data)); // 存储弹幕列表 } function saveData_GoldGift() { let isGoldGift = document.getElementById("extool__goldGift_start").checked; let data = { isGoldGift: isGoldGift } localStorage.setItem("ExSave_GoldGift", JSON.stringify(data)); // 存储弹幕列表 } function ExpandTool_Gold_Set() { // 设置初始化 let ret = localStorage.getItem("ExSave_Gold"); if (ret != null) { let retJson = JSON.parse(ret); if (retJson.isGold == true) { document.getElementById("extool__gold_start").click(); } } ret = localStorage.getItem("ExSave_GoldGift"); if (ret != null) { let retJson = JSON.parse(ret); if (retJson.isGoldGift == true) { document.getElementById("extool__goldGift_start").click(); } } } function goldBarrageList(m) { if (m.length == 0) { return; } if (m[0].addedNodes.length == 0) { return; } let itemNode = m[0].addedNodes[0]; let chatArea = itemNode.lastElementChild; if (chatArea != null && chatArea.innerHTML.indexOf("is-self") != -1) { let barrageListTimeout = setTimeout(() => { itemNode.className = "Barrage-listItem js-noblefloating-barrage"; chatArea.className = "js-noblefloating-barragecont Barrage-notice--noble"; chatArea.setAttribute('style','background-color: #fff3df'); let nickNameObj = chatArea.getElementsByClassName("Barrage-nickName")[0]; nickNameObj.setAttribute('class','Barrage-nickName is-self js-nick'); let userLevelObj = chatArea.querySelector(".UserLevel"); if( userLevelObj!=null){ userLevelObj.className = "UserLevel UserLevel--150"; userLevelObj.setAttribute("title", "用户等级:150"); } let roomLevelObj = chatArea.querySelector(".RoomLevel"); if( roomLevelObj!=null){ roomLevelObj.className = "RoomLevel RoomLevel--18"; roomLevelObj.setAttribute("title","房间等级:18"); } let fansMedal = itemNode.querySelector(".FansMedal"); if(fansMedal!=null){ fansMedal.style = "display:none;"; } let fansMedalName = document.getElementsByClassName("FansMedal-name")[0];//fans medal let fansBackgroundImg = document.getElementsByClassName("FansRankList-item FansRankList-item--top")[0]; if(fansMedalName!=undefined && fansBackgroundImg!= undefined ){ if(fansBackgroundImg.innerHTML.indexOf("background-image:")==-1){//common fans medal let fansTag = document.createElement("div"); let fansSpan = document.createElement("span"); fansTag.className="FansMedal level-50 js-fans-dysclick Barrage-icon"; // fansTag.setAttribute("data-rid",roomId);//id is same to roomId fansSpan.className = "FansMedal-name js-fans-dysclick"; // fansSpan.setAttribute("data-rid",roomId); fansSpan.innerHTML = fansMedalName.innerText; fansTag.appendChild(fansSpan); chatArea.insertBefore(fansTag,chatArea.querySelector(".UserLevel")); }else{//special fans medal let fansTag1 = document.createElement("div"); fansTag1.className="FansMedal is-made js-fans-dysclick Barrage-icon"; fansTag1.setAttribute("style", fansBackgroundImg.getElementsByClassName("FansMedal is-made")[0].getAttribute("style") ); // fansTag1.setAttribute("data-rid",roomId); let fansSpan1 = document.createElement("span"); fansSpan1.className = "FansMedal-name js-fans-dysclick"; // fansSpan1.setAttribute("data-rid",roomId); fansSpan1.innerHTML = fansMedalName.innerText; fansTag1.appendChild(fansSpan1); chatArea.insertBefore(fansTag1,chatArea.querySelector(".UserLevel")); } }else{//point to a fans medal when room have none of fans medal let fansTag2 = document.createElement("div"); fansTag2.className="FansMedal level-50 js-fans-dysclick Barrage-icon"; fansTag2.setAttribute("data-rid","5189167"); let fansSpan2 = document.createElement("span"); fansSpan2.className = "FansMedal-name js-fans-dysclick"; fansSpan2.setAttribute("data-rid","5189167"); fansSpan2.innerHTML = "歆崽"; fansTag2.appendChild(fansSpan2); chatArea.insertBefore(fansTag2,chatArea.querySelector(".UserLevel")); } let nobleIconObj = itemNode.querySelector(".Barrage-nobleImg"); if(nobleIconObj != null){ nobleIconObj.src = "//res.douyucdn.cn/resource/2019/08/15/common/4e85776071ffbae2867bb9d116e9a43c.gif"; nobleIconObj.title = "幻神" } else { let royalTag = document.createElement("span"); let royalImg = document.createElement("img"); royalTag.className = "Barrage-icon Barrage-noble"; royalImg.className = "Barrage-nobleImg"; royalImg.setAttribute("src", "//res.douyucdn.cn/resource/2019/08/15/common/4e85776071ffbae2867bb9d116e9a43c.gif"); royalImg.setAttribute("title", "幻神"); royalTag.appendChild(royalImg); chatArea.insertBefore(royalTag, chatArea.firstElementChild); } clearTimeout(barrageListTimeout); }, 100); } } function goldFansMedal() { document.getElementsByClassName("FansMedalEnter-enterContent")[0].setAttribute("data-medal-level","50"); } function goldBarrage(m) { if (m.length == 0) { return; } if (m[0].addedNodes.length == 0) { return; } let itemNode = m[0].addedNodes[0]; if(itemNode.className.indexOf("noble-bf13ad")==-1 && itemNode.innerHTML.indexOf("border: 2px solid rgb(2, 255, 255)")!=-1){//find self and remove redupliction itemNode.style.zIndex = "30"; itemNode.className = "danmuItem-31f924 noble-bf13ad"; // itemNode.setAttribute("style",characterStyle); //noble icon without redupliction remove let nobleImgTag = document.createElement("img"); nobleImgTag.className = "super-noble-icon-9aacaf"; nobleImgTag.setAttribute("src","https://shark2.douyucdn.cn/front-publish/live_player-master/assets/images/h1_dcd226.png"); nobleImgTag.setAttribute("style","margin-left: -57px; margin-top: -4px;"); itemNode.insertBefore(nobleImgTag,itemNode.firstElementChild); //user avatar img let userIconTag = document.createElement("img"); userIconTag.className = "super-user-icon-574f31"; let userIconObj = document.getElementsByClassName("Avatar is-circle")[0]; if(userIconObj !=undefined){ userIconObj = userIconObj.getElementsByTagName("img")[0].getAttribute("src"); userIconTag.setAttribute("src", userIconObj.replace((new RegExp("_middle")),"_small")); }else{ // console.error("未能获取到用户头像"); } itemNode.insertBefore(userIconTag,itemNode.firstElementChild); //remove out tail tag let tailTag = itemNode.getElementsByClassName("afterpic-8a2e13")[0]; tailTag.remove(); //transform barrage effect let textContent = itemNode.getElementsByClassName("text-879f3e")[0]; textContent.className = "super-text-0281ca"; textContent.setAttribute("style","font: bold 23px SimHei, 'Microsoft JhengHei', Arial, Helvetica, sans-serif; color: rgb(255, 255, 255); background: url('https://shark2.douyucdn.cn/front-publish/live_player-master/assets/images/h2_8e5e64.png'); height: 44px;"); //add tag tail includes fire icon or sign icon let afterpicTag = document.createElement("div"); afterpicTag.setAttribute("class","afterpic-8a2e13"); afterpicTag.setAttribute("style","margin-top: 7px; margin-left: -1px;");// afterpicTag.setAttribute("style","margin-top: 7px; margin-left: -43px;"); textContent.appendChild(afterpicTag); //tail icon let superTailImg = document.createElement("img"); superTailImg.className = "super-tail-bffa58"; superTailImg.setAttribute("src","https://shark2.douyucdn.cn/front-publish/live_player-master/assets/images/h3_fd2e5b.png"); itemNode.appendChild(superTailImg); } } function fansToSuperRocket(m) { if (m.length == 0) { return; } if (m[0].addedNodes.length == 0) { return; } let dom_gift = m[0].addedNodes[0]; if (dom_gift.getElementsByClassName("Banner4gift-senderName")[0].title == user_name) { let giftName = dom_gift.getElementsByClassName("Banner4gift-objectName")[0].title; if (giftName == "粉丝荧光棒") { dom_gift.className = "Banner4gift Banner4gift--size2"; dom_gift.getElementsByClassName("Banner4gift-bg")[0].src = "https://gfs-op.douyucdn.cn/dygift/2019/03/15/6651f2de52dd359c7b553a77b9d00020.png"; // 修改横幅 dom_gift.getElementsByClassName("Banner4gift-objectName")[0].title = "超级火箭"; dom_gift.getElementsByClassName("Banner4gift-objectName")[0].innerText = "超级火箭"; dom_gift.getElementsByClassName("Banner4gift-headerImg")[0].src = "https://gfs-op.douyucdn.cn/dygift/2018/11/27/3adbb0c17d9886c1440d55c9711f4c79.gif"; // 修改gif if (document.getElementsByClassName("ex_giftAnimation_exist").length > 0) { return; } animationNum++; let a = document.createElement("div"); let idName = "ex_giftAnimation_" + String(animationNum); a.id = idName; a.className = "ex_giftAnimation_exist"; let b = document.getElementsByClassName("ex_giftAnimation")[0]; b.appendChild(a); let player = new SVGA.Player("#" + idName); let parser = new SVGA.Parser("#" + idName); parser.load('https://gfs-op.douyucdn.cn/dygift/2018/11/27/6c6349672e662750ad5c019b240d57f2.svga', (videoItem) => { player.setVideoItem(videoItem); player.startAnimation(); setTimeout(() => { player = null; parser = null; document.getElementById(idName).remove(); }, 4000); }); } } } let redpackets_room_arr = []; let redpacket_room_timer; // 时钟句柄 function initPkg_ExpandTool_RedPacket_Room() { ExpandTool_RedPacket_Room_insertDom(); ExpandTool_RedPacket_Room_insertFunc(); ExpandTool_RedPacket_Room_Set(); } function ExpandTool_RedPacket_Room_insertDom() { let html = ""; html += ''; let a = document.createElement("div"); a.className = "extool__redpacket_room"; a.innerHTML = html; let b = document.getElementsByClassName("extool")[0]; b.insertBefore(a, b.childNodes[0]); } function ExpandTool_RedPacket_Room_insertFunc() { document.getElementById("extool__redpacekt_room_start").addEventListener("click", function() { verifyFans("5189167", 6).then(r => { if (r == true) { let ischecked = document.getElementById("extool__redpacekt_room_start").checked; if (ischecked == true) { // 开始自动抢红包 redpacket_room_timer = setInterval(() => { getRoomRedPacketsList(rid); }, 1100); } else{ // 停止自动抢红包 clearInterval(redpacket_room_timer); } saveData_RedPacket_Room(); } else { document.getElementById("extool__redpacekt_room_start").checked = false; showMessage("本功能需拥有6级歆崽粉丝牌(5189167)才可使用", "error"); } }) }); } function getRoomRedPacketsList(room_id) { fetch("https://www.douyu.com/japi/interactnc/web/propredpacket/getPrpList?type_id=1&room_id=" + room_id, { method: 'GET', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, }).then(res => { return res.json(); }).then(ret => { if (ret.data.list.length > 0) { for (let i = 0; i < ret.data.list.length; i++) { let rpid = ret.data.list[i].activityid; let offset = redpackets_room_arr.indexOf(rpid); let startTime = ret.data.list[i].startTime; let to = Number(startTime) - Math.round(new Date().getTime()/1000); to = 1000 * to - 2000; if (offset == -1) { redpackets_room_arr.push(ret.data.list[i].activityid); if (to > 0) { setTimeout(() => { getRoomRedPacket(rpid); getRoomRedPacket(rpid); getRoomRedPacket(rpid); showMessage("【礼物红包】抢红包执行完毕!", "success"); }, to); } else { getRoomRedPacket(rpid); getRoomRedPacket(rpid); getRoomRedPacket(rpid); showMessage("【礼物红包】抢红包执行完毕!", "success"); } } } } }).catch(err => { console.log("请求失败!", err); }) } function getRoomRedPacket(rpid) { fetch("https://www.douyu.com/japi/interactnc/web/propredpacket/grab_prp", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'activityid=' + rpid + '&ctn=' + getCCN() }).then(res => { return res.json(); }).then((ret) =>{ if (ret.data.isSuc == 2) { getRoomRedPacket(rpid); } }) } function saveData_RedPacket_Room() { let isGetRedPacket = document.getElementById("extool__redpacekt_room_start").checked; let data = { isGetRedPacket: isGetRedPacket } localStorage.setItem("ExSave_RedPacket_Room", JSON.stringify(data)); // 存储弹幕列表 } function ExpandTool_RedPacket_Room_Set() { // 设置初始化 let ret = localStorage.getItem("ExSave_RedPacket_Room"); if (ret != null) { let retJson = JSON.parse(ret); if (retJson.isGetRedPacket == true) { verifyFans("5189167", 6).then(r => { if (r == true) { document.getElementById("extool__redpacekt_room_start").click(); } else { let data = { isGetRedPacket: false } localStorage.setItem("ExSave_RedPacket_Room", JSON.stringify(data)); // 存储弹幕列表 showMessage("本功能需拥有6级歆崽粉丝牌(5189167)才可使用", "error"); } }) } } } function initPkg_ExpandTool_SendGift() { ExpandTool_SendGift_insertDom(); ExpandTool_SendGift_insertFunc(); } function ExpandTool_SendGift_insertDom() { let html = ""; html += '礼物id示例
'; html += ''; html += ''; html += ''; let a = document.createElement("div"); a.className = "extool__sendgift"; a.innerHTML = html; let b = document.getElementsByClassName("extool")[0]; b.insertBefore(a, b.childNodes[0]); } function ExpandTool_SendGift_insertFunc() { document.getElementById("extool__sendgift_btn").addEventListener("click", function() { if (confirm("确认送出?") != true) { return; } let gid = document.getElementById("extool__sendgift_id").value; let gcnt = document.getElementById("extool__sendgift_cnt").value; let t_num = 0; let t_price = 0; for (let i = 0; i < Number(gcnt); i++) { sendGift_any(gid, 1, rid).then(ret => { if (ret.data != null) { if (ret.msg != "鱼翅不足") { t_num = t_num + 1; t_price = t_price + Number(ret.data.priceType); } else { console.log("【送礼】" + gid + ret.msg); } } else { console.log("【送礼】" + gid + ret.msg); } if (i == Number(gcnt) - 1) { showMessage("【送礼】赠送完毕!详细信息可以在F12控制台查看", "success"); console.log("【送礼】赠送完毕!详细信息可以在F12控制台查看"); } }).catch(err => { console.log("请求失败!", err); }) } showMessage("【送礼】执行中...", "info"); }); } function sendGift_any(gid, count, rid) { // 送任意东西 // gid: 268是荧光棒 // count: 数量 // rid: 房间号 return fetch("https://www.douyu.com/japi/gift/donate/mainsite/v1", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'giftId=' + gid + '&giftCount=' + count + '&roomId=' + rid + '&bizExt=%7B%22yzxq%22%3A%7B%7D%7D' }).then(res => { return res.json(); }) } var isGetTreasure = false; function initPkg_ExpandTool_Treasure() { ExpandTool_Treasure_insertDom(); ExpandTool_Treasure_insertFunc(); ExpandTool_Treasure_Set(); } function ExpandTool_Treasure_insertDom() { let html = ""; html += ''; html += 'ms' html += '
ddocr秘钥:
'; let a = document.createElement("div"); a.className = "extool__treasure"; a.innerHTML = html; let b = document.getElementsByClassName("extool")[0]; b.insertBefore(a, b.childNodes[0]); } function ExpandTool_Treasure_insertFunc() { document.getElementById("extool__treasure_start").addEventListener("click", function() { verifyFans("5189167", 9).then(r => { // 请尊重作者劳动成果,在此感谢 if (r == true) { let ischecked = document.getElementById("extool__treasure_start").checked; if (ischecked == true) { // 开始 isGetTreasure = true; getTreasure_Existing(); } else{ // 停止 isGetTreasure = false; } saveData_Treasure(); } else { document.getElementById("extool__treasure_start").checked = false; showMessage("本功能需拥有9级歆崽粉丝牌(5189167)才可使用", "error"); } }) }); } function saveData_Treasure() { isGetTreasure = document.getElementById("extool__treasure_start").checked; let delay = document.getElementById("extool__treasure_delay").value; let skey = document.getElementById("extool__treasure_skey").value; let data = { isGetTreasure: isGetTreasure, treasureDelay: delay, skey: skey, } localStorage.setItem("ExSave_Treasure", JSON.stringify(data)); // 存储弹幕列表 } function ExpandTool_Treasure_Set() { // 设置初始化 let ret = localStorage.getItem("ExSave_Treasure"); if (ret != null) { let retJson = JSON.parse(ret); if ("treasureDelay" in retJson == true) { document.getElementById("extool__treasure_delay").value = retJson.treasureDelay; } else { document.getElementById("extool__treasure_delay").value = "3200"; } if ("skey" in retJson == true) { document.getElementById("extool__treasure_skey").value = retJson.skey; } if (retJson.isGetTreasure == true) { verifyFans("5189167", 9).then(r => { if (r == true) { document.getElementById("extool__treasure_start").click(); } else { let data = { isGetTreasure: false } localStorage.setItem("ExSave_Treasure", JSON.stringify(data)); // 存储弹幕列表 showMessage("本功能需拥有9级歆崽粉丝牌(5189167)才可使用", "error"); } }) } } } function getTreasureDelay() { let ret = document.getElementById("extool__treasure_delay").value; return Number(ret); } function getTreasureSkey() { let ret = document.getElementById("extool__treasure_skey").value; return ret; } function getTreasure_Existing() { getTslist(data => { if (data == null) { return; } let list = String(data.list).split("@S/"); for (let i = 0; i < list.length - 1; i++) { let rpid = getStrMiddle(list[i], "rpid@A=", "@"); let ot = getStrMiddle(list[i], "Sot@A=", "@"); let did = getCookieValue("dy_did"); let timeout = Number(ot) - Math.floor(Date.now()/1000); let a = document.createElement("div"); let idName = "Ex_Geetest_no" + String(treasureNum); a.id = idName; let b = document.getElementById("Ex_Geetest"); b.appendChild(a); if (timeout >= 0) { timeout = timeout * 1000 + getTreasureDelay(); treasureNum++; setTimeout(() => { getTreasure(rid, rpid, did, idName); }, timeout); } else { getTreasure(rid, rpid, did, idName); } } }); } function getTslist(callback) { unsafeWindow.socketProxy.socketStream.subscribe('tslist', callback); } function initPkg_ExPanel() { initPkg_ExPanel_insertDom(); } function initPkg_ExPanel_insertDom() { let a = document.createElement("div"); a.className = "ex-panel"; a.innerHTML = '
'; let b = document.getElementsByClassName("PlayerToolbar-Wealth")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_FansContinue() { initPkg_FansContinue_Dom(); initPkg_FansContinue_Func(); } function initPkg_FansContinue_Dom() { FansContinue_insertIcon(); } function FansContinue_insertIcon() { let a = document.createElement("div"); a.className = "fans-continue"; a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_FansContinue_Func() { document.getElementsByClassName("fans-continue")[0].addEventListener("click", function() { let sendNum = prompt("每个直播间赠送几根荧光棒?", "1"); if (sendNum == null) { return; } if (sendNum == "") { return; } fetch('https://www.douyu.com/member/cp/getFansBadgeList',{ method: 'GET', mode: 'no-cors', cache: 'default', credentials: 'include', }).then(res => { return res.text(); }).then(async (doc) => { doc = (new DOMParser()).parseFromString(doc, 'text/html'); let a = doc.getElementsByClassName("fans-badge-list")[0].lastElementChild; let n = a.children.length; for (let i = 0; i < n; i++) { let rid = a.children[i].getAttribute("data-fans-room"); // 获取房间号 await sleep(250).then(() => { sendGift_bag(268, Number(sendNum), rid).then(data => { if (data.msg == "success") { showMessage("【续牌】" + rid + "赠送荧光棒成功", "success"); // console.log(rid + "赠送一根荧光棒成功"); } else { showMessage("【续牌】" + rid + "赠送失败 " + data.msg, "error"); // console.log(rid + "赠送失败"); console.log(rid, data); } }).catch(err => { showMessage("【续牌】" + rid + "赠送失败", "error"); console.log(rid, err); }) }); } }).catch(err => { console.log("请求失败!", err); }) }); } function sendGift_bag(gid, count, rid) { // 送背包里的东西 // gid: 268是荧光棒 // count: 数量 // rid: 房间号 return fetch("https://www.douyu.com/japi/prop/donate/mainsite/v1", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'propId=' + gid + '&propCount=' + count + '&roomId=' + rid + '&bizExt=%7B%22yzxq%22%3A%7B%7D%7D' }).then(res => { return res.json(); }) } function initPkg_FirePower() { initPkg_FirePower_Dom(); initPkg_FirePower_Func(); } function initPkg_FirePower_Dom() { FirePower_insertIcon(); } function FirePower_insertIcon() { let a = document.createElement("div"); a.className = "firepower"; a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_FirePower_Func() { document.getElementsByClassName("firepower")[0].addEventListener("click", function() { fetch('https://www.douyu.com/japi/firepower/apinc/activeTask/getRecRid', { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}, body: "token=" + getCCN() }).then(result => { return result.json(); }).then(ret => { let rid = ret.data; window.location.href = "https://www.douyu.com/" + rid; }).catch(err => { console.log("请求失败!", err); }) }); } function initPkg_FishFood() { initPkg_FishFood_Dom(); initPkg_FishFood_Func(); } function initPkg_FishFood_Dom() { FishFood_insertIcon(); } function FishFood_insertIcon() { let a = document.createElement("div"); a.className = "fish-food"; a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_FishFood_Func() { document.getElementsByClassName("fish-food")[0].addEventListener("click", function() { fetch("https://www.douyu.com/japi/activepointnc/api/getActivePointInfo", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).then(res => { return res.json(); }).then(async (ret) =>{ let cnt = Math.floor(Number(ret.data.userActivePoint) / Number(ret.data.onceLotteryActivePoint)); if (cnt == 0) { showMessage("【寻宝】" + "鱼粮不足", "warning"); return; } cnt = Number(ret.data.dailyMaxLotteryTimes) - Number(ret.data.usedLotteryCount); if (cnt == 0) { showMessage("【寻宝】" + "今日寻宝次数已到达上限", "warning"); return; } for (let i = 0; i < cnt; i++) { await sleep(1500).then(() => { fetch("https://www.douyu.com/japi/activepointnc/api/dolottery", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'rid=' + rid + '&ctn=' + getCCN() }).then(res => { return res.json(); }).then(ret => { if (ret.data != null) { if (Object.keys(ret.data).length != 0) { showMessage("【寻宝】" + ret.data.msg, "success"); } } else { showMessage("【寻宝】" + ret.msg, "warning"); } // console.log("【寻宝】" + ret.data.msg); }).catch(err => { console.log("请求失败!", err); }) }) } }) }) } function initPkg_FishPond() { initPkg_FishPond_Dom(); initPkg_FishPond_Func(); } function initPkg_FishPond_Timer() { // 这里挂载每个子模块的时钟周期函数 initPkg_FishPond_Bubble_Timer(); initPkg_FishPond_Box_Timer(); initPkg_FishPond_Task_Timer(); initPkg_FishPond_RoomSign_Timer(); } function initPkg_FishPond_Func() { } function initPkg_FishPond_Dom() { FishPond_insertIcon(); } function FishPond_insertIcon() { } function getAllFishPond() { initPkg_FishPond_Bubble(); initPkg_FishPond_Box(); initPkg_FishPond_Task(); initPkg_FishPond_RoomSign(); } function FishPond_showTip(a) { // let d = document.getElementById("fish-pond__tip"); // if (a == true) { // if (d.style.display != "block") { // showMessage("【鱼粮】有鱼粮可以领取啦!", "info"); // d.style.display = "block"; // } // } else { // d.style.display = "none"; // } } let boxList = []; function initPkg_FishPond_Box() { getFishPond_Box(); } function initPkg_FishPond_Box_Timer() { getFishPond_BoxList(); } function getFishPond_Box() { // 清空boxList内的气泡 if (boxList.length == 0) { // showMessage("【鱼塘宝箱】暂无可领取的鱼粮", "info"); return; } let arr = boxList.concat(); for (let i = 0; i < arr.length; i++) { GM_xmlhttpRequest({ method: "POST", url: "https://pcapi.douyucdn.cn/japi/tasksys/ytxb/getPrize", data: "id=" + arr[i] + "&token=" + dyToken, responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", }, onload: function(response) { showMessage("【鱼塘宝箱】" + response.response.data.msg, "success"); // console.log("【鱼塘宝箱】" , response.response.msg, response.response); } }); } // FishPond_showTip(false); boxList.length = 0; } function getFishPond_BoxList() { // 获取可领取的鱼粮,如果有,就显示小红点 GM_xmlhttpRequest({ method: "POST", url: "https://pcapi.douyucdn.cn/japi/tasksys/ytxb/box", data: 'token=' + dyToken, responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", }, onload: function(response) { boxList.length = 0; for (let i = 0; i < response.response.data.length; i++) { if (response.response.data[i] != null) { if (response.response.data[i].status == "2") { boxList.push(response.response.data[i].id); getAllFishPond(); } } } } }); } let bubbleList = []; function initPkg_FishPond_Bubble() { getFishPond_Bubble(); } function initPkg_FishPond_Bubble_Timer() { getFishPond_BubbleList(); } function getFishPond_Bubble() { // 清空bubbleList内的气泡 if (bubbleList.length == 0) { // showMessage("【鱼塘气泡】暂无可领取的鱼粮", "info"); return; } let bubbleToGet = ""; for (let i = 0; i < bubbleList.length; i++) { if (i != bubbleList.length - 1) { bubbleToGet = bubbleToGet + bubbleList[i] + "%2C"; } else { bubbleToGet = bubbleToGet + bubbleList[i]; } } fetch('https://www.douyu.com/japi/tasksys/ytxb/batchGetPrize',{ method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'ids=' + bubbleToGet + '&rid=' + rid }).then(res => { return res.json(); }).then(ret => { let result = ""; for (let i = 0; i < ret.data.prizeList.length; i++) { result = result + ret.data.prizeList[i].num + "个" + ret.data.prizeList[i].name + ","; } bubbleList.length = 0; // 此处领取完毕,小红点也要去掉 // FishPond_showTip(false); showMessage("【鱼塘气泡】领取结果:" + result, "success"); // console.log("【鱼塘气泡】领取结果:" + result, ret); }).catch(err => { console.log("请求失败!", err); }) } function getFishPond_BubbleList() { // 获取可领取的鱼粮,如果有,就显示小红点 fetch('https://www.douyu.com/japi/tasksys/ytxb/bubble',{ method: 'GET', mode: 'no-cors', credentials: 'include' }).then(res => { return res.json(); }).then(ret => { bubbleList.length = 0; for (let i = 0; i < ret.data.list.length; i++) { if (ret.data.list[i] != null) { if (ret.data.list[i].status == "2") { bubbleList.push(ret.data.list[i].id); getAllFishPond(); } } } }).catch(err => { console.log("请求失败!", err); }) } let roomSignList = []; function initPkg_FishPond_RoomSign() { getFishPond_RoomSign(); } function initPkg_FishPond_RoomSign_Timer() { getFishPond_RoomSignList(); } function getFishPond_RoomSign() { // 清空roomSignList内的气泡 if (roomSignList.length == 0) { // showMessage("【签到宝箱】暂无可领取的鱼粮", "info"); return; } let arr = roomSignList.concat(); for (let i = 0; i < arr.length; i++) { fetch('https://www.douyu.com/japi/roomuserlevel/apinc/getPrize',{ method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'rid=' + rid + '&ctn=' + getCCN() }).then(res => { return res.json(); }).then(ret => { if (ret.error == "0") { showMessage("【签到宝箱】领取结果:" + ret.msg, "success"); } }).catch(err => { console.log("请求失败!", err); }) } // FishPond_showTip(false); roomSignList.length = 0; } function getFishPond_RoomSignList() { fetch('https://www.douyu.com/japi/roomuserlevel/apinc/levelInfo?rid=' + rid + '&clientType=0',{ method: 'GET', mode: 'no-cors', credentials: 'include' }).then(res => { return res.json(); }).then(ret => { if (ret.error == "0" ) { if (ret.data.treasure.status == "1") { roomSignList.push("1"); getAllFishPond(); } } }).catch(err => { console.log("请求失败!", err); }) } let taskList = []; function initPkg_FishPond_Task() { getFishPond_Task(); } function initPkg_FishPond_Task_Timer() { getFishPond_TaskList(); } function getFishPond_Task() { fetch('https://www.douyu.com/japi/tasksys/ytxb/batchGetPrize',{ method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'ids=1182%2C1183%2C1184%2C1185%2C1186' + '&rid=' + rid }).then(res => { return res.json(); }).then(ret => { if (ret.data !== null) { for (let i = 0; i < ret.data.length; i++) { showMessage("【鱼塘任务】领取结果:成功领取" + ret.data[i].name + ret.data[i].num + "个", "success"); } } }).catch(err => { console.log("请求失败!", err); }) if (taskList.length == 0) { // showMessage("【鱼塘任务】暂无可领取的鱼粮", "info"); return; } let arr = taskList.concat(); for (let i = 0; i < arr.length; i++) { fetch('https://www.douyu.com/japi/tasksys/ytxb/getPrize',{ method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'id=' + arr[i] + '&roomId=' + rid }).then(res => { return res.json(); }).then(ret => { // console.log("【鱼塘任务】领取结果:", ret); showMessage("【鱼塘任务】领取结果:" + ret.data.msg, "success"); }).catch(err => { console.log("请求失败!", err); }) } taskList.length = 0; // FishPond_showTip(false); } function getFishPond_TaskList() { // 获取可领取的鱼粮,如果有,就显示小红点 taskList.length = 0; getFishPond_TaskList_Day(); getFishPond_TaskList_Week(); getFishPond_TaskList_Ytzb(); // getFishPond_TaskList_Client(); } function getFishPond_TaskList_Day() { fetch('https://www.douyu.com/japi/tasksys/ytxb/userStatusV2?cycleType=1&roomId=' + rid,{ method: 'GET', mode: 'no-cors', credentials: 'include' }).then(res => { return res.json(); }).then(ret => { for (let i = 0; i < ret.data.list.length; i++) { if (ret.data.list[i].status == "2") { taskList.push(ret.data.list[i].id); getAllFishPond(); } } }).catch(err => { console.log("请求失败!", err); }) } function getFishPond_TaskList_Week() { fetch('https://www.douyu.com/japi/tasksys/ytxb/userStatusV2?cycleType=2&roomId=' + rid,{ method: 'GET', mode: 'no-cors', credentials: 'include' }).then(res => { return res.json(); }).then(ret => { for (let i = 0; i < ret.data.list.length; i++) { if (ret.data.list[i].status == "2") { taskList.push(ret.data.list[i].id); getAllFishPond(); } } }).catch(err => { console.log("请求失败!", err); }) } function getFishPond_TaskList_Ytzb() { fetch('https://www.douyu.com/japi/tasksys/ytxb/userStatusV2?cycleType=25&roomId=' + rid,{ method: 'GET', mode: 'no-cors', credentials: 'include' }).then(res => { return res.json(); }).then(ret => { for (let i = 0; i < ret.data.list.length; i++) { if (ret.data.list[i].status == "2") { taskList.push(ret.data.list[i].id); getAllFishPond(); } } }).catch(err => { console.log("请求失败!", err); }) } let followListHook; function initPkg_FollowList() { let intID = setInterval(() => { if (typeof(document.getElementsByClassName("DropPane-icon Follow-icon")[0]) != "undefined") { followListHook = new DomHook(".Header-follow-content", false, handleFollowList) clearInterval(intID); } }, 1000); } function handleFollowList(m) { let active = document.getElementsByClassName("Header-follow-tab is-active")[0].innerText; if (active == "特别关注") { return; } let panel = document.getElementsByClassName("Header-follow-listBox"); if (panel.length == 0) { return; } setNewFollowList(panel[0]); } async function setNewFollowList(panel) { let followList = await getFollowList(); if (followList.error != "0") { return; } const FOLLOWLIST_LIMIT = 10; // 关注列表最多显示个数 let limit = 0; let html = `
长按弹出同屏播放
`; let nowTime = Math.floor(Date.now()/1000); for (let i = 0; i < followList.data.list.length; i++) { let item = followList.data.list[i]; if (item.show_status == "1" && item.videoLoop == "0") { // 开播且非录播 html += `
  • ${ item.nickname }

    ${ item.online }${ item.room_name }

    ${ item.nickname }已播${ formatSeconds(nowTime - Number(item.show_time)) }

  • ` limit++; } if (limit >= FOLLOWLIST_LIMIT) { break; } } panel.innerHTML = html; let followListItems = document.getElementsByClassName("ExFollowListItem"); for (let i = 0; i < followListItems.length; i++) { let cclick = new CClick(followListItems[i]); cclick.longClick(() => { createNewVideo(videoPlayerArr.length, followListItems[i].getAttribute("rid"), "Douyu"); document.querySelector(".Follow .public-DropMenu").className = "public-DropMenu"; }); cclick.click(() => { openPage("https://www.douyu.com/" + followListItems[i].getAttribute("rid"), true); }); } } function getFollowList() { return new Promise(resolve => { fetch("https://www.douyu.com/wgapi/livenc/liveweb/follow/list?sort=1&cid1=0", { method: 'GET', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, }).then(res => { return res.json(); }).then(ret => { resolve(ret); }) }) } let isEnterOn = false; let enterWordList = {}; function initPkg_LiveTool_Enter() { LiveTool_Enter_insertDom(); LiveTool_Enter_insertFunc(); initPkg_Enter_Set(); } function LiveTool_Enter_insertDom() { let a = document.createElement("div"); a.className = "livetool__cell"; let cell = `
    进场欢迎
    `; let panel = `
    `; a.innerHTML = cell + panel; let b = document.getElementsByClassName("livetool")[0]; b.insertBefore(a, b.childNodes[0]); } function LiveTool_Enter_insertFunc() { document.getElementById("enter__switch").addEventListener("click", () => { let ischecked = document.getElementById("enter__switch").checked; if (ischecked == true) { // 开启关键词禁言 isEnterOn = true; } else{ // 关闭关键词禁言 isEnterOn = false; } saveData_isEnter(); }); document.getElementById("enter__title").addEventListener("click", () => { let a = document.getElementsByClassName("enter__panel")[0]; if (a.style.display != "block") { a.style.display = "block"; if (rid !== "5189167") { if (document.getElementsByClassName("mute__panel")[0].style.display == "block") { document.getElementsByClassName("mute__panel")[0].style.display = "none"; } } if (document.getElementsByClassName("reply__panel")[0].style.display == "block") { document.getElementsByClassName("reply__panel")[0].style.display = "none"; } if (document.getElementsByClassName("gift__panel")[0].style.display == "block") { document.getElementsByClassName("gift__panel")[0].style.display = "none"; } if (document.getElementsByClassName("vote__panel")[0].style.display == "block") { document.getElementsByClassName("vote__panel")[0].style.display = "none"; } } else { a.style.display = "none"; } }); document.getElementById("enter__select").onclick = function() { if (this.options.length == 0) { return; } let word = this.options[this.selectedIndex].text; let level = enterWordList[word].enter; document.getElementById("enter__word").value = word; document.getElementById("enter__level").value = level; localStorage.setItem("ExSave_LastEnterWord", word); // 存储弹幕列表 }; document.getElementById("enter__add").addEventListener("click", () => { let select_wordList = document.getElementById("enter__select"); let word = document.getElementById("enter__word").value; let level = document.getElementById("enter__level").value; if (word == "") { return; } if (level == "") { return; } // 构造json并添加json enterWordList[word] = { enter: Number(level), } // 添加到select中去 select_wordList.options.add(new Option(word, "")); saveData_Enter(); }); document.getElementById("enter__del").addEventListener("click", () => { let select_wordList = document.getElementById("enter__select"); let word = select_wordList.options[select_wordList.selectedIndex].text; // 删除json内的对象 delete enterWordList[word]; // 删除select里的option select_wordList.options.remove(select_wordList.selectedIndex); saveData_Enter(); }); } function saveData_Enter() { let data = enterWordList; localStorage.setItem("ExSave_Enter", JSON.stringify(data)); // 存储弹幕列表 } function saveData_isEnter() { let ridArr = []; let ret = localStorage.getItem("ExSave_isEnter"); if (ret != null) { let retJson = JSON.parse(ret); if ("rooms" in retJson == true) { ridArr = retJson.rooms; } } let index = ridArr.indexOf(rid); if (isEnterOn == true) { if (index == -1) { ridArr.push(rid); } } else { ridArr.splice(index, 1); } let data = { rooms: ridArr, }; localStorage.setItem("ExSave_isEnter", JSON.stringify(data)); // 存储弹幕列表 } function initPkg_Enter_Set() { // 设置初始化 let ret = localStorage.getItem("ExSave_Enter"); if (ret == "") { return; } let select_wordList = document.getElementById("enter__select"); if (ret != null) { let retJson = JSON.parse(ret); enterWordList = retJson; for (let key in retJson) { if (retJson.hasOwnProperty(key)) { select_wordList.options.add(new Option(key, "")); } } } ret = localStorage.getItem("ExSave_LastEnterWord"); if (ret != null) { let i = 0; for (const key in enterWordList) { if (key == ret) { select_wordList.selectedIndex = i; let level = enterWordList[ret].enter; document.getElementById("enter__word").value = ret; document.getElementById("enter__level").value = level; break; } i++; } } ret = localStorage.getItem("ExSave_isEnter"); if (ret != null) { let retJson = JSON.parse(ret); let ridArr = []; if ("rooms" in retJson == true) { ridArr = retJson.rooms; } if (ridArr.indexOf(rid) == -1) { isEnterOn = false; } else { isEnterOn = true; } document.getElementById("enter__switch").checked = isEnterOn; } else { isEnterOn = false; document.getElementById("enter__switch").checked = isEnterOn; } } function initPkg_LiveTool_Enter_Handle(text) { if (isEnterOn == false) { return; } if (getType(text) == "uenter") { let uid = getStrMiddle(text, "uid@=", "/"); if (uid == my_uid) { // 不算自己 return; } let nn = getStrMiddle(text, "nn@=", "/"); let level = getStrMiddle(text, "level@=", "/"); let select_wordList = document.getElementById("enter__select"); let reply = select_wordList.options[select_wordList.selectedIndex].text; let levelLimit = enterWordList[reply].enter; if (Number(level) < Number(levelLimit)) { return; } reply = String(reply).replace(//g, nn); sendBarrage(reply); } } let isGiftOn = false; let giftWordList = {}; function initPkg_LiveTool_Gift() { LiveTool_Gift_insertDom(); LiveTool_Gift_insertFunc(); initPkg_Gift_Set(); } function LiveTool_Gift_insertDom() { let a = document.createElement("div"); a.className = "livetool__cell"; let cell = `
    自动谢礼物
    `; let panel = `
    `; a.innerHTML = cell + panel; let b = document.getElementsByClassName("livetool")[0]; b.insertBefore(a, b.childNodes[0]); } function LiveTool_Gift_insertFunc() { document.getElementById("reply__show_gid").addEventListener("click", () => { console.log(` 背包礼物:http://webconf.douyucdn.cn/resource/common/prop_gift_list/prop_gift_config.json 鱼翅礼物:http://open.douyucdn.cn/api/RoomApi/room/5189167 `); showMessage("请按F12到控制台(console)查看礼物id", "success"); }); document.getElementById("gift__switch").addEventListener("click", () => { let ischecked = document.getElementById("gift__switch").checked; if (ischecked == true) { // 开启关键词禁言 isGiftOn = true; } else{ // 关闭关键词禁言 isGiftOn = false; } saveData_isGift(); }); document.getElementById("gift__title").addEventListener("click", () => { let a = document.getElementsByClassName("gift__panel")[0]; if (a.style.display != "block") { a.style.display = "block"; if (rid != "5189167") { if (document.getElementsByClassName("mute__panel")[0].style.display == "block") { document.getElementsByClassName("mute__panel")[0].style.display = "none"; } } if (document.getElementsByClassName("enter__panel")[0].style.display == "block") { document.getElementsByClassName("enter__panel")[0].style.display = "none"; } if (document.getElementsByClassName("reply__panel")[0].style.display == "block") { document.getElementsByClassName("reply__panel")[0].style.display = "none"; } if (document.getElementsByClassName("vote__panel")[0].style.display == "block") { document.getElementsByClassName("vote__panel")[0].style.display = "none"; } } else { a.style.display = "none"; } }); document.getElementById("gift__select").onclick = function() { if (this.options.length == 0) { return; } let giftId = this.options[this.selectedIndex].text; let reply = giftWordList[giftId].reply; document.getElementById("gift__giftId").value = giftId; document.getElementById("gift__reply").value = reply; }; document.getElementById("gift__add").addEventListener("click", () => { let select_wordList = document.getElementById("gift__select"); let giftId = document.getElementById("gift__giftId").value; let reply = document.getElementById("gift__reply").value; if (giftId == "") { return; } // 构造json并添加json giftWordList[giftId] = { reply: reply, } // 添加到select中去 select_wordList.options.add(new Option(giftId, "")); saveData_Gift(); }); document.getElementById("gift__del").addEventListener("click", () => { let select_wordList = document.getElementById("gift__select"); let giftId = select_wordList.options[select_wordList.selectedIndex].text; // 删除json内的对象 delete giftWordList[giftId]; // 删除select里的option select_wordList.options.remove(select_wordList.selectedIndex); saveData_Gift(); }); } function saveData_Gift() { let data = giftWordList; localStorage.setItem("ExSave_Gift", JSON.stringify(data)); // 存储弹幕列表 } function saveData_isGift() { let ridArr = []; let ret = localStorage.getItem("ExSave_isGift"); if (ret != null) { let retJson = JSON.parse(ret); if ("rooms" in retJson == true) { ridArr = retJson.rooms; } } let index = ridArr.indexOf(rid); if (isGiftOn == true) { if (index == -1) { ridArr.push(rid); } } else { ridArr.splice(index, 1); } let data = { rooms: ridArr, }; localStorage.setItem("ExSave_isGift", JSON.stringify(data)); // 存储弹幕列表 } function initPkg_Gift_Set() { // 设置初始化 let ret = localStorage.getItem("ExSave_Gift"); if (ret != null) { let retJson = JSON.parse(ret); giftWordList = retJson; let select_wordList = document.getElementById("gift__select"); for (let key in retJson) { if (retJson.hasOwnProperty(key)) { select_wordList.options.add(new Option(key, "")); } } } ret = localStorage.getItem("ExSave_isGift"); if (ret != null) { let retJson = JSON.parse(ret); let ridArr = []; if ("rooms" in retJson == true) { ridArr = retJson.rooms; } if (ridArr.indexOf(rid) == -1) { isGiftOn = false; } else { isGiftOn = true; } document.getElementById("gift__switch").checked = isGiftOn; } else { isGiftOn = false; document.getElementById("gift__switch").checked = isGiftOn; } } function initPkg_LiveTool_Gift_Handle(text) { if (isGiftOn == false) { return; } if (getType(text) == "dgb") { let uid = getStrMiddle(text, "uid@=", "/"); if (uid == my_uid) { // 不算自己 return; } let nn = getStrMiddle(text, "nn@=", "/"); let gfid = getStrMiddle(text, "gfid@=", "/"); let gfcnt = getStrMiddle(text, "gfcnt@=", "/"); for (let key in giftWordList) { if (gfid == key) { let reply = giftWordList[key].reply; reply = String(reply).replace(//g, nn); reply = String(reply).replace(//g, gfcnt); sendBarrage(reply); break; } } } } let timer_closing; let closingNum = 0; function initPkg_LiveTool_LiveNotice() { } function initPkg_LiveTool_LiveNotice_Handle(text) { if (getType(text) == "rss") { let rid = getStrMiddle(text, "rid@=", "/"); let ss = getStrMiddle(text, "ss@=", "/"); if (ss == "1") { showMessageWindow("开播提醒", "直播间:" + rid + "开播了,点我签到", () => { signRoom(rid); }); } else { clearInterval(timer_closing); timer_closing = setInterval(() => { if (closingNum > 30) { clearInterval(timer_closing); closingNum = 0; } let x = document.getElementsByClassName("dy-ModalRadius-close-x"); if (x.length > 0) { clearInterval(timer_closing); x[0].click(); } closingNum++; }, 500); } } } function getRoomAvatar() { fetch('https://www.douyu.com/betard/' + rid,{ method: 'GET', mode: 'no-cors', credentials: 'include' }).then(res => { return res.json(); }).then(ret => { roomAvatar = ret.room.avatar.middle; }).catch(err => { console.log("请求失败!", err); }) } function initPkg_LiveTool() { initPkg_LiveTool_Dom(); initPkg_LiveTool_Module(); initPkg_LiveTool_Func(); initPkg_LiveTool_HandleFunc(); } function initPkg_LiveTool_Dom() { LiveTool_insertModal(); LiveTool_insertIcon(); } function initPkg_LiveTool_Module() { // 添加模块 initPkg_LiveTool_Vote(); initPkg_LiveTool_Enter(); initPkg_LiveTool_Mute(); initPkg_LiveTool_Gift(); initPkg_LiveTool_Reply(); initPkg_LiveTool_Treasure(); // initPkg_LiveTool_Bojiang_Handle(); } function LiveTool_insertModal() { let a = document.createElement("div"); a.className = "livetool"; let b = document.getElementsByClassName("layout-Player-chat")[0]; b.insertBefore(a, b.childNodes[0]); } function LiveTool_insertIcon() { let a = document.createElement("div"); a.className = "livetool-icon"; a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_LiveTool_Func() { document.getElementsByClassName("livetool-icon")[0].addEventListener("click", function() { let a = document.getElementsByClassName("livetool")[0]; if (a.style.display != "block") { a.style.display = "block"; if (document.getElementsByClassName("bloop")[0].style.display == "block") { document.getElementsByClassName("bloop")[0].style.display = "none"; } if (document.getElementsByClassName("extool")[0].style.display == "block") { document.getElementsByClassName("extool")[0].style.display = "none"; } } else { a.style.display = "none"; } }); } function initPkg_LiveTool_HandleFunc() { // 开启ws,并且设置处理函数的入口 // 是否生效由每个处理函数决定,可以设置一个变量保存开启状态,判断是否要执行 let ws = new Ex_WebSocket_UnLogin(rid, (ret) => { initPkg_LiveTool_LiveNotice_Handle(ret); // 开播提醒 initPkg_LiveTool_Mute_Handle(ret); // 关键词禁言 initPkg_LiveTool_Reply_Handle(ret); // 关键词回复 initPkg_LiveTool_Gift_Handle(ret); // 自动谢礼物 initPkg_LiveTool_Treasure_Handle(ret); initPkg_LiveTool_Enter_Handle(ret); // initPkg_LiveTool_Friend_Handle(ret); initPkg_LiveTool_Vote_Handle(ret); }); } function getType(str) { return getStrMiddle(str, "type@=", "/"); } function selectOptionByValue(selectId, checkValue) { // 根据value值选择option let select = document.getElementById(selectId); for(let i=0; i 关键词禁言名单
    `; let panel = `
    `; a.innerHTML = cell + panel; let b = document.getElementsByClassName("livetool")[0]; b.insertBefore(a, b.childNodes[0]); } function LiveTool_Mute_insertFunc() { document.getElementById("mute__idlist").addEventListener("click", () => { if (muteIdListShow.length == 0) { showMessage("暂无禁言名单", "warning"); return; } console.log("【禁言名单】"); for (let i = 0; i < muteIdListShow.length; i++) { let item = muteIdListShow[i]; console.log("id:【" + item.id + "】 | uid:" + item.uid + " | 弹幕:" + item.barrage + " | 检测次数:" + item.count + " | 禁言时长:" + item.time + "分钟 | 禁言时间:" + item.ts); } showMessage("禁言名单已经输出在控制台,请按F12查看", "success"); }); document.getElementById("mute__delmute").addEventListener("click", async () => { if (muteIdListShow.length == 0) { showMessage("暂无禁言名单", "warning"); return; } if (confirm("是否解禁名单上所有的id?") != true) { return; } for (let i = 0; i < muteIdListShow.length; i++) { let item = muteIdListShow[i]; let tmp = await deleteMuteUser(rid, item.uid); } showMessage("解除禁言完毕", "success"); }); document.getElementById("mute__switch").addEventListener("click", () => { let ischecked = document.getElementById("mute__switch").checked; if (ischecked == true) { // 开启关键词禁言 isMuteOn = true; } else{ // 关闭关键词禁言 isMuteOn = false; } saveData_isMute(); }); document.getElementById("mute__title").addEventListener("click", () => { let a = document.getElementsByClassName("mute__panel")[0]; if (a.style.display != "block") { a.style.display = "block"; if (document.getElementsByClassName("reply__panel")[0].style.display == "block") { document.getElementsByClassName("reply__panel")[0].style.display = "none"; } if (document.getElementsByClassName("enter__panel")[0].style.display == "block") { document.getElementsByClassName("enter__panel")[0].style.display = "none"; } if (document.getElementsByClassName("gift__panel")[0].style.display == "block") { document.getElementsByClassName("gift__panel")[0].style.display = "none"; } if (document.getElementsByClassName("vote__panel")[0].style.display == "block") { document.getElementsByClassName("vote__panel")[0].style.display = "none"; } } else { a.style.display = "none"; } }); document.getElementById("mute__select").onclick = function() { if (this.options.length == 0) { return; } let word = this.options[this.selectedIndex].text; let count = muteWordList[word].count; let time = muteWordList[word].time; document.getElementById("mute__word").value = word; document.getElementById("mute__count").value = count; selectOptionByValue("mute__time", time); }; document.getElementById("mute__add").addEventListener("click", () => { let select_time = document.getElementById("mute__time"); let select_wordList = document.getElementById("mute__select"); let word = document.getElementById("mute__word").value; let count = document.getElementById("mute__count").value; let time = select_time.options[select_time.selectedIndex].value if (word == "") { return; } // 构造json并添加json muteWordList[word] = { count: count, time: time, } // 添加到select中去 select_wordList.options.add(new Option(word, "")); saveData_Mute(); }); document.getElementById("mute__del").addEventListener("click", () => { let select_wordList = document.getElementById("mute__select"); let word = select_wordList.options[select_wordList.selectedIndex].text; // 删除json内的对象 delete muteWordList[word]; // 删除select里的option select_wordList.options.remove(select_wordList.selectedIndex); saveData_Mute(); }); } function saveData_Mute() { let data = muteWordList; localStorage.setItem("ExSave_Mute", JSON.stringify(data)); // 存储弹幕列表 } function saveData_isMute() { let ridArr = []; let ret = localStorage.getItem("ExSave_isMute"); if (ret != null) { let retJson = JSON.parse(ret); if ("rooms" in retJson == true) { ridArr = retJson.rooms; } } let index = ridArr.indexOf(rid); if (isMuteOn == true) { if (index == -1) { ridArr.push(rid); } } else { ridArr.splice(index, 1); } let data = { rooms: ridArr, }; localStorage.setItem("ExSave_isMute", JSON.stringify(data)); // 存储弹幕列表 } async function initPkg_Mute_Set() { // canMute = await getRoomAdminStatus(); // 设置初始化 let ret = localStorage.getItem("ExSave_Mute"); if (ret != null) { let retJson = JSON.parse(ret); muteWordList = retJson; let select_wordList = document.getElementById("mute__select"); for (let key in retJson) { if (retJson.hasOwnProperty(key)) { select_wordList.options.add(new Option(key, "")); } } } ret = localStorage.getItem("ExSave_isMute"); if (ret != null) { let retJson = JSON.parse(ret); let ridArr = []; if ("rooms" in retJson == true) { ridArr = retJson.rooms; } if (ridArr.indexOf(rid) == -1) { isMuteOn = false; } else { isMuteOn = true; } document.getElementById("mute__switch").checked = isMuteOn; } else { isMuteOn = false; document.getElementById("mute__switch").checked = isMuteOn; } } async function initPkg_LiveTool_Mute_Handle(text) { // if (canMute != true) { // return; // } if (isMuteOn == false) { return; } if (rid == "5189167") { return; } if (getType(text) == "chatmsg") { let uid = getStrMiddle(text, "uid@=", "/"); if (uid == my_uid) { // 不算自己 return; } let nn = getStrMiddle(text, "nn@=", "/"); let txt = getStrMiddle(text, "txt@=", "/"); let isConform = false; for (let key in muteWordList) { if (key == "") { continue; } if (key.indexOf("re(") != -1) { // 正则 let regStr = getStrMiddle(key, "re(", ")="); let strArr = key.split("=") if (strArr.length > 1) { let str = strArr[1]; let regObj = new RegExp(regStr, "g"); let result = regObj.exec(txt); if (result.length > 0) { if (result[0] == str) { isConform = true; } else { isConform = false; } } } } else { if (String(txt).indexOf(key) == -1) { // 没找到 isConform = false; } else { isConform = true; } } if (isConform == true) { let maxCount = muteWordList[key].count; let time = muteWordList[key].time; if (muteIdList.hasOwnProperty(nn)) { let nextCount = Number(muteIdList[nn].count) + 1; if (nextCount >= maxCount) { let tmp = await addMuteUser(rid, nn, time); showMessageWindow("禁言信息", "【" + nn + "】已被禁言" + time + "分钟" + "\n弹幕:" + txt, () => {}); let obj = { id: nn, uid: uid, barrage: txt, time: time, count: 1, ts: String(dateFormat("yyyy年MM月dd日hh时mm分ss秒 ",new Date())) }; muteIdListShow.push(obj); muteIdList[nn].count = 0; } else { muteIdList[nn].count = String(nextCount); } } else { let nextCount = 1; if (nextCount >= maxCount) { let tmp = await addMuteUser(rid, nn, time); showMessageWindow("禁言信息", "【" + nn + "】已被禁言" + time + "分钟" + "\n弹幕:" + txt, () => {}); let obj = { id: nn, uid: uid, barrage: txt, time: time, count: 1, ts: String(dateFormat("yyyy年MM月dd日hh时mm分ss秒 ",new Date())) }; muteIdListShow.push(obj); } else { muteIdList[nn] = { uid: uid, count: 1, } } } break; } } } } function addMuteUser(roomid, name, ban_time) { return new Promise(resolve => { fetch("https://www.douyu.com/room/roomSetting/addMuteUser", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'ban_nickname=' + name + '&room_id=' + roomid + '&ban_time=' + ban_time + '&reason=7' }).then(res => { return res.json(); }).then(ret => { resolve(ret); }) }) } function deleteMuteUser(roomid, uid) { return new Promise(resolve => { fetch("https://www.douyu.com/room/roomSetting/deleteMuteUser", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'room_id=' + roomid + '&uid=' + uid }).then(res => { return res.json(); }).then(ret => { resolve(ret); }) }) } function getRoomAdminStatus() { return new Promise(resolve => { fetch('https://www.douyu.com/japi/firepower/apinc/roomAdmin/getStatus?rid=' + rid,{ method: 'GET', mode: 'no-cors', credentials: 'include' }).then(res => { return res.json(); }).then(ret => { let result = false; if (ret.error == "0") { if (ret.data.has == "1") { result = true; } else { result = false; } } else { result = false; } resolve(result); }).catch(err => { console.log("请求失败!", err); }) }); } let isReplyOn = false; let replyWordList = {}; function initPkg_LiveTool_Reply() { LiveTool_Reply_insertDom(); LiveTool_Reply_insertFunc(); initPkg_Reply_Set(); } function LiveTool_Reply_insertDom() { let a = document.createElement("div"); a.className = "livetool__cell"; let cell = `
    关键词回复
    `; let panel = `
    `; a.innerHTML = cell + panel; let b = document.getElementsByClassName("livetool")[0]; b.insertBefore(a, b.childNodes[0]); } function LiveTool_Reply_insertFunc() { document.getElementById("reply__switch").addEventListener("click", () => { let ischecked = document.getElementById("reply__switch").checked; if (ischecked == true) { // 开启关键词禁言 isReplyOn = true; } else{ // 关闭关键词禁言 isReplyOn = false; } saveData_isReply(); }); document.getElementById("reply__title").addEventListener("click", () => { let a = document.getElementsByClassName("reply__panel")[0]; if (a.style.display != "block") { a.style.display = "block"; if (rid !== "5189167") { if (document.getElementsByClassName("mute__panel")[0].style.display == "block") { document.getElementsByClassName("mute__panel")[0].style.display = "none"; } } if (document.getElementsByClassName("enter__panel")[0].style.display == "block") { document.getElementsByClassName("enter__panel")[0].style.display = "none"; } if (document.getElementsByClassName("gift__panel")[0].style.display == "block") { document.getElementsByClassName("gift__panel")[0].style.display = "none"; } if (document.getElementsByClassName("vote__panel")[0].style.display == "block") { document.getElementsByClassName("vote__panel")[0].style.display = "none"; } } else { a.style.display = "none"; } }); document.getElementById("reply__select").onclick = function() { if (this.options.length == 0) { return; } let word = this.options[this.selectedIndex].text; let reply = replyWordList[word].reply; document.getElementById("reply__word").value = word; document.getElementById("reply__reply").value = reply; }; document.getElementById("reply__add").addEventListener("click", () => { let select_wordList = document.getElementById("reply__select"); let word = document.getElementById("reply__word").value; let reply = document.getElementById("reply__reply").value; if (word == "") { return; } // 构造json并添加json replyWordList[word] = { reply: reply, } // 添加到select中去 select_wordList.options.add(new Option(word, "")); saveData_Reply(); }); document.getElementById("reply__del").addEventListener("click", () => { let select_wordList = document.getElementById("reply__select"); let word = select_wordList.options[select_wordList.selectedIndex].text; // 删除json内的对象 delete replyWordList[word]; // 删除select里的option select_wordList.options.remove(select_wordList.selectedIndex); saveData_Reply(); }); } function saveData_Reply() { let data = replyWordList; localStorage.setItem("ExSave_Reply", JSON.stringify(data)); // 存储弹幕列表 } function saveData_isReply() { let ridArr = []; let ret = localStorage.getItem("ExSave_isReply"); if (ret != null) { let retJson = JSON.parse(ret); if ("rooms" in retJson == true) { ridArr = retJson.rooms; } } let index = ridArr.indexOf(rid); if (isReplyOn == true) { if (index == -1) { ridArr.push(rid); } } else { ridArr.splice(index, 1); } let data = { rooms: ridArr, }; localStorage.setItem("ExSave_isReply", JSON.stringify(data)); // 存储弹幕列表 } function initPkg_Reply_Set() { // 设置初始化 let ret = localStorage.getItem("ExSave_Reply"); if (ret != null) { let retJson = JSON.parse(ret); replyWordList = retJson; let select_wordList = document.getElementById("reply__select"); for (let key in retJson) { if (retJson.hasOwnProperty(key)) { select_wordList.options.add(new Option(key, "")); } } } ret = localStorage.getItem("ExSave_isReply"); if (ret != null) { let retJson = JSON.parse(ret); let ridArr = []; if ("rooms" in retJson == true) { ridArr = retJson.rooms; } if (ridArr.indexOf(rid) == -1) { isReplyOn = false; } else { isReplyOn = true; } document.getElementById("reply__switch").checked = isReplyOn; } else { isReplyOn = false; document.getElementById("reply__switch").checked = isReplyOn; } } function initPkg_LiveTool_Reply_Handle(text) { if (isReplyOn == false) { return; } if (getType(text) == "chatmsg") { let uid = getStrMiddle(text, "uid@=", "/"); if (uid == my_uid) { // 不算自己 return; } let nn = getStrMiddle(text, "nn@=", "/"); let txt = getStrMiddle(text, "txt@=", "/"); let isConform = false; for (let key in replyWordList) { if (key == "") { continue; } if (key.indexOf("re(") != -1) { // 正则 let regStr = getStrMiddle(key, "re(", ")="); let strArr = key.split("=") if (strArr.length > 1) { let str = strArr[1]; let regObj = new RegExp(regStr, "g"); let result = regObj.exec(txt); if (result.length > 0) { if (result[0] == str) { isConform = true; } else { isConform = false; } } } } else { if (String(txt).indexOf(key) != -1) { isConform = true; } else { isConform = false } } if (isConform == true) { let reply = replyWordList[key].reply; reply = String(reply).replace(//g, nn); reply = String(reply).replace(//g, txt); sendBarrage(reply); break; } } } } var treasureNum = 0; function initPkg_LiveTool_Treasure() { LiveTool_Treasure_insertModal(); } function LiveTool_Treasure_insertModal() { let a = document.createElement("div"); a.className = "livetool__Treasure"; a.id = "Ex_Geetest"; let b = document.getElementsByClassName("Barrage-main")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_LiveTool_Treasure_Handle(text) { if (isGetTreasure == false) { return; } if (getType(text) == "tsboxb") { let ot = getStrMiddle(text, "ot@=", "/"); let rpid = getStrMiddle(text, "rpid@=", "/"); let rid = getStrMiddle(text, "rid@=", "/"); let did = getCookieValue("dy_did"); let timeout = Number(ot) - Math.floor(Date.now()/1000); timeout = timeout * 1000 + getTreasureDelay(); treasureNum++; let a = document.createElement("div"); let idName = "Ex_Geetest_no" + String(treasureNum); a.id = idName; let b = document.getElementById("Ex_Geetest"); b.appendChild(a); setTimeout(() => { getTreasure(rid, rpid, did, idName); }, timeout); } } function getTreasure(roomid, rpid, deviceid, idName) { GM_xmlhttpRequest({ method: "POST", url: "https://pcapi.douyucdn.cn/h5nc/member/getRedPacket?token=" + dyToken, data: "room_id=" + roomid + "&package_room_id=" + roomid + "&device_id=" + deviceid + "&packerid=" + rpid + "&version=1", responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.data.code == "-1" && ret.data.validate != "0") { let v = JSON.parse(ret.data.geetest.validate_str); let success = v.success; let challenge = v.challenge; let gt = v.gt; let skey = getTreasureSkey(); if (skey != "") { let url = window.location.href; getTreasure_Auto(skey, gt, challenge, url, deviceid, rpid, roomid); return; } let handler = (e) => { showMessageWindow(rid, "【宝箱】请手动验证领取宝箱", () => { window.focus(); }); let idDiv = document.getElementById(idName); e.appendTo("#" + idName); e.onSuccess(() => { let result = e.getValidate(); let geetest_challenge = result.geetest_challenge; let geetest_seccode = result.geetest_seccode; let geetest_validate = result.geetest_validate; let data = "room_id=" + roomid + "&package_room_id=" + roomid + "&device_id=" + deviceid + "&packerid=" + rpid + "&version=1"; data = data + "&geetest_challenge=" + geetest_challenge + "&geetest_validate=" + geetest_validate + "&geetest_seccode=" + encodeURIComponent(geetest_seccode); GM_xmlhttpRequest({ method: "POST", url: "https://pcapi.douyucdn.cn/h5nc/member/getRedPacket?token=" + dyToken, data: data, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; let msg = ""; if (ret.data.prop_id == "") { msg = "鱼丸x" + ret.data.silver; } else { msg = ret.data.prop_name + "x" + ret.data.prop_count; } if (msg != "") { showMessage("【宝箱】获得" + msg, "success"); } if (idDiv != null) { idDiv.remove(); } } }); }); }; if (unsafeWindow.initGeetest != undefined) { unsafeWindow.initGeetest({ gt: gt, challenge: challenge, offline: !success, product: "float", }, handler); } else { showMessage("自动抢宝箱初始化失败", "error"); } } else if(ret.data.msg != "领取失败" && ret.data.msg != "验证码不正确") { let msg = ""; if (ret.data.prop_id == "") { msg = "鱼丸x" + ret.data.silver; } else { msg = ret.data.prop_name + "x" + ret.data.prop_count; } if (msg != "") { showMessage("【宝箱】获得" + msg, "success"); } } else { showMessage("【宝箱】领取失败", "error"); } } }); } function getTreasure_Verify(challenge, validate, seccode, divId) { let data = "room_id=" + roomid + "&package_room_id=" + roomid + "&device_id=" + deviceid + "&packerid=" + rpid + "&version=1"; data += "&geetest_challenge=" + challenge + "&geetest_validate=" + validate + "&geetest_seccode=" + encodeURIComponent(seccode); GM_xmlhttpRequest({ method: "POST", url: "https://pcapi.douyucdn.cn/h5nc/member/getRedPacket?token=" + dyToken, data: data, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (document.getElementById(divId) != null) { document.getElementById(divId).remove(); } } }); } function getTreasure_Auto(skey, gt, challenge, referer, deviceid, rpid, roomid) { let wtype = "geetest"; let data = "wtype=" + wtype + "&secretkey=" + skey + ">=" + gt + "&referer=" + referer + "&challenge=" + challenge + "&supporttype=3"; GM_xmlhttpRequest({ method: "POST", url: "http://api.ddocr.com/api/gateway.jsonp", data: data, timeout: 60000, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.status == "-1") { showMessage("【宝箱】自动识别失败", "error"); return; } let data = "room_id=" + roomid + "&package_room_id=" + roomid + "&device_id=" + deviceid + "&packerid=" + rpid + "&version=1"; data = data + "&geetest_challenge=" + ret.data.challenge + "&geetest_validate=" + ret.data.validate + "&geetest_seccode=" + ret.data.validate + "%7Cjordan"; GM_xmlhttpRequest({ method: "POST", url: "https://pcapi.douyucdn.cn/h5nc/member/getRedPacket?token=" + dyToken, data: data, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.data.code == "-1") { showMessage("【宝箱】验证码不正确", "error") return; } let msg = ""; if (ret.data.prop_id == "") { msg = "鱼丸x" + ret.data.silver; } else { msg = ret.data.prop_name + "x" + ret.data.prop_count; } if (msg != "") { showMessage("【宝箱】获得" + msg, "success"); } } }); } }); } let isVoteOn = false; let voteList = {}; let voteNameList = {}; let voteWordList = {}; let voteTotalNum = 0; let timer_Vote; let isRepeat = false; function initPkg_LiveTool_Vote() { LiveTool_Vote_insertDom(); LiveTool_Vote_insertDom_VotePanel(); LiveTool_Vote_insertFunc(); initPkg_Vote_Set(); } function LiveTool_Vote_insertDom() { let a = document.createElement("div"); a.className = "livetool__cell"; let cell = `
    弹幕投票面板
    `; let panel = `
    `; a.innerHTML = cell + panel; let b = document.getElementsByClassName("livetool")[0]; b.insertBefore(a, b.childNodes[0]); } function LiveTool_Vote_insertFunc() { document.getElementById("vote__switch").addEventListener("click", () => { let ischecked = document.getElementById("vote__switch").checked; let selectDom = document.getElementById("vote__select"); let title = selectDom.options[selectDom.selectedIndex].text; let options = voteList[title].options; let time = voteList[title].time; if (ischecked == true) { // 开启关键词禁言 let arr = String(options).split(" "); for (let i = 0; i < arr.length; i++) { voteWordList[arr[i]] = { num: 0, index: i }; } document.getElementById("vote__repeat").disabled = true; voteTotalNum = 0; initVoteOptionsPanel(title, options); isRepeat = document.getElementById("vote__repeat").checked; isVoteOn = true; timer_Vote = setTimeout(() => { voteNameList = {}; voteWordList = {}; isVoteOn = false; document.getElementById("vote__repeat").disabled = false; document.getElementById("vote__switch").checked = false; }, time * 1000); document.getElementsByClassName("vote__result")[0].style.display = "block"; } else{ // 关闭关键词禁言 clearTimeout(timer_Vote); voteNameList = {}; voteWordList = {}; isVoteOn = false; document.getElementById("vote__repeat").disabled = false; } }); document.getElementById("vote__title").addEventListener("click", () => { let a = document.getElementsByClassName("vote__panel")[0]; if (a.style.display != "block") { a.style.display = "block"; if (rid !== "5189167") { if (document.getElementsByClassName("mute__panel")[0].style.display == "block") { document.getElementsByClassName("mute__panel")[0].style.display = "none"; } } if (document.getElementsByClassName("enter__panel")[0].style.display == "block") { document.getElementsByClassName("enter__panel")[0].style.display = "none"; } if (document.getElementsByClassName("gift__panel")[0].style.display == "block") { document.getElementsByClassName("gift__panel")[0].style.display = "none"; } if (document.getElementsByClassName("reply__panel")[0].style.display == "block") { document.getElementsByClassName("reply__panel")[0].style.display = "none"; } } else { a.style.display = "none"; } }); document.getElementById("vote__select").onclick = function() { if (this.options.length == 0) { return; } let title = this.options[this.selectedIndex].text; let options = voteList[title].options; let time = voteList[title].time; document.getElementById("vote__theme").value = title; document.getElementById("vote__options").value = options; document.getElementById("vote__time").value = time; }; document.getElementById("vote__add").addEventListener("click", () => { let select_wordList = document.getElementById("vote__select"); let title = document.getElementById("vote__theme").value; let options = document.getElementById("vote__options").value; let time = document.getElementById("vote__time").value; if (title == "" || options == "" || time == "") { return; } // 构造json并添加json voteList[title] = { options: options, time: time } // 添加到select中去 select_wordList.options.add(new Option(title, "")); saveDate_Vote(); }); document.getElementById("vote__del").addEventListener("click", () => { let select_wordList = document.getElementById("vote__select"); let title = select_wordList.options[select_wordList.selectedIndex].text; // 删除json内的对象 delete voteList[title]; // 删除select里的option select_wordList.options.remove(select_wordList.selectedIndex); saveDate_Vote(); }); document.getElementById("vote__show-result").addEventListener("click", () => { let a = document.getElementsByClassName("vote__result")[0]; if (a.style.display != "block") { a.style.display = "block"; } else { a.style.display = "none"; } }) } function initPkg_Vote_Set() { document.getElementById("vote__switch").checked = isReplyOn; // 设置初始化 let ret = localStorage.getItem("ExSave_Vote"); if (ret != null) { let retJson = JSON.parse(ret); voteList = retJson; let select_wordList = document.getElementById("vote__select"); for (let key in retJson) { if (retJson.hasOwnProperty(key)) { select_wordList.options.add(new Option(key, "")); } } } } function initPkg_LiveTool_Vote_Handle(text) { if (isVoteOn == false) { return; } if (getType(text) == "chatmsg") { let uid = getStrMiddle(text, "uid@=", "/"); let txt = getStrMiddle(text, "txt@=", "/"); if (isRepeat) { if (Object(voteWordList).hasOwnProperty(txt)) { voteWordList[txt].num++; voteTotalNum++; changeOptionsData(); } } else { if (Object(voteNameList).hasOwnProperty(uid) == false) { if (Object(voteWordList).hasOwnProperty(txt)) { voteNameList[uid] = 0; voteWordList[txt].num++; voteTotalNum++; changeOptionsData(); } } } } } function saveDate_Vote() { let data = voteList; localStorage.setItem("ExSave_Vote", JSON.stringify(data)); // 存储弹幕列表 } function LiveTool_Vote_insertDom_VotePanel() { let a = document.createElement("div"); a.className = "vote__result"; let panel = `
    投票主题
    X
    `; a.innerHTML = panel; let b = document.getElementsByClassName("layout-Player-main")[0]; b.insertBefore(a, b.childNodes[0]); let box = document.getElementsByClassName("vote__result")[0]; box.onmousedown = function (event) { event.stopPropagation(); let xx = event.clientX - box.offsetLeft; let yy = event.clientY - box.offsetTop; let mouseX; let mouseY; document.onmousemove = function (event) { event.stopPropagation(); mouseX = event.clientX - xx; mouseY = event.clientY - yy; box.style.left = mouseX + "px"; box.style.top = mouseY + "px"; } document.onmouseup = function (event) { event.stopPropagation(); document.onmousemove = null; document.onmouseup = null; } } document.getElementById("vote__result-close").addEventListener("click", () => { document.getElementsByClassName("vote__result")[0].style.display = "none"; }) } function initVoteOptionsPanel(theme, options) { // 设置标题 document.getElementById("vote__result-theme").innerText = theme; // 设置结果面板 document.getElementById("vote__result-options").innerHTML = ""; // 清空信息面板 setVoteOptionsDom(options); } function setVoteOptionsDom(options) { let arr = options.split(" "); let b = document.getElementById("vote__result-options"); for (let i = 0; i < arr.length; i++) { let a = document.createElement("div"); a.className = "vote__option-wrap"; a.innerHTML = `
    ${ arr[i] }
    `; b.appendChild(a); } } function changeOptionsData() { for (const key in voteWordList) { let item = voteWordList[key]; let domNum = document.getElementsByClassName("vote__option-num")[item.index]; let domBar = document.getElementsByClassName("vote__progress-bar")[item.index]; let percent = String(Number(Number(item.num / voteTotalNum) * 100).toFixed(1)) + "%"; domNum.innerText = `${ item.num }(${ percent })`; domBar.style.width = percent; } } function initPkg_MiniProgram() { initPkg_MiniProgram_Dom(); initPkg_MiniProgram_Func(); } function initPkg_MiniProgram_Dom() { MiniProgram_insertIcon(); MiniProgram_insertModal(); } function MiniProgram_insertIcon() { let a = document.createElement("div"); a.className = "MiniProgram"; a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function MiniProgram_insertModal() { let a = document.createElement("div"); a.className = "miniprogram__panel"; a.innerHTML = `
    DouyuEx移动端上线啦
    微信扫码或搜索DouyuEx
    ↓ 即刻体验 ↓
    `; let b = document.getElementsByClassName("PlayerToolbar-Wealth")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_MiniProgram_Func() { document.getElementsByClassName("MiniProgram")[0].addEventListener("click", function() { let a = document.getElementsByClassName("miniprogram__panel")[0]; if (a.style.display != "block") { a.style.display = "block"; } else { a.style.display = "none"; } }); } let svg_night = ''; let svg_day = ''; let currentMode = 0; // 0日间模式 1夜间模式 function initPkg_Night() { initPkg_Night_Dom(); initPkg_Night_Func(); initPkg_Night_Set(); } function initPkg_Night_Dom() { Night_insertIcon(); } function Night_insertIcon() { let a = document.createElement("div"); a.style = "position: absolute;right: -75px;top: 18px;cursor: pointer;" a.id = "ex-night"; a.innerHTML = svg_day; a.title = "切换夜间模式"; let b = document.getElementsByClassName("Header-right")[0]; b.appendChild(a); } function saveData_Mode() { // 0日间模式 1夜间模式 let data = { mode: currentMode } localStorage.setItem("ExSave_Mode", JSON.stringify(data)); } function initPkg_Night_Set_Fast() { let ret = localStorage.getItem("ExSave_Mode"); if (ret != null) { let retJson = JSON.parse(ret); if ("mode" in retJson == false) { retJson.mode = 0; } if (retJson.mode == 1) { setNightMode(); } } } function initPkg_Night_Set() { let ret = localStorage.getItem("ExSave_Mode"); let a = document.getElementById("ex-night"); if (ret != null) { let retJson = JSON.parse(ret); if ("mode" in retJson == false) { retJson.mode = 0; } if (retJson.mode == 1) { currentMode = 1; a.innerHTML = svg_night; a.title = "切换日间模式"; // setNightMode(); } } } function initPkg_Night_Func() { document.getElementById("ex-night").addEventListener("click", function() { let a = document.getElementById("ex-night"); if (currentMode == 0) { currentMode = 1; a.innerHTML = svg_night; a.title = "切换日间模式"; setNightMode(); } else { currentMode = 0; a.innerHTML = svg_day; a.title = "切换夜间模式"; cancelNightMode(); } saveData_Mode(); }); } function setNightMode() { let cssText = ` .layout-Player-barrage,.Barrage--paddedBarrage,.Barrage-firstCharge,.Barrage-notice--replyBarrage{background-color:rgba(37,38,42,1) !important;} .Barrage-userEnter{background-color:rgba(37,38,42,1) !important;color:rgba(187,187,187,1) !important;} /*.Barrage-content,.Barrage-text{color:rgba(187,187,187,1) !important;}*/ .Barrage-content,.Barrage-text{color:rgba(187,187,187,1);} .Barrage-notice--noble{background-color:rgba(37,38,42,1) !important;border:rgba(37,38,42,1) solid 1px !important;} .layout-Player-title{background-color:rgba(35,36,39,1) !important;border:rgba(35,36,39,1) solid 1px !important;} .Title-header{color:rgba(191,191,191,1) !important;} .Title-anchorText{color:rgba(107,176,125,1) !important;} .Title-row-text,.Title-anchorName{color:rgba(153,153,153,1) !important;} #js-player-toolbar{background:rgb(37,38,42) !important;border:1px solid rgb(37,38,42) !important;} .PlayerToolbar-wealthNum,.Header-wrap .Header-menu-link>a,.public-DropMenu-link,.Header-icon{color:rgb(191,191,191) !important;} .layout-Main{background-color:rgba(35,36,39,1) !important;} .ChatRank-rankWraper{background:rgba(47,48,53,1) !important;border:rgba(47,48,53,1) solid 1px !important;} .bg-icon{display:none;} .ChatRankWeek-headerContent,.NobleRank,.NobleRankTips{background-color:rgba(47,48,53,1) !important;} #js-player-asideMain{border:1px solid rgba(37,38,42,1) !important;background-color:rgb(47,48,53) !important;} .Chat,.ChatSend-txt{background:rgba(47,48,53,1) !important;color:rgb(187,187,187) !important;border-radius:0px !important;} .ChatTabContainer-titleWraper--tabLi{background:rgb(29,32,35) !important;border:1px solid rgb(47,48,53) !important;} .ChatTabContainer-titleWraper--tabLi.is-active,.ChatBarrageCollect-tip,.FansRankInfo{background:rgb(47,48,53) !important;} .FansRankInfo-txt{color:rgb(121,127,137) !important;} .Barrage{border:1px solid rgba(35,36,39,1) !important;} .layout-Player-chat{border-top:1px solid rgba(47,48,53,1) !important;} .layout-Player-announce{background-color:rgb(29,32,35) !important;border:1px solid rgb(29,32,35) !important;} .FansRankBottom,.AnchorFriend-footer{border-top:1px solid rgb(121,127,137) !important;} .Title-official{background:rgb(35,36,39) !important;} .Header-wrap{background:rgb(45,46,54) !important;border-bottom:1px solid rgb(45,46,54) !important;} .layout-Menu{background:rgb(47,48,53) !important;border-color:rgb(35,36,39) !important;} .GuessMainPanel{background:rgba(47,48,53,0.9) !important;border:1px solid rgb(47,48,53) !important;} .danmuAuthor-3d7b4a{color:rgb(234,234,234) !important;} .danmudiv-32f498{background:rgba(47,49,53,0.9) !important;} .danmuContent-25f266{background:rgba(35,36,39,0.9) !important;} .word-89c053{background:rgba(35,36,39,0.9) !important;color:rgb(187,187,187) !important;} .FansMedalPanel-Panel{color:black !important;} .AnchorLike-ItemBox,.AnchorFriendPane-content,.SociatyLabelPop-content{border:1px solid rgb(35,36,39) !important;} .AnchorFriendCard-info>h3,.GiftExpandPanel-descName,.GiftInfoPanel-name,.FansMedalInfo-titleL,.SociatyAnchorCard-info>h3{color:rgb(204,204,204) !important;} .GuessReturnYwFdSlider{background:rgba(47,48,53,0.7); !important;border-left:1px solid rgb(35,36,39) !important;} .GuessGuideList-itemBox,.GuessGuideList-moreGuess{background-color:rgba(47,48,53) !important;color:rgb(204,204,204) !important;} .AnchorFriend-footer a{background-color:rgb(47,48,53) !important;color:rgb(204,204,204) !important;} .AnchorFriendPane-title{border-bottom:1px solid rgb(121,127,137) !important;background-color:rgb(35,36,39) !important;} .AnchorLike-friendList .AnchorFriendPane-title h3,.Title svg{color:rgb(153,153,153) !important;} .GiftExpandPanel{background-color:rgb(35,36,39) !important;border:1px solid rgb(35,36,39) !important;} .GiftInfoPanel-cont{background-color:rgb(35,36,39) !important;border:1px solid rgb(35,36,39) !important;} .BatchGiveForm-num{background-color:rgb(35,36,39) !important;} .BatchGiveForm-input{background-color:rgb(35,36,39) !important;color:rgb(149,149,149) !important;} .BatchGiveForm-btn,.Backpack-prop.is-blank,.GuessMainPanel-sliderItem{background-color:rgb(47,48,53) !important;} .Backpack{background-color:rgb(35,36,39) !important;border:1px solid rgb(35,36,39) !important;} .Backpack-name,.NormalCard-btn,.NormalCard-close,.NobleCard-close,.ReportButton-41fa9e,.HideButton-d22988,.txtHidden-486e56,.BackpackInfoPanel-name,.NormalCard-name{color:rgb(187,187,187) !important;} .Backpack-propPage,.BatchProp-content{background-color:rgb(35,36,39) !important;color:rgb(149,149,149)!important;} .BackpackInfoPanel-content{background-color:rgb(35,36,39) !important;border:1px solid rgb(35,36,39) !important;} .BatchProp-customIpt,.BatchGiveForm-num,.GiftInfoPanel-intro{color:rgb(149,149,149) !important;} .GuessReturnYwFdSlider-numIptWrap,.GuessReturnYwFdSlider-numIpt{background-color:rgb(47,48,53) !important;color:rgb(149,149,149) !important;} .GuessReturnYwFdSlider-giftName{color:rgb(160,160,160) !important;} .NormalCard-common,.GuessRankPanel{background-color:rgb(47,48,53) !important;border:1px solid rgb(47,48,53) !important;} .FansMedalPanel-OwnerInfo,.FansMedalPanel-list{background-color:rgb(47,48,53) !important;color:rgb(187,187,187) !important;} .FansMedalList-item:hover{background-color:rgb(37,38,42) !important;} .AnchorFriend-content,.SociatyAnchor-content{background-color:rgb(35,36,39) !important;border-top:1px solid rgb(35,36,39) !important;} .SociatyLabelPop-title{border-bottom:1px solid rgb(121,127,137) !important;background-color:rgb(35,36,39) !important;color:rgb(153,153,153) !important;} .Barrage-nickName{color:rgb(255,119,0) !important;} .wm-general-wrapper{background:rgb(35,36,39) !important;} .ChatRank-rankWraper .ChatRankTab-title.is-active{color:rgb(255,119,0)!important;} .ChatRank-rankWraper .ChatRankTab-title{color:rgb(131,140,154)!important;background:rgb(29,32,35)!important;border:1px solid rgb(47,48,53)!important;} .MatchTeamRankList-topAvatar{background:rgb(47,48,53)!important;} .MatchTeamRankList-topName{color:rgb(131,140,154)!important;background-color:rgb(47,48,53)!important;} .MatchTeamRankTitle-content{background:rgb(47,48,53)!important;color:rgb(131,140,154)!important;} .MatchTeamRankBottom{background:rgb(47,48,53) !important;} .MatchTeamRankBottom-lable{color:rgb(131,140,154);} .MatchTeamRankBottom-desc{color:rgb(121,127,137);} .Barrage-text>a,.Barrage-firstCharge{color:rgb(187,187,187)!important;} .GuessMainPanelHeader-slogon{color:rgb(204,204,204)!important;} .Barrage-hitYwGame--text{color:rgb(187,187,187)!important;} .AnchorFriendPane-title h3{color:rgb(153,153,153)!important;} .Barrage-nickName.is-self{color:rgb(255,0,51)!important;} .barragePanel__funcPanel{background:rgba(47,49,53,0.9) !important;} .layui-text{color:rgb(187,187,187) !important;} .GuessReturnYwFdSlider-ywNum{color:rgb(237,90,101) !important;} .VideoBottomTabs span{color:rgb(204,204,204)} #point__value{color:rgb(191,191,191) !important;} #red_envelope_text,#red_envelope_query{color:rgb(191,191,191) !important;} .layout-Container{background-color:rgb(35,36,39) !important;} .FansRankBottom-invisible,.ChatRankWeek-invisibleContent{background:rgb(47,48,53) !important;} .Barrage-roomVip--super{border-top: 1px solid rgb(37,38,42)!important;border-bottom: 1px solid rgb(37,38,42)!important;background: rgb(37,38,42)!important;} .Barrage-userEnter--vip{background: rgb(37,38,42)!important;} `; StyleHook_set("Ex_Style_NightMode", cssText); } function cancelNightMode() { StyleHook_remove("Ex_Style_NightMode"); } function initPkg_Point() { initPkg_Point_insertDom(); initPkg_Point_Func(); initPkg_Point_Constructor(); initPkg_Point_Module(); } function initPkg_Point_Module() { initPkg_Point_PointPanel(); } function initPkg_Point_insertDom() { let a = document.createElement("div"); a.id = "ex-point"; a.innerHTML = ` 💗 积分 `; let b = document.getElementsByClassName("PlayerToolbar-Wealth")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_Point_Func() { document.getElementById("ex-point").addEventListener("click", () => { let a = document.getElementsByClassName("point__panel")[0]; if (a.style.display != "block") { a.style.display = "block"; } else { a.style.display = "none"; } }) } async function initPkg_Point_Constructor() { let ret = await getUserPoint(dyToken); let valueDom = document.getElementById("point__value"); if (ret.error == "0") { valueDom.className = ""; valueDom.innerText = ret.data[0].point; document.getElementById("ex-point").title = `更新时间:${ ret.data[0].update_time }`; } else if (ret.error == "2") { alert(ret.msg); } else { valueDom.className = ""; valueDom.innerText = "0"; } } async function updateUserPoint() { let ret = await getUserPoint(dyToken); let valueDom = document.getElementById("point__value"); if (ret.error == "0") { valueDom.className = ""; valueDom.innerText = ret.data[0].point; document.getElementById("ex-point").title = `更新时间:${ ret.data[0].update_time }`; showMessage("【积分系统】积分更新完毕", "success"); } else if (ret.error == "2") { alert(ret.msg); } else { valueDom.className = ""; valueDom.innerText = "0"; } } function getUserPoint(token) { // 获取用户积分 return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "http://122.51.5.63:27999/douyu/point/5189167/query_by_uid", data: "token=" + token, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; resolve(ret); } }); }) } function getItemList(token) { // 获取物品列表 return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "http://122.51.5.63:27999/douyu/point/5189167/query_item", data: "token=" + token, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; resolve(ret); } }); }) } function exchangeItem(token, item_id, id, info) { // 兑换物品 return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "http://122.51.5.63:27999/douyu/point/5189167/exchange", data: "token=" + token + "&item_id=" + item_id + "&id=" + id + "&info=" + info, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; resolve(ret); } }); }) } function getExchangeRecord(token, offset) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "http://122.51.5.63:27999/douyu/point/5189167/query_exchange", data: "token=" + token + "&offset=" + offset, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; resolve(ret); } }); }) } function getPointList(token) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "http://122.51.5.63:27999/douyu/point/5189167/point_list", data: "token=" + token, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; resolve(ret); } }); }) } function initPkg_Point_PointExchange() { initPkg_Point_PointExchange_insertDom(); initPkg_Point_PointExchange_insertFunc(); } function initPkg_Point_PointExchange_insertDom() { renderExchangePanel(); } function initPkg_Point_PointExchange_insertFunc() { } async function renderExchangePanel() { if (document.getElementById("ex-exchange") !== null) { return; } let ret = await getItemList(dyToken); if (ret.error != "0") { showMessage("【积分系统】获取物品列表失败:" + ret.msg, "error"); return; } if (ret.data == null) { showMessage("【积分系统】暂无可兑换的物品", "error"); return; } let a = document.createElement("div"); a.id = "ex-exchange"; let html = `
    X
    `; for (let i = 0; i < ret.data.length; i++) { html = html + `
    ${ ret.data[i].name } ${ ret.data[i].description } 剩余 ${ ret.data[i].num } 件 💗${ ret.data[i].price }
    兑换
    `; } html = html + "
    "; a.innerHTML = html; let b = document.getElementsByClassName("PlayerToolbar-Wealth")[0]; b.insertBefore(a, b.childNodes[0]); bindExchangePanel(ret); } function bindExchangePanel(itemJson) { let dom = document.getElementsByClassName("item__exchange"); for (let i = 0; i < dom.length; i++) { dom[i].onclick = () => { exchangeItemEvent(itemJson.data[i].id, itemJson.data[i].num, itemJson.data[i].price); } } document.getElementsByClassName("exchange__close")[0].onclick = () => { let a = document.getElementById("ex-exchange"); if (a !== null) { a.remove(); } } } async function exchangeItemEvent(item_id, item_num, item_price){ if (item_num <= 0) { showMessage("【积分系统】兑换失败:物品数量不足", "error"); return; } let currentPoint = document.getElementById("point__value").innerText; if (currentPoint - item_price < 0) { showMessage("【积分系统】兑换失败:积分不足", "error"); return; } showPrompt("请填写备注信息(联系方式/收货地址)",async (info) => { if (info == "") { showMessage("【积分系统】兑换失败:未填写备注信息", "error"); return; } let id = await getUserName(); let ret = await exchangeItem(dyToken, item_id, id, info); if (ret.error == "0") { showMessage("【积分系统】" + ret.msg, "success"); if (ret.data.length > 0) { document.getElementById("point__value").innerText = ret.data[0].point; document.getElementById("ex-point").title = `更新时间:${ ret.data[0].update_time }`; } } else { showMessage("【积分系统】" + ret.msg, "error"); } }, () => {return}); } function initPkg_Point_PointList() { initPkg_Point_PointList_insertDom(); } function initPkg_Point_PointList_insertDom() { renderPointList(); } function initPkg_Point_PointList_insertFunc() { document.getElementsByClassName("pointlist__close")[0].onclick = () => { let a = document.getElementById("ex-pointlist"); if (a !== null) { a.remove(); } } } async function renderPointList() { if (document.getElementById("ex-pointlist") !== null) { return; } let ret = await getPointList(dyToken); if (ret.error != "0") { showMessage("【积分系统】获取积分榜失败:" + ret.msg, "error"); return; } if (ret.data == null) { showMessage("【积分系统】积分榜暂无数据", "error"); return; } let a = document.createElement("div"); a.id = "ex-pointlist"; let html = `
    X
    `; for (let i = 0; i < ret.data.length; i++) { html = html + ` `; } html = html + "
    排名 昵称 积分
    ${ i + 1 } ${ ret.data[i].id } ${ ret.data[i].point }
    "; a.innerHTML = html; let b = document.getElementsByClassName("PlayerToolbar-Wealth")[0]; b.insertBefore(a, b.childNodes[0]); // 异步函数所以要把绑定函数放在最后 initPkg_Point_PointList_insertFunc(); } function initPkg_Point_PointPanel() { initPkg_Point_PointPanel_insertDom(); initPkg_Point_PointPanel_insertFunc(); } function initPkg_Point_PointPanel_insertDom() { let a = document.createElement("div"); a.className = "point__panel"; a.innerHTML = `
    更新积分
    积分榜
    兑换物品
    兑换记录
    积分规则
    `; let b = document.getElementsByClassName("PlayerToolbar-Wealth")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_Point_PointPanel_insertFunc() { document.getElementById("panel__update").addEventListener("click", () => { closePointPanel(); updateUserPoint(); }); document.getElementById("panel__pointlist").addEventListener("click", () => { closePointPanel(); initPkg_Point_PointList(); }); document.getElementById("panel__exchange").addEventListener("click", async () => { closePointPanel(); initPkg_Point_PointExchange(); }); document.getElementById("panel__record").addEventListener("click", async () => { closePointPanel(); initPkg_Point_PointRecord(); }); document.getElementById("panel__rules").addEventListener("click", async () => { closePointPanel(); openPage("https://qianjiachun.github.io/DouyuEx/rules", true); }); } function closePointPanel() { document.getElementsByClassName("point__panel")[0].style.display = "none"; } let currentOffset = 0; let maxOffset = 99999; function initPkg_Point_PointRecord() { currentOffset = 0; initPkg_Point_PointRecord_insertDom(); initPkg_Point_PointRecord_insertFunc(); } function initPkg_Point_PointRecord_insertDom() { renderRecordWrap(); renderRecord(currentOffset); } function initPkg_Point_PointRecord_insertFunc() { document.getElementsByClassName("record__close")[0].onclick = () => { let a = document.getElementById("ex-record"); if (a !== null) { a.remove(); } } document.getElementsByClassName("record__prev")[0].onclick = () => { if (currentOffset < 10) { showMessage("【积分系统】兑换系统已到首页", "error"); return; } currentOffset = currentOffset - 10; renderRecord(currentOffset); } document.getElementsByClassName("record__next")[0].onclick = () => { if (currentOffset >= maxOffset) { showMessage("【积分系统】兑换系统已到尾页", "error"); return; } currentOffset = currentOffset + 10; renderRecord(currentOffset); } } function renderRecordWrap() { if (document.getElementById("ex-record") !== null) { return; } let a = document.createElement("div"); a.id = "ex-record"; let html = `
    X
    上一页
    下一页
    `; a.innerHTML = html; let b = document.getElementsByClassName("PlayerToolbar-Wealth")[0]; b.insertBefore(a, b.childNodes[0]); } async function renderRecord(offset) { let dom = document.getElementsByClassName("records__wrap"); if (dom.length <= 0) { return; } dom[0].innerHTML = ""; let recordList = await getExchangeRecord(dyToken, offset); if (recordList.error != "0") { showMessage("【积分系统】" + recordList.msg, "error"); return; } if (recordList.data == null) { maxOffset = currentOffset; showMessage("【积分系统】无兑换记录", "error"); return; } let html = ""; for (let i = 0; i < recordList.data.length; i++) { html += `
    (${ recordList.data[i].status=="1"?"已发货":"未发货" })${ recordList.data[i].item_name }
    ${ recordList.data[i].update_time }
    💗${ recordList.data[i].price }
    `; } dom[0].innerHTML = html; bindRecord(recordList); } function bindRecord(recordJson) { let dom = document.getElementsByClassName("record__wrap"); for (let i = 0; i < dom.length; i++) { dom[i].onclick = () => { PostbirdAlertBox.alert({ 'title': '备注信息', 'content': recordJson.data[i].info, 'okBtn': '确定', 'contentColor': 'rgb(51,51,51)', }); } } } var videoPlayerArr = []; function initPkg_PopupPlayer() { initPkg_PopupPlayer_Dom(); initPkg_PopupPlayer_Func(); } function initPkg_PopupPlayer_Dom() { PopupPlayer_insertIcon(); PopupPlayer_insertPrompt(); } function PopupPlayer_insertIcon() { let a = document.createElement("div"); a.className = "popup-player"; a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function PopupPlayer_insertPrompt() { let a = document.createElement("div"); let html = ""; a.className = "postbird-box-container"; a.id = "popup-player__prompt" html += '
    '; html += '
    '; html += '
    '; html += '请输入直播间地址:'; html += '
    '; // header html += '
    '; html += ''; html += ''; html += ''; html += '
    '; // text html += '
    ' a.innerHTML = html; let b = document.getElementsByClassName("layout-Main")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_PopupPlayer_Func() { document.getElementsByClassName("popup-player")[0].addEventListener("click", function () { document.getElementById("popup-player__prompt").style.display = "block"; }); document.getElementById("popup-player__cancel").addEventListener("click", function() { document.getElementById("popup-player__prompt").style.display = "none"; }) document.getElementById("popup-player__ok").addEventListener("click", function() { let roomUrl = document.getElementById("popup-player__url").value; if (roomUrl != "") { let isIframe = document.getElementById("popup-player__noiframe").checked; if (isIframe == true) { if (roomUrl.indexOf("douyu.com") != -1) { getRealRid_Douyu(roomUrl, (rid) => { createNewVideo(videoPlayerArr.length, rid, "Douyu"); }); } else if (roomUrl.indexOf("bilibili.com") != -1) { getRealRid_Bilibili(roomUrl, (rid) => { createNewVideo(videoPlayerArr.length, rid, "Bilibili"); }); } else if (roomUrl.indexOf("huya.com") != -1) { createNewVideo(videoPlayerArr.length, roomUrl, "Huya"); } } else { createNewVideo_iframe(videoPlayerArr.length, roomUrl); } } else { showMessage("请输入地址", "error"); } document.getElementById("popup-player__prompt").style.display = "none"; }) document.getElementById("popup-player__prompt").addEventListener("keydown", function(event) { let theEvent = window.event || e; let code = theEvent.keyCode || theEvent.which || theEvent.charCode; if (code == 13) { document.getElementById("popup-player__ok").click(); } }) } function createNewVideo(id, rid, platform) { switch (platform) { case "Douyu": createNewVideo_Douyu(id, rid); break; case "Bilibili": createNewVideo_Bilibili(id, rid); break; case "Huya": let a = String(rid).split("/"); createNewVideo_Huya(id, rid, a[a.length - 1]); break; default: createNewVideo_Douyu(id, rid); break; } } function setElementVideo(id, l) { if (flvjs.isSupported()) { var videoElement = document.getElementById("exVideoPlayer" + String(id)); var flvPlayer = flvjs.createPlayer({ type: 'flv', url: l },{fixAudioTimestampGap: false}); if (id > videoPlayerArr.length - 1) { videoPlayerArr.push(flvPlayer); } else { videoPlayerArr[id] = flvPlayer; } flvPlayer.attachMediaElement(videoElement); flvPlayer.load(); flvPlayer.play(); } } function setElementResize(id) { let box = document.getElementById("exVideoDiv" + String(id)); let scale = document.getElementById("exVideoScale" + String(id)); scale.onmousedown = function (e) { // 阻止冒泡,避免缩放时触发移动事件 e.stopPropagation(); e.preventDefault(); let pos = { 'w': box.offsetWidth, 'h': box.offsetHeight, 'x': e.clientX, 'y': e.clientY }; let w; let h; document.onmousemove = function (ev) { ev.stopPropagation(); ev.preventDefault(); w = Math.max(300, ev.clientX - pos.x + pos.w) h = Math.max(150, ev.clientY - pos.y + pos.h) w = w >= document.offsetWidth - box.offsetLeft ? document.offsetWidth - box.offsetLeft : w h = h >= document.offsetHeight - box.offsetTop ? document.offsetHeight - box.offsetTop : h box.style.width = w + 'px'; box.style.height = h + 'px'; } document.onmouseup = function (e) { e.stopPropagation(); e.preventDefault(); document.onmousemove = null; document.onmouseup = null; } } } function setElementDrag(id) { let box = document.getElementById("exVideoDiv" + String(id)); box.onmousedown = function (event) { event.stopPropagation(); let xx = event.clientX - box.offsetLeft; let yy = event.clientY - box.offsetTop; let mouseX; let mouseY; document.onmousemove = function (event) { event.stopPropagation(); mouseX = event.clientX - xx; mouseY = event.clientY - yy; box.style.left = mouseX + "px"; box.style.top = mouseY + "px"; } document.onmouseup = function (event) { event.stopPropagation(); document.onmousemove = null; document.onmouseup = null; } } } // Douyu function createNewVideo_Douyu(id, rid) { getRealLive_Douyu(rid, true, "1", (lurl) => { if (lurl != "" || lurl != null) { if (lurl == "None") { showMessage("房间未开播或其他错误", "error"); return; } let lurl_host_arr = String(lurl).split("/live"); let lurl_host = ""; if (lurl_host_arr.length > 0) { lurl_host = lurl_host_arr[0]; } let a = document.createElement("div"); let html = ""; a.id = "exVideoDiv" + String(id); a.rid = rid; a.className = "exVideoDiv"; html += "
    " + "斗鱼 - " + rid + ""; html += ""; html += ""; html += "无视频?"; html += "
    X
    "; html += "
    "; html += "
    "; a.innerHTML = html; let b = document.getElementsByClassName("layout-Main")[0]; b.insertBefore(a, b.childNodes[0]); setElementDrag(id); setElementResize(id); setElementFunc_Douyu(id, rid); setElementVideo(id, lurl); } }); } function setElementFunc_Douyu(id, rid) { let box = document.getElementById("exVideoDiv" + String(id)); let exVideoPlayer = document.getElementById("exVideoPlayer" + String(id)); let info = document.getElementById("exVideoInfo" + String(id)); let scale = document.getElementById("exVideoScale" + String(id)); exVideoPlayer.onclick = function(e) { e.stopPropagation(); e.preventDefault(); if (scale.style.display != "block") { scale.style.display = "block"; info.style.display = "block"; } else { scale.style.display = "none"; info.style.display = "none"; } for (let i = 0; i < videoPlayerArr.length; i++) { let box = document.getElementById("exVideoDiv" + String(i)); if (box != null) { if (i == id) { box.style.zIndex = 7778; } else { box.style.zIndex = 7777; } } } } let exVideoQn = document.getElementById("exVideoQn" + String(id)); let exVideoCDN = document.getElementById("exVideoCDN" + String(id)); let exVideoClose = document.getElementById("exVideoClose" + String(id)); exVideoQn.onchange = function() { getRealLive_Douyu(rid, true, exVideoQn.value, (lurl) => { videoPlayerArr[id].destroy(); setElementVideo(id, lurl); }) } exVideoCDN.onchange = function() { getRealLive_Douyu(rid, true, exVideoQn.value, (lurl) => { videoPlayerArr[id].destroy(); setElementVideo(id, lurl); }) } exVideoClose.onclick = function() { box.remove(); } let exVideoRID = document.getElementById("exVideoRID" + String(id)); exVideoRID.onclick = function() { getRealLive_Douyu(rid, true, exVideoQn.value, (lurl) => { GM_setClipboard(String(lurl).replace("https", "http")); showMessage("复制成功", "success"); }) } } // Bilibili function createNewVideo_Bilibili(id, rid){ getRealLive_Bilibili(rid, "1", "1", (lurl) => { if (lurl != "" || lurl != null) { let a = document.createElement("div"); let html = ""; a.id = "exVideoDiv" + String(id); a.rid = rid; a.className = "exVideoDiv"; html += "
    " + "Bilibili - " + rid + ""; html += ""; html += ""; html += "
    X
    " html += "
    "; html += "
    "; a.innerHTML = html; let b = document.getElementsByClassName("layout-Main")[0]; b.insertBefore(a, b.childNodes[0]); setElementDrag(id); setElementResize(id); setElementFunc_Bilibili(id, rid); setElementVideo(id, lurl); } }); } function setElementFunc_Bilibili(id, rid) { let box = document.getElementById("exVideoDiv" + String(id)); let exVideoPlayer = document.getElementById("exVideoPlayer" + String(id)); let info = document.getElementById("exVideoInfo" + String(id)); let scale = document.getElementById("exVideoScale" + String(id)); exVideoPlayer.onclick = function(e) { e.stopPropagation(); e.preventDefault(); if (scale.style.display != "block") { scale.style.display = "block"; info.style.display = "block"; } else { scale.style.display = "none"; info.style.display = "none"; } for (let i = 0; i < videoPlayerArr.length; i++) { let box = document.getElementById("exVideoDiv" + String(i)); if (box != null) { if (i == id) { box.style.zIndex = 7778; } else { box.style.zIndex = 7777; } } } } let exVideoQn = document.getElementById("exVideoQn" + String(id)); let exVideoCDN = document.getElementById("exVideoCDN" + String(id)); let exVideoClose = document.getElementById("exVideoClose" + String(id)); exVideoQn.onchange = function() { getRealLive_Bilibili(rid, exVideoQn.value, exVideoCDN.value, (lurl) => { videoPlayerArr[id].destroy(); setElementVideo(id, lurl); }) } exVideoCDN.onchange = function() { getRealLive_Bilibili(rid, exVideoQn.value, exVideoCDN.value, (lurl) => { videoPlayerArr[id].destroy(); setElementVideo(id, lurl); }) } exVideoClose.onclick = function() { box.remove(); } let exVideoRID = document.getElementById("exVideoRID" + String(id)); exVideoRID.onclick = function() { getRealLive_Bilibili(rid, exVideoQn.value, exVideoCDN.value, (lurl) => { GM_setClipboard(lurl); showMessage("复制成功", "success"); }) } } // Huya function createNewVideo_Huya(id, rid, rname){ getRealLive_Huya(rid, "1", (lurl, msg) => { if (lurl != "" || lurl != null) { if (msg != "") { showMessage(msg, "error"); return; } let a = document.createElement("div"); let html = ""; a.id = "exVideoDiv" + String(id); a.rid = rid; a.className = "exVideoDiv"; html += "
    " + "Huya - " + rname + ""; html += ""; // html += ""; html += "
    X
    " html += "
    "; html += "
    "; a.innerHTML = html; let b = document.getElementsByClassName("layout-Main")[0]; b.insertBefore(a, b.childNodes[0]); setElementDrag(id); setElementResize(id); setElementFunc_Huya(id, rid); setElementVideo(id, lurl); } }); } function setElementFunc_Huya(id, rid) { let box = document.getElementById("exVideoDiv" + String(id)); let exVideoPlayer = document.getElementById("exVideoPlayer" + String(id)); let info = document.getElementById("exVideoInfo" + String(id)); let scale = document.getElementById("exVideoScale" + String(id)); exVideoPlayer.onclick = function(e) { e.stopPropagation(); e.preventDefault(); if (scale.style.display != "block") { scale.style.display = "block"; info.style.display = "block"; } else { scale.style.display = "none"; info.style.display = "none"; } for (let i = 0; i < videoPlayerArr.length; i++) { let box = document.getElementById("exVideoDiv" + String(i)); if (box != null) { if (i == id) { box.style.zIndex = 7778; } else { box.style.zIndex = 7777; } } } } let exVideoQn = document.getElementById("exVideoQn" + String(id)); // let exVideoCDN = document.getElementById("exVideoCDN" + String(id)); let exVideoClose = document.getElementById("exVideoClose" + String(id)); exVideoQn.onchange = function() { getRealLive_Huya(rid, exVideoQn.value, (lurl, msg) => { if (msg != "") { showMessage(msg, "error"); return; } videoPlayerArr[id].destroy(); setElementVideo(id, lurl); }) } exVideoClose.onclick = function() { box.remove(); } let exVideoRID = document.getElementById("exVideoRID" + String(id)); exVideoRID.onclick = function() { getRealLive_Huya(rid, exVideoQn.value, (lurl, msg) => { if (msg != "") { showMessage(msg, "error"); return; } GM_setClipboard(lurl); showMessage("复制成功", "success"); }) } } // iframe function createNewVideo_iframe(id, url) { if (String(url).indexOf("douyu.com") == -1) { showMessage("有弹幕模式仅支持斗鱼直播", "error"); return; } let rid_arr = String(url).split("/"); let rid = rid_arr[rid_arr.length - 1]; let a = document.createElement("div"); let html = ""; a.id = "exVideoDiv" + String(id); a.rid = rid; a.className = "exVideoDiv"; html += "
    " + "斗鱼 - " + rid + ""; html += "
    X
    " html += "
    "; html += "" html += "
    "; a.innerHTML = html; let b = document.getElementsByClassName("layout-Main")[0]; b.insertBefore(a, b.childNodes[0]); setElementDrag(id); setElementResize(id); if (id > videoPlayerArr.length - 1) { videoPlayerArr.push("iframe"); } else { videoPlayerArr[id] = "iframe"; } setElementFunc_iframe(id); } function setElementFunc_iframe(id) { let box = document.getElementById("exVideoDiv" + String(id)); let exVideoClose = document.getElementById("exVideoClose" + String(id)); exVideoClose.onclick = function() { box.remove(); } box.onclick = function(e) { e.stopPropagation(); e.preventDefault(); for (let i = 0; i < videoPlayerArr.length; i++) { let box = document.getElementById("exVideoDiv" + String(i)); if (box != null) { if (i == id) { box.style.zIndex = 7778; } else { box.style.zIndex = 7777; } } } } } let real_info = { view: "", showtime: 777, danmu_person_count: "", gift_person_count: "", isShow: 2, money_yc: 0, money_bag: 0, money_total: 0, } function initPkg_RealAudience() { initPkg_RealAudience_StyleHook(); initPkg_RealAudience_Dom(); initPkg_RealAudience_Func(); fetch("https://www.douyu.com/swf_api/h5room/" + rid, { method: 'GET', mode: 'no-cors', credentials: 'include' }).then(res => { return res.json(); }).then(retData => { real_info.showtime = retData.data.show_time; real_info.isShow = retData.data.show_status; getRealViewer(); setInterval(getRealViewer, 30000); }).catch(err => { console.log("请求失败!", err); }) } function initPkg_RealAudience_StyleHook() { StyleHook_set("Ex_Style_RealAudience", ` .VideoEntry{display:none !important;} .layout-Player-rank{top:34px !important;} `); } function initPkg_RealAudience_Dom() { let real_viewIcon = ''; let real_danmuIcon = ''; // let real_giftIcon = '' let real_money_yc = ''; document.getElementsByClassName("VideoEntry")[0].style.display = "none"; // document.querySelector(".AnchorAnnounce > h3").style.display = "none"; let html = ""; let a = document.createElement("div"); a.className = "real-audience"; html += "
    "; html += "
    " + real_viewIcon + '****
    '; html += "
    " + real_danmuIcon + '****
    '; // html += "
    " + real_giftIcon + '****
    '; html += "
    " + real_money_yc + '****
    '; html += "
    "; html += '' + "已播:" + "****" + ""; a.innerHTML = html; let b = document.getElementsByClassName("layout-Player-announce")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_RealAudience_Func() { document.getElementsByClassName("real-audience")[0].addEventListener("click", function() { openPage(`http://www.toubang.tv/anchor/1_${ rid }.html`, true); }) } function getRealViewer() { if(document.querySelector(".MatchSystemChatRoomEntry") != null){ document.querySelector(".MatchSystemChatRoomEntry").style.display = "none"; } fetch("https://bojianger.com/data/api/common/search.do?keyword=" + rid,{ method: 'GET', }).then(res => { return res.json(); }).then(retData => { let showedTime = 0; if (real_info.isShow == 2) { showedTime = 0; } else { if (real_info.showtime == 777) { showedTime = 0; } else { showedTime = Math.floor(Date.now()/1000) - Number(real_info.showtime); } } real_info.view = retData.data.anchorVo.audience_count; real_info.danmu_person_count = retData.data.anchorVo.danmu_person_count; real_info.gift_person_count = retData.data.anchorVo.gift_person_count; real_info.money_yc = retData.data.anchorVo.gift_new_yc; if (real_info.money_yc == "undefined" || real_info.money_yc == undefined) { real_info.money_yc = 0; real_info.money_bag = 0; real_info.money_total = 0; } else { real_info.money_bag = retData.data.anchorVo.gift_new_bag; real_info.money_total = retData.data.anchorVo.yc_gift_value; } document.getElementById("real-audience__total").innerText = real_info.view; document.getElementById("real-audience__t").title = "总人数:" + real_info.view + " 弹幕人数:" + real_info.danmu_person_count + " 送礼人数:" + real_info.gift_person_count; document.getElementById("real-audience__barrage").innerText = real_info.danmu_person_count; // document.getElementById("real-audience__gift").innerText = real_info.gift_person_count; document.getElementById("real-audience__money_yc").innerText = real_info.money_yc; document.getElementById("real-audience__money").title = "总礼物价值:" + real_info.money_total + " 鱼翅礼物:" + real_info.money_yc + " 背包礼物:" + real_info.money_bag; document.getElementById("real-audience__time").innerText = "已播:" + formatSeconds(showedTime); document.getElementById("real-audience__time").title = "开播时间:" + String(dateFormat("yyyy年MM月dd日hh时mm分ss秒 ",new Date(Number(real_info.showtime + "000")))); }).catch(err => { console.log("请求失败!", err); }) } function initPkg_Refresh() { initPkg_Refresh_BarrageFrame(); initPkg_Refresh_Video(); initPkg_Refresh_Barrage(); } function saveData_Refresh() { // 此处为保存简洁模式的数据,请在每次操作后都调用这个函数以保存状态 // 数据结构 // {功能1:{子功能1:{}}} // 每个子模块需要提供相应的返回数据函数 let data = { barrageFrame: { status: refresh_BarrageFrame_getStatus(), }, video: { status: refresh_Video_getStatus(), }, barrage: { status: refresh_Barrage_getStatus(), } } localStorage.setItem("ExSave_Refresh", JSON.stringify(data)); // 存储弹幕列表 } let current_barrage_status = 0; // 0没被简化 1被简化 function initPkg_Refresh_Barrage() { initPkg_Refresh_Barrage_Dom(); initPkg_Refresh_Barrage_Func(); initPkg_Refresh_Barrage_Set(); } function initPkg_Refresh_Barrage_Dom() { Refresh_Barrage_insertIcon(); } function Refresh_Barrage_insertIcon() { let a = document.createElement("a"); a.className = "refresh-barrage"; a.id = "refresh-barrage"; a.innerHTML = '前缀'; let b = document.getElementsByClassName("Barrage-toolbar")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_Refresh_Barrage_Func() { document.getElementById("refresh-barrage").addEventListener("click", function() { if (current_barrage_status == 0) { // 简化 current_barrage_status = 1; setRefreshBarrage(); } else { current_barrage_status = 0; cancelRefreshBarrage(); } saveData_Refresh(); }); } function refresh_Barrage_getStatus() { if (current_barrage_status == 1) { // 被简化 return true; } else { // 没被简化 return false; } } function initPkg_Refresh_Barrage_Set() { let ret = localStorage.getItem("ExSave_Refresh"); if (ret != null) { let retJson = JSON.parse(ret); if ("barrage" in retJson == false) { retJson.barrage = {status: false}; } if (retJson.barrage.status == true) { current_barrage_status = 1; setRefreshBarrage(); } } } function setRefreshBarrage() { let cssText = ` .Barrage-listItem .Barrage-icon,.Barrage-listItem .FansMedal.is-made,.Barrage-listItem .RoomLevel,.Barrage-listItem .Motor,.Barrage-listItem .ChatAchievement,.Barrage-listItem .Barrage-hiIcon,.Barrage-listItem .Medal,.Barrage-listItem .MatchSystemTeamMedal{display:none !important;} /*.Barrage-listItem .UserLevel{display:none !important;}*/ `; StyleHook_set("Ex_Style_RefreshBarrage", cssText); } function cancelRefreshBarrage() { StyleHook_remove("Ex_Style_RefreshBarrage"); } function initPkg_Refresh_BarrageFrame() { initPkg_Refresh_BarrageFrame_Dom(); initPkg_Refresh_BarrageFrame_Func(); initPkg_Refresh_BarrageFrame_Set(); } function initPkg_Refresh_BarrageFrame_Dom() { Refresh_BarrageFrame_insertIcon(); } function Refresh_BarrageFrame_insertIcon() { let a = document.createElement("a"); a.className = "Barrage-toolbarLock"; a.id = "refresh-barrage-frame"; a.innerHTML = '拉高'; let b = document.getElementsByClassName("Barrage-toolbar")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_Refresh_BarrageFrame_Func() { document.getElementById("refresh-barrage-frame").addEventListener("click", function() { let dom_rank = document.getElementsByClassName("layout-Player-rank")[0]; let dom_barrage = document.getElementById("js-player-barrage"); let dom_activity = document.getElementById("js-room-activity"); if (dom_rank.style.display == "none") { // 被拉高 dom_rank.style.display = "block"; dom_barrage.style = ""; dom_activity.style.display = "block"; document.getElementById("refresh-barrage-frame__text").innerText = "拉高"; } else { // 没拉高 let topHeight = document.getElementsByClassName("layout-Player-announce")[0].offsetHeight; dom_rank.style.display = "none"; dom_activity.style.display = "none"; dom_barrage.style = "top:" + topHeight + "px"; document.getElementById("refresh-barrage-frame__text").innerText = "恢复"; } saveData_Refresh(); }); } function refresh_BarrageFrame_getStatus() { let dom_rank = document.getElementsByClassName("layout-Player-rank")[0]; if (dom_rank.style.display == "none") { // 被拉高 return true; } else { // 没拉高 return false; } } function initPkg_Refresh_BarrageFrame_Set() { let ret = localStorage.getItem("ExSave_Refresh"); if (ret != null) { let retJson = JSON.parse(ret); if ("barrageFrame" in retJson == false) { retJson.barrageFrame = {status: false}; } if (retJson.barrageFrame.status == true) { let dom_rank = document.getElementsByClassName("layout-Player-rank")[0]; let dom_barrage = document.getElementById("js-player-barrage"); let dom_activity = document.getElementById("js-room-activity"); let topHeight = document.getElementsByClassName("layout-Player-announce")[0].offsetHeight; dom_rank.style.display = "none"; dom_activity.style.display = "none"; dom_barrage.style = "top:" + topHeight + "px"; document.getElementById("refresh-barrage-frame__text").innerText = "恢复"; } } } let video_num = 0; function initPkg_Refresh_Video() { let timer = setInterval(() => { if (document.getElementsByClassName("right-e7ea5d").length > 0) { clearInterval(timer); initPkg_Refresh_Video_Dom(); initPkg_Refresh_Video_Func(); initPkg_Refresh_Video_Set(); } video_num++; if (video_num >= 15) { clearInterval(timer); } }, 1500); } function initPkg_Refresh_Video_Dom() { Refresh_Video_insertIcon(); } function Refresh_Video_insertIcon() { let a = document.createElement("div"); a.id = "refresh-video"; a.title = "隐藏礼物框"; a.innerHTML = ''; let b = document.getElementsByClassName("right-e7ea5d")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_Refresh_Video_Func() { document.getElementById("refresh-video").addEventListener("click", function() { let dom_toolbar = document.getElementsByClassName("PlayerToolbar-Content")[0]; let dom_video = document.getElementsByClassName("layout-Player-video")[0]; if (dom_toolbar.style.visibility == "hidden") { dom_toolbar.style.visibility = "visible"; dom_video.style = ""; } else { dom_toolbar.style.visibility = "hidden"; dom_video.style = "bottom:0;z-index:25"; } saveData_Refresh(); }); } function refresh_Video_getStatus() { let dom_toolbar = document.getElementsByClassName("PlayerToolbar-Content")[0]; if (dom_toolbar.style.visibility == "hidden") { return true; } else { return false; } } function initPkg_Refresh_Video_Set() { let ret = localStorage.getItem("ExSave_Refresh"); if (ret != null) { let retJson = JSON.parse(ret); if ("video" in retJson == false) { retJson.video = {status: false}; } if (retJson.video.status == true) { let dom_toolbar = document.getElementsByClassName("PlayerToolbar-Content")[0]; let dom_video = document.getElementsByClassName("layout-Player-video")[0]; dom_toolbar.style.visibility = "hidden"; dom_video.style = "bottom:0;z-index:25"; } } } function initPkg_RemoveAD() { let t = setInterval(() => { let a = document.getElementsByClassName("PlayerToolbar-wealthNum")[0]; if (a != undefined) { removeChatLimit(); clearInterval(t); } }, 1000); } // .dy-ModalRadius-mask,dy-ModalRadius-wrap{display:none !important;} function removeAD() { StyleHook_set("Ex_Style_RemoveAD", ` .CloudGameLink,.RoomText-icon-horn,.RoomText-list,.Search-ad,.RedEnvelopAd,.noHandlerAd-0566b9,.PcDiversion,.DropMenuList-ad,.DropPane-ad,.WXTipsBox,.igl_bg-b0724a,.closure-ab91fb,.VideoAboveVivoAd,.pwd-990896,.css-widgetWrapper-EdVVC,.watermark-442a18,.FollowGuide-FadeOut,.MatchSystemChatRoomEntry-roomTabs,.FansMedalDialog-normal,.GameLauncher,.recommendAD-54569e,.recommendApp-0e23eb,.Title-ad,.Bottom-ad,.SignBarrage,.corner-ad-495ade,.SignBaseComponent-sign-ad,.SuperFansBubble,.is-noLogin,.PlayerToolbar-signCont,#js-widget,.Frawdroom,.HeaderGif-right,.HeaderGif-left,.liveos-workspace{display:none !important;} .Barrage-topFloater{z-index:999} .danmuAuthor-3d7b4a, .danmuContent-25f266{overflow: initial} .BattleShipTips{display:none !important;} .LastLiveTime,.recommendView-3e8b62{display:none !important;} .TurntableLottery-actTips{display:none !important;} .feedback-e27241{display:none !important;} .FansMedalEnter-maxFlag{display:none !important;} .Header-follow-listBox{max-height:640px !important;} `); // body{transform: translateZ(0)!important;} // .RomanticDatePanelModal-middle--small{height:220px !important;} // .MainDialog-main--content{height:450px !important;} // .RomanticDatePanelModal-middle--rowItemBottom--rowItemBottomBtn{margin-left:0px !important;margin-top:0px !important;width:170px !important;height:40px !important;background:orange !important;} // } } function removeChatLimit() { let a; a = document.getElementsByClassName("ChatSend-button")[0]; if (a != undefined) { a.className = "ChatSend-button"; } a = document.getElementsByClassName("ChatSend-txt")[0]; if (a != undefined) { a.maxLength = a.maxLength + 20; // 原来为50字符,修改成70字符 } } function initPkg_Sign() { initPkg_Sign_Dom(); initPkg_Sign_Func(); } function initPkg_Sign_Func() { let dom = new CClick(document.getElementsByClassName("ex-sign")[0]); dom.click(() => { initPkg_Sign_Main(false); // 只签到开播的 }); dom.longClick(() => { initPkg_Sign_Main(true); // 全部签到 }); } function initPkg_Sign_Dom() { Sign_insertIcon(); } function Sign_insertIcon() { let a = document.createElement("div"); a.className = "ex-sign"; // 以免有同名冲突,加了ex- a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_Sign_Main(isAll) { // 这里挂载每个子模块的函数入口 // 入口即为调用 initPkg_Sign_Yuba(); // 鱼吧签到 initPkg_Sign_Client(); initPkg_Sign_Motorcade(); initPkg_Sign_Room(isAll); // initPkg_Sign_Ad_666(); // 此处移动到鱼塘鱼丸领取中去以免观看冲突 initPkg_Sign_Ad_Sign(); // initPkg_Sign_Aoligei(); // initPkg_Sign_Ad_Yuba(); // initPkg_Sign_Bycc(); // saobai后每秒签到一个 // initPkg_Sign_Saobai(); // initPkg_Sign_Changzheng(); // initPkg_Sign_Chengxiao(); // initPkg_Sign_WuXuanyi(); // initPkg_Sign_1000(); // initPkg_Sign_Zhuli(); initPkg_Sign_TV(); initPkg_Sign_Yuba_Like(); // initPkg_Sign_Renlei(); initPkg_Sign_Act(); // initPkg_Sign_Bowuyuan(); // initPkg_Sign_ZBXSL2(); // initPkg_Sign_COD(); // initPkg_Sign_Wangzhe(); } // function takeActPrize(name) { // // 关注20200911LMJX_T2 // // 分享20200911LMJX_T5 // return new Promise(resolve => { // fetch('https://www.douyu.com/japi/carnival/nc/actTask/takePrize',{ // method: 'POST', // mode: 'no-cors', // credentials: 'include', // headers: {'Content-Type': 'application/x-www-form-urlencoded'}, // body: `token=${ dyToken }&aid=android&taskAlias=${ name }` // }).then(res => { // return res.json(); // }).then(ret => { // resolve(ret); // }).catch(err => { // console.log("请求失败!", err); // }) // }) // } // function addFollowRoom(rid) { // return new Promise(resolve => { // fetch('https://www.douyu.com/wgapi/livenc/liveweb/follow/add',{ // method: 'POST', // mode: 'no-cors', // credentials: 'include', // headers: {'Content-Type': 'application/x-www-form-urlencoded'}, // body: `rid=${ rid }&ctn=${ getCCN() }` // }).then(res => { // return res.json(); // }).then(ret => { // resolve(ret); // }).catch(err => { // console.log("请求失败!", err); // }) // }) // } // function removeFollowRoom(rid) { // return new Promise(resolve => { // fetch('https://www.douyu.com/wgapi/livenc/liveweb/follow/rm',{ // method: 'POST', // mode: 'no-cors', // credentials: 'include', // headers: {'Content-Type': 'application/x-www-form-urlencoded'}, // body: `rid=${ rid }&ctn=${ getCCN() }` // }).then(res => { // return res.json(); // }).then(ret => { // resolve(ret); // }).catch(err => { // console.log("请求失败!", err); // }) // }) // } // function shareAct(name) { // // 20200911LMJX // return new Promise(resolve => { // fetch('https://www.douyu.com/japi/carnival/common/share',{ // method: 'POST', // mode: 'no-cors', // credentials: 'include', // headers: {'Content-Type': 'application/x-www-form-urlencoded'}, // body: `actAlias=${ name }&token=${ dyToken }` // }).then(res => { // return res.json(); // }).then(ret => { // resolve(ret); // }).catch(err => { // console.log("请求失败!", err); // }) // }) // } // function getJackpot(id) { // return new Promise(resolve => { // fetch("https://www.douyu.com/japi/carnival/nc/lottery/jackpot", { // method: 'POST', // headers: {'Content-Type': 'application/json;charset=UTF-8'}, // body: `{"activityId":"${ id }","token":"${ dyToken }"}` // }).then(res => { // return res.json(); // }).then(ret => { // resolve(ret); // }) // }) // } // function getActRemaining(id) { // return new Promise(resolve => { // fetch("https://www.douyu.com/japi/carnival/nc/lottery/remaining?activityId=" + id, { // method: 'GET', // mode: 'no-cors', // credentials: 'include', // headers: {'Content-Type': 'application/json;charset=UTF-8'}, // }).then(res => { // return res.json(); // }).then(ret => { // resolve(ret); // }) // }) // } function initPkg_Sign_Act() { getAct(); } async function getAct() { let actList = await getActList(); actList = JSON.parse(decodeURIComponent(escape(window.atob(actList)))); if ("data" in actList == false) { return; } for (let i = 0; i < actList.data.length; i++) { let eachAct = actList.data[i]; let name = eachAct.name; for (let j = 0; j < eachAct.script.length; j++) { let script = eachAct.script[j]; let value = script.value; let ret; let ret2; switch (script.name) { case "signAct": ret = await signAct(value); if (ret.error == "0") { showMessage(`【${name}】签到完毕`, "success"); } else { showMessage(`【${name}】${ret.msg}`, "error"); } break; case "userStatus": ret = await userStatus(value); if (ret.error == 0) { for (let key in ret.data) { let item = ret.data[key]; let cnt = item.curCompleteNum - item.curDeliverNum; let name2 = name + "-" + item.taskName; for (let i = 0; i < cnt; i++) { let ret2 = await takeActPrize(key); if (ret2.error == "0") { showMessage(`【${name2}】获得` + ret2.data.sendRes.items[0].prizeName + "*" + ret2.data.sendRes.items[0].prizeNum, "success"); } else { showMessage(`【${name2}】${ret2.msg}`, "error"); } } } } break; case "addFollowRoom": await addFollowRoom(value); break; case "removeFollowRoom": await removeFollowRoom(value); break; case "shareAct": await shareAct(value); break; case "getActRemaining": ret = await getActRemaining(value); if (ret.error == "0") { for (let i = 0; i < ret.data.freeCount; i++) { ret2 = await getJackpot(value); if (ret2.error == "0") { showMessage(`【${name}】礼盒开启:${ret2.data.giftName}`, "success"); } } } default: break; } } } } function initPkg_Sign_Ad_Sign() { getFishBall_Ad_Sign(); } function getFishBall_Ad_Sign() { let fishBallNum = "0"; let posid_ad_sign = "1064246"; GM_xmlhttpRequest({ method: "GET", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/inspire/getFishBallNum?posId=" + posid_ad_sign + "&ct=1&token=" + dyToken, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { fishBallNum = ret.data.num; GM_xmlhttpRequest({ method: "GET", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/inspire/sendFishBall?uid=" + getUID() + "&posCode=" + posid_ad_sign + "&ct=1&token=" + dyToken, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { showMessage("【签到鱼丸】成功领取" + fishBallNum + "个鱼丸", "success"); } else { if (ret.msg == "null") { showMessage("【签到鱼丸】未绑定手机" , "warning"); } else { showMessage("【签到鱼丸】" + ret.msg, "warning"); } } } }); } } }); } function initPkg_Sign_Client() { signClient(); } function signClient() { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/h5nc/sign/sendSign", data: 'token=' + dyToken, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.data.length == 0) { showMessage("【客户端】今日已签到", "warning"); // console.log("【客户端】今日已签到"); } else { if (ret.data.sign_pl.length != 0) { let recv = ""; for (let i = 0; i < ret.data.sign_pl.length; i++) { recv = recv + ret.data.sign_pl[i].cnt + "个" + ret.data.sign_pl[i].name + ","; } showMessage("【客户端】签到成功! 获得物品:" + recv, "success"); // console.log("【客户端】签到成功! 获得物品:" + recv); } else { showMessage("【客户端】签到成功! 可惜没有获得东西", "success"); // console.log("【客户端】签到成功! 可惜没获得东西"); } } } }); } function initPkg_Sign_Motorcade() { signMotorcade(); } function signMotorcade() { openPage("https://msg.douyu.com/motorcade/#/motorcade/list/recommend?exid=chun", false); } function getCookie(cookieName) { let csrfToken = ""; let strCookie = document.cookie; let arrCookie = strCookie.split("; "); for(let i = 0; i < arrCookie.length; i++) { let arr = arrCookie[i].split("="); if(cookieName == arr[0]){ csrfToken = arr[1]; } } if(csrfToken == ""){ csrfToken = Math.random().toString(36).substr(2); document.cookie = "post-csrfToken="+ escape(csrfToken)+";path=/"; } return csrfToken; } async function signMotorcade_Sign() { let retConnect = await motorcadeConnect(); let retConnect2 = await motorcadeConnect2(retConnect.data.uid, retConnect.data.sig); let mid = await getMotorcadeID(retConnect2.TinyId, retConnect2.A2Key, retConnect.data.uid); if (mid == null) { closePage(); return; } if (mid == undefined) { closePage(); return; } if (mid == "") { closePage(); return; } console.log("mid是:", mid); mid = encodeURIComponent(mid); fetch('https://msg.douyu.com/v3/motorcade/signs/weekly?mid=' + mid + '×tamp=' + Math.random().toFixed(17), { method: 'GET', mode: 'cors', credentials: 'include', headers: { 'dy-device-id':'-', "dy-client": "web", "dy-csrf-token":getCookie("post-csrfToken"), 'Content-Type': 'application/x-www-form-urlencoded' }, }).then(res => { return res; }).then(ret => { console.log("weekly:", ret); if (ret.data.is_sign == "1") { closePage(); } else { fetch('https://msg.douyu.com/v3/msign/add?timestamp=' + Math.random().toFixed(17), { method: 'POST', mode: 'cors', credentials: 'include', headers: { 'dy-device-id':'-', "dy-client": "web", "dy-csrf-token":getCookie("post-csrfToken"), 'Content-Type': 'application/x-www-form-urlencoded' }, body: "to_mid="+ mid +"&expression=" + String(Number(ret.data.total) + 1) }).then(res => { return res; }).then(ret => { if (Math.floor(ret.status_code / 100) == 2){ console.log("【车队】签到成功") } else { console.log(ret.message); } closePage(); }).catch(err => { console.log("请求失败!", err) closePage(); }) } }).catch(err => { console.log("请求失败!", err) }) } function motorcadeConnect() { return new Promise(resolve => { fetch('https://msg.douyu.com/v3/login/getusersig?t=' + String(new Date().getTime()) + '×tamp=' + Math.random().toFixed(17), { method: 'GET', mode: 'cors', credentials: 'include', headers: { 'dy-device-id':'-', "dy-client": "web", "dy-csrf-token":getCookie("post-csrfToken"), 'Content-Type': 'application/x-www-form-urlencoded' }, }).then(res => { return res; }).then(ret => { resolve(ret); }).catch(err => { console.log("请求失败!", err) }) }) } function motorcadeConnect2(identifier, sig) { let url = "https://webim.tim.qq.com/v4/openim/login?identifier=" + identifier + "&usersig=" + sig +"&contenttype=json&sdkappid=1400029396"; return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: url, data: '{"State":"Online"}', responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", }, onload: function(response) { resolve(response.response); } }); }) } function getMotorcadeID(tinyid, a2, identifier) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://webim.tim.qq.com/v4/group_open_http_svc/get_joined_group_list?tinyid=" + tinyid + "&a2=" + a2 + "&contenttype=json&sdkappid=1400029396", data: '{"Member_Account":"' + identifier + '"}', responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded" }, onload: function(response) { if (response.response.GroupIdList.length > 0) { resolve(response.response.GroupIdList[0].GroupId); } else { resolve(""); } } }); }) } function initPkg_Sign_Room(isAll) { signAllRoom(isAll); } function signAllRoom(isAll) { // 1. get page counts(777) // 2. for in all pages // 3. sign each room let pageCount = 0; let signedCount = 0; let count = 0; fetch('https://www.douyu.com/wgapi/livenc/liveweb/follow/list?page=777',{ method: 'GET', mode: 'no-cors', cache: 'default', credentials: 'include', }).then(res => { return res.json(); }).then(ret => { pageCount = Number(ret.data.pageCount); for (let nowPage = 1; nowPage <= pageCount; nowPage++) { fetch('https://www.douyu.com/wgapi/livenc/liveweb/follow/list?page=' + String(nowPage),{ method: 'GET', mode: 'no-cors', cache: 'default', credentials: 'include', }).then(res => { return res.json(); }).then(ret1 => { let roomCount = Number(ret1.data.list.length); for (let i = 0; i < roomCount; i++) { if (isAll == false) { if (ret1.data.list[i].show_status == "1") { signRoom(ret1.data.list[i].room_id); signedCount++; } } else { signRoom(ret1.data.list[i].room_id); signedCount++; } count++; if (count == ret1.data.total && i == roomCount - 1) { let rest = Number(ret1.data.total) - signedCount; showMessage("【房间签到】" + String(signedCount) + "个房间签到已完成," + String(rest) + "个房间未签到", "success"); } } }).catch(err => { console.log("请求失败!", err); }) } showMessage("【房间签到】" + ret.data.total + "个房间正在签到中...", "info"); }).catch(err => { console.log("请求失败!", err); }) } function signRoom(r) { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/roomuserlevel/apinc/checkIn?client_sys=android", data: 'rid=' + r, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'token': dyToken, 'aid': 'android1' }, onload: function(response) { } }); } function initPkg_Sign_TV() { signTV(); } function signTV() { let did = window.btoa(getDyDid()); GM_xmlhttpRequest({ method: "GET", url: "https://apitv.douyucdn.cn/user/sign/index?token=" + dyToken + "&client_sys=android", responseType: "json", headers: { 'User-Device': did }, onload: function(response) { let ret = response.response; if (ret.error == "0") { showMessage("【电视端】签到成功!获得100鱼丸", "success"); } else { showMessage("【电视端】" + ret.data.msg, "warning"); } } }); } let signedYuba = 0; let totalYuba = 0; let doneYuba = 0; function initPkg_Sign_Yuba() { signYubaList(); } function signYubaFast() { GM_xmlhttpRequest({ method: "POST", url: "https://mapi-yuba.douyu.com/wb/v3/fastSign", responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded", "client": "android", "token": dyToken, }, onload: function (response) { if (response.response.message == "" && response.response.data != 0) { // showMessage("【鱼吧】一键签到成功! 获得经验" + response.response.data, "success"); // console.log("【极速鱼吧】" + group_id + "签到成功! 连续" + response.response.data.count + "天 获得经验" + response.response.data.exp); } else if (response.response.data == 0) { // showMessage("【鱼吧】没有7级以上的鱼吧或极速签到已完成", "warning"); // console.log("【极速鱼吧】" + group_id + response.response.message); } else { // showMessage("【鱼吧】" + response.response.message, "warning"); // console.log("【极速鱼吧】" + response.response.message); } } }); } function signYuba(group_id, t) { GM_xmlhttpRequest({ method: "POST", url: "https://yuba.douyu.com/ybapi/topic/sign", data: 'group_id=' + group_id, responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded", "dy-client": "pc", "dy-token": t, 'Referer': 'https://yuba.douyu.com/group/' + group_id }, onload: function (response) { doneYuba++; if (response.response.message == "") { signedYuba++; // showMessage("【鱼吧】" + group_id + "签到成功! 连续" + response.response.data.count + "天 获得经验" + response.response.data.exp, "success"); // console.log("【鱼吧】" + group_id + "签到成功! 连续" + response.response.data.count + "天 获得经验" + response.response.data.exp); } else { // showMessage("【鱼吧】" + group_id + response.response.message, "warning"); // console.log("【鱼吧】" + group_id + response.response.message); } getSupplementaryNums(group_id).then(async (numsRet) => { if (numsRet.status_code == "200") { let nums = numsRet.data.supplementary_cards; for (let j = 0; j < nums; j++) { let a = await signSupplementary(group_id); if (a.message == "补签失败" || a.message == "系统维护中") { break; } } } }) if (doneYuba == totalYuba) { // 完成全部签到 if (signedYuba > 0) { if (totalYuba - signedYuba == 0) { showMessage("【鱼吧】" + String(signedYuba) + "个鱼吧签到完成", "success") } else { showMessage("【鱼吧】" + String(signedYuba) + "个鱼吧签到完成," + String(totalYuba - signedYuba) + "个鱼吧已签到", "success"); } } else { showMessage("【鱼吧】"+ String(totalYuba) + "个鱼吧已签到", "warning"); } signedYuba = null; totalYuba = null; doneYuba = null; } } }); } async function signYubaList() { let yubaList = []; let ret = await getYubaPage(1); yubaList = yubaList.concat(ret.list); let pageNum = Number(ret.count_page) - 1; if (pageNum >= 1) { for (let i = 0; i < pageNum; i++) { let curPage = 2 + i; ret = await getYubaPage(curPage); yubaList = yubaList.concat(ret.list); } } totalYuba = yubaList.length; signYubaFast(); for (let i = 0; i < yubaList.length; i++) { signYuba(yubaList[i].group_id, dyToken); } } function getYubaPage(page) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "GET", url: "https://yuba.douyu.com/wbapi/web/group/myFollow?page=" + String(page) + "&limit=30", responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded", "dy-client": "pc", "dy-token": dyToken }, onload: function(response) { resolve(response.response.data) } }); }) } function getSupplementaryNums(group_id) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "GET", url: "https://yuba.douyu.com/wbapi/web/signDetail?group_id=" + group_id, responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded", "dy-client": "pc", "dy-token": dyToken }, onload: function(response) { resolve(response.response); } }); }) } function signSupplementary(group_id) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://mapi-yuba.douyu.com/wb/v3/supplement", responseType: "json", headers: { "Content-Type": "application/x-www-form-urlencoded", "client": "android", "token": dyToken, }, data: "group_id=" + group_id, onload: function(response) { resolve(response.response); } }); }) } function initPkg_Sign_Yuba_Like() { likeYuba(); } function likeYuba() { let pid = "479725451596644862"; likeYubaPostComment(pid, "1517012660302061924", "-1").then(() => {likeYubaPostComment(pid, "1517012660302061924", "1")}); likeYubaPostComment(pid, "1517012829374456125", "-1").then(() => {likeYubaPostComment(pid, "1517012829374456125", "1")}); likeYubaPostComment(pid, "1517013103069569447", "-1").then(() => {likeYubaPostComment(pid, "1517013103069569447", "1")}); likeYubaPostComment(pid, "1517013231197168052", "-1").then(() => {likeYubaPostComment(pid, "1517013231197168052", "1")}); likeYubaPostComment(pid, "1517013448084627821", "-1").then(() => {likeYubaPostComment(pid, "1517013448084627821", "1")}); showMessage("【鱼吧点赞】已完成", "success"); } function likeYubaPostComment(post_id, commnet_id, type) { let data = `pid=${ post_id }&comment_id=${ commnet_id }&type=${ type }`; return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://yuba.douyu.com/ybapi/follow/like", data: data, responseType: "json", headers: { "dy-token": dyToken, "dy-client": "pc", "Content-Type": "application/x-www-form-urlencoded", "Referer": "https://yuba.douyu.com/p/479725451596644862" }, onload: function(response) { let ret = response.response; resolve(ret); } }); }) } var _hmt = _hmt || []; function initPkg_Statistics() { let hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?4dc4fb0549a56fe03ba53c022b1ff455"; let s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); } // 版本号 // 格式 yyyy.MM.dd.** // var curVersion = "2020.01.12.01"; var curVersion = "2020.12.29.02" function initPkg_Update() { initPkg_Update_Dom(); initPkg_Update_Func(); Update_checkVersion(); // 首次检查更新 } function initPkg_Update_Dom() { Update_insertIcon(); } function Update_insertIcon() { let a = document.createElement("div"); a.className = "ex-update"; a.innerHTML = ''; let b = document.getElementsByClassName("ex-panel__wrap")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_Update_Func() { document.getElementsByClassName("ex-update")[0].addEventListener("click", Update_openUpdatePage); } function Update_checkVersion() { // fetch('https://greasyfork.org/zh-CN/scripts/394497',{ // method: 'GET', // mode: 'cors', // cache: 'no-store', // credentials: 'omit', // }).then(res => { // return res.text(); // }).then(txt => { // txt = (new DOMParser()).parseFromString(txt, 'text/html'); // let v = txt.getElementsByClassName("script-show-version")[1]; // if(v != undefined){ // if (v.innerText != curVersion) { // Update_showTip(true); // } // } // }).catch(err => { // console.error('请求失败', err); // }) fetch('https://www.douyuex.com/src/douyuex_version.txt',{ method: 'GET', mode: 'cors', cache: 'no-store', credentials: 'omit', }).then(res => { return res.text(); }).then(txt => { if(txt != undefined){ if (txt != curVersion) { Update_showTip(true); } } }).catch(err => { console.error('请求失败', err); }) } function Update_openUpdatePage() { openPage("https://www.douyuex.com/install/web.html", true); } function Update_showTip(a) { let d = document.getElementById("ex-update__tip"); if (a == true) { if (d.style.display != "block") { showMessage("【版本更新】插件有新版本,请及时更新~", "error"); d.style.display = "block"; } } else { d.style.display = "none"; } } function initPkg_VideoTools_Cinema() { initPkg_VideoTools_Cinema_Dom(); initPkg_VideoTools_Cinema_Func(); } function initPkg_VideoTools_Cinema_Dom() { Cinema_insertIcon(); } function Cinema_insertIcon() { let a = document.createElement("div"); a.id = "ex-cinema"; a.innerHTML = `
    • 默认
    • 剪裁
    • 拉伸
    `; let b = document.getElementsByClassName("right-e7ea5d")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_VideoTools_Cinema_Func() { document.getElementById("ex-cinema").addEventListener("mouseover", function() { document.getElementsByClassName("cinema__wrap")[0].style.display = "block"; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; document.getElementsByClassName("filter__wrap")[0].style.display = "none"; }); document.getElementsByClassName("cinema__wrap")[0].addEventListener("mouseout", function() { document.getElementsByClassName("cinema__wrap")[0].style.display = "none"; }); document.getElementById("cinema__default").addEventListener("click", () => { StyleHook_remove("Ex_Style_Cinema"); document.getElementsByClassName("cinema__wrap")[0].style.display = "none"; }); document.getElementById("cinema__cover").addEventListener("click", () => { setVideoCinemaMode("cover"); document.getElementsByClassName("cinema__wrap")[0].style.display = "none"; }); document.getElementById("cinema__fill").addEventListener("click", () => { setVideoCinemaMode("fill"); document.getElementsByClassName("cinema__wrap")[0].style.display = "none"; }); } function setVideoCinemaMode(fit) { let newHeigth = String(parseInt(liveVideoNode.style.width) / 2.39) + "px"; StyleHook_remove("Ex_Style_Cinema"); let style = ` .layout-Player-videoEntity video{object-fit:${ fit } !important;height:${ newHeigth } !important;} `; StyleHook_set("Ex_Style_Cinema", style); } let currentBrightness = ""; let currentContrast = ""; let currentSaturate = ""; let liveVideoParentClassName = ""; function initPkg_VideoTools_Filter() { liveVideoParentClassName = liveVideoNode.parentNode.className; initPkg_VideoTools_Filter_Dom(); initPkg_VideoTools_Filter_Func(); } function initPkg_VideoTools_Filter_Dom() { Filter_insertIcon(); } function Filter_insertIcon() { let a = document.createElement("div"); a.id = "ex-filter"; a.innerHTML = `
    明亮度
    对比度
    饱和度

    滤镜

    • 镜像画面
    • 重置
    `; let b = document.getElementsByClassName("right-e7ea5d")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_VideoTools_Filter_Func() { document.onmouseup = function () { document.onmousemove = null; //弹起鼠标不做任何操作 } setScrollFunc(document.getElementById("scroll__bright"), document.getElementById("bar__bright"), document.getElementById("mask__bright"), (data) => { currentBrightness = `brightness(${ data }%)`; liveVideoNode.style.filter = `${ currentBrightness } ${ currentContrast } ${ currentSaturate }`; }); setScrollFunc(document.getElementById("scroll__contrast"), document.getElementById("bar__contrast"), document.getElementById("mask__contrast"), (data) => { currentContrast = `contrast(${ data }%)`; liveVideoNode.style.filter = `${ currentBrightness } ${ currentContrast } ${ currentSaturate }`; }); setScrollFunc(document.getElementById("scroll__saturate"), document.getElementById("bar__saturate"), document.getElementById("mask__saturate"), (data) => { currentSaturate = `saturate(${ data }%)`; liveVideoNode.style.filter = `${ currentBrightness } ${ currentContrast } ${ currentSaturate }`; }); document.getElementById("ex-filter").addEventListener("mouseover", function () { document.getElementsByClassName("filter__wrap")[0].style.display = "block"; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; document.getElementsByClassName("cinema__wrap")[0].style.display = "none" }); document.getElementsByClassName("filter__wrap")[0].addEventListener("mouseleave", function () { document.getElementsByClassName("filter__wrap")[0].style.display = "none" }); document.getElementById("filter__reset").addEventListener("click", () => { StyleHook_remove("Ex_Style_Filter"); document.getElementById("filter__select").selectedIndex = 0; liveVideoNode.style.filter = ""; liveVideoNode.parentNode.style.transform = ""; document.getElementById("bar__bright").style.left = "100px"; document.getElementById("bar__contrast").style.left = "100px"; document.getElementById("bar__saturate").style.left = "100px"; document.getElementById("mask__bright").style.width = "100px"; document.getElementById("mask__contrast").style.width = "100px"; document.getElementById("mask__saturate").style.width = "100px"; }); document.getElementById("filter__mirror").addEventListener("click", () => { if (liveVideoNode.parentNode.style.transform == "") { liveVideoNode.parentNode.style.transform = "rotateY(180deg)"; } else { liveVideoNode.parentNode.style.transform = ""; } }); document.getElementById("filter__select").onchange = function() { let option = this.options[this.selectedIndex].text; switch (option) { case "default": StyleHook_remove("Ex_Style_Filter") break; case "1977": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(110%)brightness(110%)saturate(130%);filter:contrast(110%)brightness(110%)saturate(130%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:screen;background:rgba(243,106,188,0.3);z-index:10}`) break; case "Aden": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(90%)brightness(120%)saturate(85%)hue-rotate(20deg);filter:contrast(90%)brightness(120%)saturate(85%)hue-rotate(20deg)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:darken;background:-webkit-linear-gradient(to right,rgba(66,10,14,0.2)1,rgba(66,10,14,0));background:linear-gradient(to right,rgba(66,10,14,0.2)1,rgba(66,10,14,0));z-index:10}`) break; case "Amaro": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(90%)brightness(110%)saturate(150%)hue-rotate(-10deg);filter:contrast(90%)brightness(110%)saturate(150%)hue-rotate(-10deg)}`) break; case "Brannan": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(140%)sepia(50%);filter:contrast(140%)sepia(50%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:lighten;background:rgba(161,44,199,0.31);z-index:10}`) break; case "Brooklyn": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(90%)brightness(110%);filter:contrast(90%)brightness(110%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:overlay;background:-webkit-radial-gradient(50%50%,circle closest-corner,rgba(168,223,193,0.4)1,rgba(183,196,200,0.2));background:radial-gradient(50%50%,circle closest-corner,rgba(168,223,193,0.4)1,rgba(183,196,200,0.2));z-index:10}`) break; case "Claredon": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(120%)saturate(125%);filter:contrast(120%)saturate(125%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:overlay;background:rgba(127,187,227,0.2);z-index:10}`) break; case "Earlybird": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(90%)sepia(20%);filter:contrast(90%)sepia(20%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:overlay;background:-webkit-radial-gradient(50%50%,circle closest-corner,rgba(208,186,142,1)20,rgba(29,2,16,0.2));background:radial-gradient(50%50%,circle closest-corner,rgba(208,186,142,1)20,rgba(29,2,16,0.2));z-index:10}`) break; case "Gingham": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:brightness(105%)hue-rotate(350deg);filter:brightness(105%)hue-rotate(350deg)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:darken;background:-webkit-linear-gradient(to right,rgba(66,10,14,0.2)1,rgba(0,0,0,0));background:linear-gradient(to right,rgba(66,10,14,0.2)1,rgba(0,0,0,0));z-index:10}`) break; case "Hudson": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(90%)brightness(120%)saturate(110%);filter:contrast(90%)brightness(120%)saturate(110%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:multiply;opacity:0.5;background:-webkit-radial-gradient(50%50%,circle closest-corner,rgba(255,177,166,1)50,rgba(52,33,52,1));background:radial-gradient(50%50%,circle closest-corner,rgba(255,177,166,1)50,rgba(52,33,52,1));z-index:10}`) break; case "Inkwell": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(110%)brightness(110%)sepia(30%)grayscale(100%);filter:contrast(110%)brightness(110%)sepia(30%)grayscale(100%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;background:rgba(0,0,0,0);z-index:10}`) break; case "Lofi": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(150%)saturate(110%);filter:contrast(150%)saturate(110%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:multiply;background:-webkit-radial-gradient(50%50%,circle closest-corner,rgba(0,0,0,0)70,rgba(34,34,34,1));background:radial-gradient(50%50%,circle closest-corner,rgba(0,0,0,0)70,rgba(34,34,34,1));z-index:10}`); break; case "Maven": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(95%)brightness(95%)saturate(150%)sepia(25%);filter:contrast(95%)brightness(95%)saturate(150%)sepia(25%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:hue;background:rgba(3,230,26,0.2);z-index:10}`) break; case "Perpetua": setVideoFilter(`.${ liveVideoParentClassName }{position:relative}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:soft-light;opacity:0.5;background:-webkit-linear-gradient(to bottom,rgba(0,91,154,1)1,rgba(61,193,230,0));background:linear-gradient(to bottom,rgba(0,91,154,1)1,rgba(61,193,230,0));z-index:10}`) break; case "Reyes": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(85%)brightness(110%)saturate(75%)sepia(22%);filter:contrast(85%)brightness(110%)saturate(75%)sepia(22%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:soft-light;opacity:0.5;background:rgba(173,205,239,1);z-index:10}`) break; case "Stinson": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(75%)brightness(115%)saturate(85%);filter:contrast(75%)brightness(115%)saturate(85%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:soft-light;background:rgba(240,149,128,0.2);z-index:10}`) break; case "Toaster": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(150%)brightness(90%);filter:contrast(150%)brightness(90%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:screen;opacity:0.5;background:-webkit-radial-gradient(50%50%,circle closest-corner,rgba(15,78,128,1)1,rgba(59,0,59,1));background:radial-gradient(50%50%,circle closest-corner,rgba(15,78,128,1)1,rgba(59,0,59,1));z-index:10}`) break; case "Walden": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:brightness(110%)saturate(160%)sepia(30%)hue-rotate(350deg);filter:brightness(110%)saturate(160%)sepia(30%)hue-rotate(350deg)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:screen;opacity:0.3;background:rgba(204,68,0,1);z-index:10}`) break; case "Valencia": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:contrast(108%)brightness(108%)sepia(8%);filter:contrast(108%)brightness(108%)sepia(8%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:exclusion;opacity:0.5;background:rgba(58,3,57,1);z-index:10}`) break; case "Xpro2": setVideoFilter(`.${ liveVideoParentClassName }{position:relative;-webkit-filter:sepia(30%);filter:sepia(30%)}.${ liveVideoParentClassName }::before{content:"";display:block;height:100%;width:100%;top:0;left:0;position:absolute;pointer-events:none;mix-blend-mode:color-burn;background:-webkit-radial-gradient(50%50%,circle closest-corner,rgba(224,231,230,1)40,rgba(43,42,161,0.6));background:radial-gradient(50%50%,circle closest-corner,rgba(224,231,230,1)40,rgba(43,42,161,0.6));z-index:10}`) break; default: StyleHook_remove("Ex_Style_Filter") break; } } } function setVideoFilter(style) { // liveVideoNode.style.filter = text; // liveVideoNode.style.webkitFilter = text; StyleHook_remove("Ex_Style_Filter"); StyleHook_set("Ex_Style_Filter", style); document.getElementsByClassName("filter__wrap")[0].style.display = "none"; } function setScrollFunc(scrollDom, barDom, maskDom, callback) { let scroll = scrollDom; let bar = barDom; let mask = maskDom; let barleft = 0; bar.onmousedown = function (e) { let event = e || window.event; let leftVal = event.clientX - this.offsetLeft; let that = this; // 拖动一定写到 down 里面才可以 document.onmousemove = function (e) { let event = e || window.event; barleft = event.clientX - leftVal; if (barleft < 0) barleft = 0; else if (barleft > scroll.offsetWidth - bar.offsetWidth) barleft = scroll.offsetWidth - bar.offsetWidth; mask.style.width = barleft + 'px'; that.style.left = barleft + "px"; callback(parseInt(barleft / (scroll.offsetWidth - bar.offsetWidth) * 255)); //防止选择内容--当拖动鼠标过快时候,弹起鼠标,bar也会移动,修复bug window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); } } } function initPkg_VideoTools_VideoRecall() { initPkg_VideoTools_VideoRecall_Func(); } function initPkg_VideoTools_VideoRecall_Func() { document.getElementsByClassName("layout-Player-video")[0].addEventListener("keydown", (e) => { if (isInput == true) { return; } if (e.keyCode == 37) { liveVideoNode.currentTime += -3; } else if (e.keyCode == 39) { liveVideoNode.currentTime += 3; } }); } function initPkg_VideoTools_VideoSpeed() { initPkg_VideoTools_VideoSpeed_Dom(); initPkg_VideoTools_VideoSpeed_Func(); } function initPkg_VideoTools_VideoSpeed_Dom() { VideoSpeed_insertIcon(); } function VideoSpeed_insertIcon() { let a = document.createElement("div"); a.id = "ex-videospeed"; a.innerHTML = `
    • 2.0x
    • 1.5x
    • 1.25x
    • 1.0x
    • 0.75x
    • 0.5x
    `; let b = document.getElementsByClassName("right-e7ea5d")[0]; b.insertBefore(a, b.childNodes[0]); } function initPkg_VideoTools_VideoSpeed_Func() { document.getElementById("ex-videospeed").addEventListener("mouseover", function() { document.getElementsByClassName("videospeed__wrap")[0].style.display = "block"; document.getElementsByClassName("cinema__wrap")[0].style.display = "none"; document.getElementsByClassName("filter__wrap")[0].style.display = "none"; }); document.getElementsByClassName("videospeed__wrap")[0].addEventListener("mouseout", function() { document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; }); document.getElementById("videospeed__2.0").addEventListener("click", () => { liveVideoNode.playbackRate = 2; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; }); document.getElementById("videospeed__1.5").addEventListener("click", () => { liveVideoNode.playbackRate = 1.5; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; }); document.getElementById("videospeed__1.25").addEventListener("click", () => { liveVideoNode.playbackRate = 1.25; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; }); document.getElementById("videospeed__1.0").addEventListener("click", () => { liveVideoNode.playbackRate = 1; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; }); document.getElementById("videospeed__0.75").addEventListener("click", () => { liveVideoNode.playbackRate = 0.75; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; }); document.getElementById("videospeed__0.5").addEventListener("click", () => { liveVideoNode.playbackRate = 0.5; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; }); } function initPkg_VideoTools_VideoSync() { initPkg_VideoTools_VideoSync_Dom(); initPkg_VideoTools_VideoSync_Func(); } function initPkg_VideoTools_VideoSync_Dom() { VideoSync_insertIcon(); } function VideoSync_insertIcon() { let a = document.createElement("div"); a.id = "ex-videosync"; a.title = "同步时间"; a.innerHTML = ` `; let b = document.getElementsByClassName("left-d3671e")[0]; b.insertBefore(a, b.childNodes[3]); } function initPkg_VideoTools_VideoSync_Func() { document.getElementById("ex-videosync").addEventListener("click", () => { setVideoSync(); }) } function setVideoSync() { let buffered = liveVideoNode.buffered; if (buffered.length == 0) { // 暂停中 return; } liveVideoNode.currentTime = buffered.end(0); } var liveVideoNode; // 直播video标签节点 var isInput = false; let videotools_num = 0; function initPkg_VideoTools() { let timer = setInterval(() => { if (document.getElementsByClassName("right-e7ea5d").length > 0) { clearInterval(timer); liveVideoNode = document.querySelector(".layout-Player-videoEntity video"); initPkg_VideoTools_Module(); initPkg_VideoTools_Func(); } videotools_num++; if (videotools_num >= 15) { clearInterval(timer); } }, 1500); } function initPkg_VideoTools_Module() { // 添加模块 initPkg_VideoTools_VideoSpeed(); initPkg_VideoTools_Cinema(); initPkg_VideoTools_VideoSync(); initPkg_VideoTools_VideoRecall(); initPkg_VideoTools_Filter(); } function initPkg_VideoTools_Func() { document.getElementById("js-player-toolbar").addEventListener("mouseover", () => { document.getElementsByClassName("cinema__wrap")[0].style.display = "none"; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; document.getElementsByClassName("filter__wrap")[0].style.display = "none"; }); document.getElementById("js-player-asideMain").addEventListener("mouseover", () => { document.getElementsByClassName("cinema__wrap")[0].style.display = "none"; document.getElementsByClassName("videospeed__wrap")[0].style.display = "none"; document.getElementsByClassName("filter__wrap")[0].style.display = "none"; }); document.getElementsByClassName("inputView-2a65aa")[0].addEventListener("focus", () => { isInput = true; }); document.getElementsByClassName("inputView-2a65aa")[0].addEventListener("blur", () => { isInput = false; }); let m = new DomHook(".app-f0f9c7", false, (m) => { if (m.length > 0) { if (m[0].addedNodes.length > 0) { isInput = true; } else if (m[0].removedNodes.length > 0) { isInput = false; } } }); } function signAct(alias) { return new Promise(resolve => { fetch("https://www.douyu.com/japi/carnival/nc/signAct/signIn", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: 'token=' + dyToken + "&signAlias=" + alias }).then(res => { return res.json(); }).then(ret => { resolve(ret); }) }) } function userStatus(tasks) { return new Promise(resolve => { fetch("https://www.douyu.com/japi/carnival/nc/actTask/userStatus", { method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: `tasks=${tasks}&token=${dyToken}` }).then(res => { return res.json(); }).then(ret => { resolve(ret); }).catch(err => { console.log("请求失败!", err); }) }) } function takeActPrize(name) { // 该接口会在userStatus后自动执行 // 关注20200911LMJX_T2 // 分享20200911LMJX_T5 return new Promise(resolve => { fetch('https://www.douyu.com/japi/carnival/nc/actTask/takePrize',{ method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: `token=${ dyToken }&aid=android&taskAlias=${ name }` }).then(res => { return res.json(); }).then(ret => { resolve(ret); }).catch(err => { console.log("请求失败!", err); }) }) } function addFollowRoom(rid) { return new Promise(resolve => { fetch('https://www.douyu.com/wgapi/livenc/liveweb/follow/add',{ method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: `rid=${ rid }&ctn=${ getCCN() }` }).then(res => { return res.json(); }).then(ret => { resolve(ret); }).catch(err => { console.log("请求失败!", err); }) }) } function removeFollowRoom(rid) { return new Promise(resolve => { fetch('https://www.douyu.com/wgapi/livenc/liveweb/follow/rm',{ method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: `rid=${ rid }&ctn=${ getCCN() }` }).then(res => { return res.json(); }).then(ret => { resolve(ret); }).catch(err => { console.log("请求失败!", err); }) }) } function shareAct(name) { // 20200911LMJX return new Promise(resolve => { fetch('https://www.douyu.com/japi/carnival/common/share',{ method: 'POST', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/x-www-form-urlencoded'}, body: `actAlias=${ name }&token=${ dyToken }` }).then(res => { return res.json(); }).then(ret => { resolve(ret); }).catch(err => { console.log("请求失败!", err); }) }) } function getJackpot(id) { return new Promise(resolve => { fetch("https://www.douyu.com/japi/carnival/nc/lottery/jackpot", { method: 'POST', headers: {'Content-Type': 'application/json;charset=UTF-8'}, body: `{"activityId":"${ id }","token":"${ dyToken }"}` }).then(res => { return res.json(); }).then(ret => { resolve(ret); }) }) } function getActRemaining(id) { return new Promise(resolve => { fetch("https://www.douyu.com/japi/carnival/nc/lottery/remaining?activityId=" + id, { method: 'GET', mode: 'no-cors', credentials: 'include', headers: {'Content-Type': 'application/json;charset=UTF-8'}, }).then(res => { return res.json(); }).then(ret => { resolve(ret); }) }) } function getActList() { return new Promise(resolve => { fetch('https://www.douyuex.com/src/actList.txt',{ method: 'GET', mode: 'cors', cache: 'no-store', credentials: 'omit', }).then(res => { return res.text(); }).then(txt => { resolve(txt); }).catch(err => { console.error('请求失败', err); }) }) } // function douyuVideo_createUp(cookie, vid, ctn) { // // 斗鱼视频点赞 // return exHttpRequest("https://v.douyu.com/api/video/createUp", "POST", { // cookie: cookie // }, "vid=" + vid + "&ccn=" + ctn); // } // function douyuVideo_destroyUp(cookie, vid, ctn) { // // 斗鱼视频取消点赞 // return exHttpRequest("https://v.douyu.com/api/video/destroyUp", "POST", { // cookie: cookie // }, "vid=" + vid + "&ccn=" + ctn); // } // function douyuVideo_createCollect(cookie, vid, ctn) { // // 斗鱼视频收藏 // return exHttpRequest("https://v.douyu.com/api/video/createCollect", "POST", { // cookie: cookie // }, "vid=" + vid + "&ccn=" + ctn); // } // function douyuVideo_destroyCollect(cookie, vid, ctn) { // // 斗鱼视频取消收藏 // return exHttpRequest("https://v.douyu.com/api/video/destroyCollect", "POST", { // cookie: cookie // }, "vid=" + vid + "&ccn=" + ctn); // } // function douyuVideo_createSub(cookie, uid, ctn) { // // 斗鱼关注UP主 // return exHttpRequest("https://v.douyu.com/api/video/createSub", "POST", { // cookie: cookie // }, "uid=" + uid + "&ccn=" + ctn); // } // function douyuVideo_destroySub(cookie, uid, ctn) { // // 斗鱼取消关注UP主 // return exHttpRequest("https://v.douyu.com/api/video/destroySub", "POST", { // cookie: cookie // }, "uid=" + uid + "&ccn=" + ctn); // } // function douyuVideo_shareVideo(token, vid) { // // 斗鱼分享视频 // return exHttpRequest("https://apiv2.douyucdn.cn/mgapi/vodnc/share/success?token=" + token + "&client_sys=android", "POST", {}, "hash_id=" + vid + "&share_type=weixin"); // } /* CClick 单双击/长按不冲突的解决方案 By: 小淳 调用方法: let a = new CClick(document.getElementById("")); a.click((e) => {// TODO}); a.dbClick((e) => {// TODO}); a.longClick((e) => {// TODO}); */ class CClick { constructor(element) { const CONST_LONG_TIME = 700; // 长按多少ms执行 const CONST_DOUBLE_TIME = 250; // 双击的间隔 this.func_click = null; this.func_dbClick = null; this.func_longClick = null; let isLong = false; let timer_long; let clickTimes = 0; let timer_db; element.onmousedown = (event) => { if (event.button !== 0) { return; } isLong = false; timer_long = setTimeout(() => { isLong = true; if (this.func_longClick !== null) { this.func_longClick(event); } }, CONST_LONG_TIME); }; element.onmouseup = (event) => { if (event.button !== 0) { return; } if (isLong == false) { clearTimeout(timer_long); clickTimes++; if (clickTimes >= 2) { clearTimeout(timer_db); clickTimes = 0; if (this.func_dbClick !== null) { this.func_dbClick(event); } return; } timer_db = setTimeout(() => { clickTimes = 0; if (this.func_click !== null) { this.func_click(event); } }, CONST_DOUBLE_TIME); } }; } click(callback) { this.func_click = callback; } dbClick(callback) { this.func_dbClick = callback; } longClick(callback) { this.func_longClick = callback; } } class DomHook { constructor(selector, isSubtree, callback) { this.selector = selector; this.isSubtree = isSubtree; let targetNode = document.querySelector(this.selector); if (targetNode == null) { return; } let observer = new MutationObserver(function(mutations) { callback(mutations); }); this.observer = observer; this.observer.observe(targetNode, { attributes: true, childList: true, subtree: this.isSubtree }); } closeHook() { this.observer.disconnect(); } } class DyWacthAd { constructor(posid, token, rid) { this.posid = posid; this.token = token; this.rid = rid; this._uid = String(token).split("_")[0]; this._mid = 0; this._infoBack = ""; } async start() { let info = await this.getInfo(this.posid, this.token, this.rid); if (info == false) { return false; } this._mid = info.mid; this._infoBack = info.infoBack; let isStart = await this.getStart(this.posid, this.token, this._uid, this._mid, this._infoBack); return isStart; } async finish() { let isFinish = await this.getFinish(this.posid, this.token, this._uid, this._mid, this._infoBack); return isFinish; } getInfo(posid, token, rid) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://rtbapi.douyucdn.cn/japi/sign/app/getinfo?token=" + token + "&mdid=phone" + "&client_sys=android", data: "posid=" + posid + "&roomid=" + rid + "&cate1=1&cate2=1&chanid=30" + '&device={"nt":"1"}', responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { if (ret.data.length == 0) { resolve(false); return; } let mid = ret.data[0].mid; let infoBack = encodeURIComponent(JSON.stringify(ret.data)); resolve({mid: mid, infoBack: infoBack}); } } }); }) } getStart(posid, token, uid, mid, infoBack) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/start?client_sys=android", data: "&uid=" + uid + "&roomId=" + rid + "&posCode=" + posid + "&token=" + token + "&clientType=1&creativeId=" + mid + "&infoBack=" + infoBack, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { resolve(true); } } }); }) } getFinish(posid, token, uid, mid, infoBack) { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://apiv2.douyucdn.cn/japi/inspire/api/ad/fishpond/mobile/finish?client_sys=android", data: "uid=" + uid + "&clientType=1&posCode=" + posid + "&creativeId=" + mid + "&roomId=" + rid + "&token=" + token + "&infoBack=" + infoBack, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, onload: function(response) { let ret = response.response; if (ret.error == "0") { if (ret.data == "1") { resolve(true); } else { resolve(false); } } else { resolve(false); } } }); }) } } /* md5.js */ var hexcase=0;var b64pad="";var chrsz=8;function hex_md5(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz))}function b64_md5(s){return binl2b64(core_md5(str2binl(s),s.length*chrsz))}function str_md5(s){return binl2str(core_md5(str2binl(s),s.length*chrsz))}function hex_hmac_md5(key,data){return binl2hex(core_hmac_md5(key,data))}function b64_hmac_md5(key,data){return binl2b64(core_hmac_md5(key,data))}function str_hmac_md5(key,data){return binl2str(core_hmac_md5(key,data))}function md5_vm_test(){return hex_md5("abc")=="900150983cd24fb0d6963f7d28e17f72"}function core_md5(x,len){x[len>>5]|=0x80<<((len)%32);x[(((len+64)>>>9)<<4)+14]=len;var a=1732584193;var b=-271733879;var c=-1732584194;var d=271733878;for(var i=0;i16)bkey=core_md5(bkey,key.length*chrsz);var ipad=Array(16),opad=Array(16);for(var i=0;i<16;i++){ipad[i]=bkey[i]^0x36363636;opad[i]=bkey[i]^0x5C5C5C5C}var hash=core_md5(ipad.concat(str2binl(data)),512+data.length*chrsz);return core_md5(opad.concat(hash),512+128)}function safe_add(x,y){var lsw=(x&0xFFFF)+(y&0xFFFF);var msw=(x>>16)+(y>>16)+(lsw>>16);return(msw<<16)|(lsw&0xFFFF)}function bit_rol(num,cnt){return(num<>>(32-cnt))}function str2binl(str){var bin=Array();var mask=(1<>5]|=(str.charCodeAt(i/chrsz)&mask)<<(i%32);return bin}function binl2str(bin){var str="";var mask=(1<>5]>>>(i%32))&mask);return str}function binl2hex(binarray){var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";var str="";for(var i=0;i>2]>>((i%4)*8+4))&0xF)+hex_tab.charAt((binarray[i>>2]>>((i%4)*8))&0xF)}return str}function binl2b64(binarray){var tab="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var str="";for(var i=0;i>2]>>8*(i%4))&0xFF)<<16)|(((binarray[i+1>>2]>>8*((i+1)%4))&0xFF)<<8)|((binarray[i+2>>2]>>8*((i+2)%4))&0xFF);for(var j=0;j<4;j++){if(i*8+j*6>binarray.length*32)str+=b64pad;else str+=tab.charAt((triplet>>6*(3-j))&0x3F)}}return str} /* Notice.js */ (function webpackUniversalModuleDefinition(root,factory){if(typeof exports==='object'&&typeof module==='object')module.exports=factory();else if(typeof define==='function'&&define.amd)define("NoticeJs",[],factory);else if(typeof exports==='object')exports["NoticeJs"]=factory();else root["NoticeJs"]=factory()})(typeof self!=='undefined'?self:this,function(){return(function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId]){return installedModules[moduleId].exports}var module=installedModules[moduleId]={i:moduleId,l:false,exports:{}};modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);module.l=true;return module.exports}__webpack_require__.m=modules;__webpack_require__.c=installedModules;__webpack_require__.d=function(exports,name,getter){if(!__webpack_require__.o(exports,name)){Object.defineProperty(exports,name,{configurable:false,enumerable:true,get:getter})}};__webpack_require__.n=function(module){var getter=module&&module.__esModule?function getDefault(){return module['default']}:function getModuleExports(){return module};__webpack_require__.d(getter,'a',getter);return getter};__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)};__webpack_require__.p="dist/";return __webpack_require__(__webpack_require__.s=2)})([(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var noticeJsModalClassName=exports.noticeJsModalClassName='noticejs-modal';var closeAnimation=exports.closeAnimation='noticejs-fadeOut';var Defaults=exports.Defaults={title:'',text:'',type:'success',position:'topRight',timeout:30,progressBar:true,closeWith:['button'],animation:null,modal:false,scroll:{maxHeight:300,showOnHover:true},rtl:false,callbacks:{beforeShow:[],onShow:[],afterShow:[],onClose:[],afterClose:[],onClick:[],onHover:[],onTemplate:[]}}}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.appendNoticeJs=exports.addListener=exports.CloseItem=exports.AddModal=undefined;exports.getCallback=getCallback;var _api=__webpack_require__(0);var API=_interopRequireWildcard(_api);function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj.default=obj;return newObj}}var options=API.Defaults;function getCallback(ref,eventName){if(ref.callbacks.hasOwnProperty(eventName)){ref.callbacks[eventName].forEach(function(cb){if(typeof cb==='function'){cb.apply(ref)}})}}var AddModal=exports.AddModal=function AddModal(){if(document.getElementsByClassName(API.noticeJsModalClassName).length<=0){var element=document.createElement('div');element.classList.add(API.noticeJsModalClassName);element.classList.add('noticejs-modal-open');document.body.appendChild(element);setTimeout(function(){element.className=API.noticeJsModalClassName},200)}};var CloseItem=exports.CloseItem=function CloseItem(item){getCallback(options,'onClose');if(options.animation!==null&&options.animation.close!==null){item.className+=' '+options.animation.close}setTimeout(function(){item.remove()},200);if(options.modal===true&&document.querySelectorAll("[noticejs-modal='true']").length>=1){document.querySelector('.noticejs-modal').className+=' noticejs-modal-close';setTimeout(function(){document.querySelector('.noticejs-modal').remove()},500)}var position='.'+item.closest('.noticejs').className.replace('noticejs','').trim();setTimeout(function(){if(document.querySelectorAll(position+' .item').length<=0){let p=document.querySelector(position);if(p!=null){p.remove()}}},500)};var addListener=exports.addListener=function addListener(item){if(options.closeWith.includes('button')){item.querySelector('.close').addEventListener('click',function(){CloseItem(item)})}if(options.closeWith.includes('click')){item.style.cursor='pointer';item.addEventListener('click',function(e){if(e.target.className!=='close'){getCallback(options,'onClick');CloseItem(item)}})}else{item.addEventListener('click',function(e){if(e.target.className!=='close'){getCallback(options,'onClick')}})}item.addEventListener('mouseover',function(){getCallback(options,'onHover')})};var appendNoticeJs=exports.appendNoticeJs=function appendNoticeJs(noticeJsHeader,noticeJsBody,noticeJsProgressBar){var target_class='.noticejs-'+options.position;var noticeJsItem=document.createElement('div');noticeJsItem.classList.add('item');noticeJsItem.classList.add(options.type);if(options.rtl===true){noticeJsItem.classList.add('noticejs-rtl')}if(noticeJsHeader&¬iceJsHeader!==''){noticeJsItem.appendChild(noticeJsHeader)}noticeJsItem.appendChild(noticeJsBody);if(noticeJsProgressBar&¬iceJsProgressBar!==''){noticeJsItem.appendChild(noticeJsProgressBar)}if(['top','bottom'].includes(options.position)){document.querySelector(target_class).innerHTML=''}if(options.animation!==null&&options.animation.open!==null){noticeJsItem.className+=' '+options.animation.open}if(options.modal===true){noticeJsItem.setAttribute('noticejs-modal','true');AddModal()}addListener(noticeJsItem,options.closeWith);getCallback(options,'beforeShow');getCallback(options,'onShow');document.querySelector(target_class).appendChild(noticeJsItem);getCallback(options,'afterShow');return noticeJsItem}}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,NoticeJs);this.options=Object.assign(API.Defaults,options);this.component=new _components.Components();this.on('beforeShow',this.options.callbacks.beforeShow);this.on('onShow',this.options.callbacks.onShow);this.on('afterShow',this.options.callbacks.afterShow);this.on('onClose',this.options.callbacks.onClose);this.on('afterClose',this.options.callbacks.afterClose);this.on('onClick',this.options.callbacks.onClick);this.on('onHover',this.options.callbacks.onHover);return this}_createClass(NoticeJs,[{key:'show',value:function show(){var container=this.component.createContainer();if(document.querySelector('.noticejs-'+this.options.position)===null){document.body.appendChild(container)}var noticeJsHeader=void 0;var noticeJsBody=void 0;var noticeJsProgressBar=void 0;noticeJsHeader=this.component.createHeader(this.options.title,this.options.closeWith);noticeJsBody=this.component.createBody(this.options.text);if(this.options.progressBar===true){noticeJsProgressBar=this.component.createProgressBar()}var noticeJs=helper.appendNoticeJs(noticeJsHeader,noticeJsBody,noticeJsProgressBar);return noticeJs}},{key:'on',value:function on(eventName){var cb=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};if(typeof cb==='function'&&this.options.callbacks.hasOwnProperty(eventName)){this.options.callbacks[eventName].push(cb)}return this}}]);return NoticeJs}();exports.default=NoticeJs;module.exports=exports['default']}),(function(module,exports){}),(function(module,exports,__webpack_require__){"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Components=undefined;var _createClass=function(){function defineProperties(target,props){for(var i=0;i'+'
    '+'×'+''+""+this.textTemplate.title+""+""+"
    "+'
    '+''+this.textTemplate.content+""+"
    "+'"+"
    "+"";return temp},getConfirmTemplate:function(){return'
    '+'
    '+'
    '+'
    '+'×'+''+""+this.textTemplate.title+""+""+"
    "+'
    '+''+this.textTemplate.content+"?"+"
    "+'"+"
    "+"
    "+"
    "},getPromptTemplate:function(){return'
    '+'
    '+'
    '+'
    '+'×'+''+""+this.textTemplate.title+""+""+"
    "+'
    '+''+"
    "+'"+"
    "+"
    "+"
    "},alert:function(opt){this.textTemplate.title=opt.title||this.textTemplate.title;this.textTemplate.content=opt.content||this.textTemplate.content;this.textTemplate.okBtn=opt.okBtn||this.textTemplate.okBtn;this.textTemplate.okBtnColor=opt.okBtnColor||this.textTemplate.okBtnColor;this.textTemplate.contentColor=opt.contentColor||this.textTemplate.contentColor;var box=document.createElement("div"),_this=this;box.className=this.containerClass;box.innerHTML=this.getAlertTemplate();this.box=box;document.body.appendChild(this.box);var btn=document.getElementsByClassName("btn-footer-ok");btn[btn.length-1].focus();btn[btn.length-1].onclick=function(){if(opt.onConfirm){opt.onConfirm()}_this.removeBox()}},confirm:function(opt){this.textTemplate.title=opt.title||this.textTemplate.promptTitle;this.textTemplate.promptPlaceholder=opt.promptPlaceholder||this.textTemplate.promptPlaceholder;this.textTemplate.okBtn=opt.okBtn||this.textTemplate.promptOkBtn;this.textTemplate.okBtnColor=opt.okBtnColor||this.textTemplate.okBtnColor;this.textTemplate.cancelBtn=opt.cancelBtn||this.textTemplate.cancelBtn;this.textTemplate.cancelBtnColor=opt.cancelBtnColor||this.textTemplate.cancelBtnColor;this.textTemplate.content=opt.content||this.textTemplate.content;var box=document.createElement("div"),_this=this;this.box=box;box.className=this.containerClass;box.innerHTML=this.getConfirmTemplate();document.body.appendChild(box);var okBtn=document.getElementsByClassName("btn-footer-ok");okBtn[okBtn.length-1].focus();okBtn[okBtn.length-1].onclick=function(){if(opt.onConfirm){opt.onConfirm()}_this.removeBox()};var cancelBtn=document.getElementsByClassName("btn-footer-cancel");cancelBtn[cancelBtn.length-1].onclick=function(){if(opt.onCancel){opt.onCancel()}_this.removeBox()}},prompt:function(opt){this.textTemplate.title=opt.title||this.textTemplate.title;this.textTemplate.content=opt.content||this.textTemplate.content;this.textTemplate.contentColor=opt.contentColor||this.textTemplate.contentColor;this.textTemplate.okBtn=opt.okBtn||this.textTemplate.okBtn;this.textTemplate.okBtnColor=opt.okBtnColor||this.textTemplate.okBtnColor;this.textTemplate.cancelBtn=opt.cancelBtn||this.textTemplate.cancelBtn;this.textTemplate.cancelBtnColor=opt.cancelBtnColor||this.textTemplate.cancelBtnColor;var box=document.createElement("div"),_this=this;box.className=this.containerClass;box.innerHTML=this.getPromptTemplate();this.box=box;document.body.appendChild(box);var promptInput=document.getElementsByClassName("postbird-prompt-input"); promptInput=promptInput[promptInput.length-1];promptInput.focus();var okBtn=document.getElementsByClassName("btn-footer-ok");var inputData=promptInput.value;okBtn[okBtn.length-1].focus();okBtn[okBtn.length-1].onclick=function(){if(opt.onConfirm){opt.onConfirm(promptInput.value)}_this.removeBox()};var cancelBtn=document.getElementsByClassName("btn-footer-cancel");cancelBtn[cancelBtn.length-1].onclick=function(){if(opt.onCancel){opt.onCancel(promptInput.value)}_this.removeBox()}},colse:function(){this.removeBox()},removeBox:function(){var box=document.getElementsByClassName(this.containerClass);document.body.removeChild(box[box.length-1])}}; /* Get Bilibili Real Live URL (https) By: 小淳 */ function getRealLive_Bilibili(room_id, qn, cdn, reallive_callback) { // 第一个参数传入string,表示房间号(注意是真实房间号) // 第二个参数传入string(1,2,3,4,5),表示清晰度 流畅_80(1) 高清_150(2) 超清_250(3) 蓝光_400p(4) 原画_10000p(5) // 第三个参数传入string(1,2,3,4),表示线路 1:主线路 2:备用线路1 3:备用线路2 4:备用线路3 此参数只对HTTPS有效 // 第四个参数传入回调函数,最好是箭头函数,用于处理返回的地址,例: (url) => {console.log(url)} let qn_data = "80"; switch (qn) { case "1": qn_data = "80"; break; case "2": qn_data = "150"; break; case "3": qn_data = "250"; break; case "4": qn_data = "400"; break; case "5": qn_data = "10000"; break; default: qn_data = "80"; break; } GM_xmlhttpRequest({ method: "GET", url: "https://api.live.bilibili.com/room/v1/Room/playUrl?cid=" + room_id + "&qn=" + qn_data + "&platform=web", responseType: "json", onload: function(response) { let ret = response.response; let rurl = ""; if (ret.data.durl != null) { rurl = ret.data.durl[Number(cdn)].url; } else { rurl = ""; } reallive_callback(rurl); } }); } /* Get Bilibili Real Room ID By: 小淳 */ function getRealRid_Bilibili(url, realrid_callback) { GM_xmlhttpRequest({ method: "GET", url: url, responseType: "text", onload: function(response) { let ret = response.response; let rid = ""; rid = getStrMiddle(ret, 'room_id":', ','); rid = rid.trim(); if (rid == "") { rid = "-1"; } realrid_callback(rid); } }); } /* Get Douyu Real Live URL (http/https) By: 小淳 */ function getRealLive_Douyu(room_id, is_https, qn, reallive_callback) { // 第一个参数传入string,表示房间号(注意是真实房间号) // 第二个参数传入bool,表示是否返回https地址。注意https地址只能使用一次,使用过以后需要再次获取;http地址无限制 // 第三个参数传入string(1,2,3,4),表示清晰度 流畅_550p(rate:1) 高清_1200p(rate:2) 超清_2000p(rate:3) 蓝光4M_4000p(rate:0) 填写777则返回默认清晰度 // 第四个参数传入回调函数,最好是箭头函数,用于处理返回的地址,例: (url) => {console.log(url)} GM_xmlhttpRequest({ method: "GET", url: 'https://m.douyu.com/' + room_id, responseType: "text", onload: function(response) { let a = response.response.match(/(function ub9.*)[\s\S](var.*)/i); let ub9_ex = String(a[0]).replace("ub98484234", "ub98484234_ex"); eval1(ub9_ex, "exScript1"); let tt0 = Math.round(new Date().getTime()/1000).toString(); RealLive_get_sign_url(room_id, tt0, is_https, qn, reallive_callback); // 传入参数无误 } }); } function RealLive_get_sign_url(r, tt, is_https, qn, reallive_callback) { let param1 = ub98484234_ex(r, getDyDid(), tt); let postData; if (qn == "777") { postData = param1 + "&ver=219032101&rid=" + r + "&rate=1"; } else { postData = param1 + "&ver=219032101&rid=" + r + "&rate=" + qn; } document.getElementById("exScript1").remove(); GM_xmlhttpRequest({ method: "POST", url: "https://m.douyu.com/api/room/ratestream", data: postData, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, onload: function(response) { let ret = response.response; let result = ""; if (ret.code == "0") { let url = ret.data.url; if (String(url).indexOf("mix=1") != -1) { result = "PKing" } else { let p = /^[0-9a-zA-Z]*/; let tmpArr = String(ret.data.url).split("/"); result = String(tmpArr[tmpArr.length - 1]).match(p)[0]; } } else { result = "0"; } let cl = ""; switch (qn) { case "1": cl = "550p" break; case "2": cl = "1200p" break; case "3": cl = "2000p" break; case "4": cl = "4000p" break; default: cl = "1200p" break; } let realLive = ""; if (result == "0") { realLive = "None"; } else { if (is_https == true) { realLive = String(ret.data.url).replace("m3u8", "flv"); realLive = realLive.replace("http:", "https:"); } else { if (qn == "777") { // qn写777则不返回清晰度,即默认 realLive = "https://tx2play1.douyucdn.cn/live/" + result + ".flv?uuid="; } else { realLive = "https://tx2play1.douyucdn.cn/live/" + result + "_" + cl + ".flv?uuid="; } } } reallive_callback(realLive); } }); } function eval1(str, iid) { let sc = document.createElement("script"); sc.id = iid sc.setAttribute("type","text\/javascript"); sc.appendChild(document.createTextNode(str)); document.body.appendChild(sc); } /* Get Douyu Real Room ID By: 小淳 */ function getRealRid_Douyu(url, realrid_callback) { fetch(url,{ method: 'GET', mode: 'no-cors', cache: 'default', credentials: 'include', }).then(res => { return res.text(); }).then(doc => { doc = (new DOMParser()).parseFromString(doc, 'text/html'); let url = doc.getElementsByTagName('html')[0].innerHTML; let urlLen = ("$ROOM.room_id =").length; let ridPos = url.indexOf('$ROOM.room_id ='); let rid = url.substring(ridPos + urlLen, url.indexOf(';', ridPos + urlLen)); rid = rid.trim(); if (isRid(rid) == true) { realrid_callback(rid); } else { showMessage("获取直播间失败,请检查直播间地址是否正确!", "error") } }).catch(err => { console.log("请求失败!", err); }) } /* Get Huya Real Live URL (https) By: 小淳 */ function getRealLive_Huya(url, qn, reallive_callback) { // 第一个参数传入string,表示房间号(注意是真实房间号) // 第二个参数传入string(1,2,3,4),表示清晰度 流畅_500(1) 超清_2500(2) 蓝光4M_4500(3) 原画(4) // 第三个参数传入string(1,2,3,4),表示线路 1:主线路 2:备用线路1 3:备用线路2 4:备用线路3 // 第四个参数传入回调函数,最好是箭头函数,用于处理返回的地址,例: (url, msg) => {console.log(url, msg)} // 这个回调函数有2个参数,第一个是直播流地址,第二个是信息,用于判断错误 let qn_data = "500"; switch (qn) { case "1": qn_data = "500"; break; case "2": qn_data = "2500"; break; case "3": qn_data = "4500"; break; case "4": qn_data = "0"; break; default: qn_data = "500"; break; } GM_xmlhttpRequest({ method: 'GET', headers: { 'user-agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1' }, url: url, responseType: 'blob', onload: resp=>{ let msg = ""; let ret = resp.responseText; let liveUrl = /\\s*var liveLineUrl = "(.+)";\s*\<\/script\>/.exec(ret); if (liveUrl == null) { msg = "房间暂未开播"; } else { liveUrl = liveUrl[1]; liveUrl = liveUrl.replace(/(_\d+)(.m3u8)/, '$2'); liveUrl = "https:" + liveUrl; liveUrl = liveUrl + "&ratio=" + qn_data; liveUrl = String(liveUrl).replace("m3u8", "flv"); } reallive_callback(liveUrl, msg); } }) } class STT { escape(v) { return v.toString().replace(/@/g, '@A').replace(/\//g, '@S') } unescape(v) { return v.toString().replace(/@A/g, '@').replace(/@S/g, '/') } serialize(raw) { if (util.isObject(raw)) { return Object.keys(raw).map(k => `${k}@=${this.escape(this.serialize(raw[k]))}/`).join('') } else if (Array.isArray(raw)) { return raw.map(v => `${this.escape(this.serialize(v))}/`).join('') } else if (util.isString(raw) || util.isNumber(raw)) { return raw.toString() } } deserialize(raw) { if (raw.includes('//')) { return raw.split('//').filter(e => e !== '').map(item => this.deserialize(item)) } if (raw.includes('@=')) { return raw.split('/').filter(e => e !== '').reduce((o, s) => { const [k, v] = s.split('@=') o[k] = this.deserialize(this.unescape(v)) return o }, {}) } else if (raw.includes('@A=')) { return this.deserialize(this.unescape(raw)) } else { return raw.toString() } } } // let a = new STT(); // a.deserialize(`type@=rquizisn/rid@=475252/qst@=1/qril@=qid@AA=4441661@ASqbid@AA=7341fe0a159617089038802172028@ASqt@AA=我的死亡数能否小于等于5@ASfon@AA=能@ASson@AA=不能@ASfbuid@AA=9985474@ASsbuid@AA=182243496@ASfbmc@AA=2360@ASsbmc@AA=4545@ASfolpc@AA=10@ASsolpc@AA=220@ASfobc@AA=440126@ASsobc@AA=39210@ASfbid@AA=109846265@ASsbid@AA=109846431@ASqs@AA=1@ASet@AA=-1@ASwo@AA=0@ASscs@AA=0@ASsuid@AA=25332273@ASsname@AA=孙悟空丨兰林汉@ASaktp@AA=10@ASft@AA=0@ASflagc@AA=0@AS@Sqid@AA=4441660@ASqbid@AA=7341fe0a159617089038802172028@ASqt@AA=比赛结果@ASfon@AA=赢@ASson@AA=输@ASfbuid@AA=0@ASsbuid@AA=136676242@ASfbmc@AA=0@ASsbmc@AA=35978@ASfolpc@AA=0@ASsolpc@AA=990@ASfobc@AA=1809968@ASsobc@AA=64078@ASfbid@AA=0@ASsbid@AA=109846387@ASqs@AA=1@ASet@AA=-1@ASwo@AA=0@ASscs@AA=0@ASsuid@AA=25332273@ASsname@AA=孙悟空丨兰林汉@ASaktp@AA=10@ASft@AA=0@ASflagc@AA=0@AS@Sqid@AA=4441659@ASqbid@AA=7341fe0a159617089038802172028@ASqt@AA=我的伤害能否全场第一@ASfon@AA=能@ASson@AA=不能@ASfbuid@AA=186024887@ASsbuid@AA=175701690@ASfbmc@AA=382@ASsbmc@AA=86040@ASfolpc@AA=510@ASsolpc@AA=10@ASfobc@AA=90719@ASsobc@AA=224159@ASfbid@AA=109846402@ASsbid@AA=109846396@ASqs@AA=1@ASet@AA=-1@ASwo@AA=0@ASscs@AA=0@ASsuid@AA=25332273@ASsname@AA=孙悟空丨兰林汉@ASaktp@AA=10@ASft@AA=0@ASflagc@AA=0@AS@S/`) // function parseMsg(t) { // if (t.includes("//")) { // return t.split("//").map(item => {return parseMsg(item)}).filter(e => { return e !== "" }); // } // if (t.includes("@=")) { // let arr = t.split("/"); // return arr.reduce((prev, cur) => { // if (cur !== "") { // let obj = cur.split("@="); // prev[obj[0]] = parseMsg(obj[1].replace(/@A/g, '@').replace(/@S/g, '/')); // } // return prev; // }, {}) // } else if (t.includes("@A=")) { // return parseMsg(t.replace(/@A/g, '@').replace(/@S/g, '/')); // } else { // return t; // } // } /* Style Hook 用于替换页面的原样式 By 小淳 */ function StyleHook_set(styleName, styleText) { // styleName:样式id名,建议以Ex_Style_大驼峰的形式命名 if (document.getElementById(styleName) == null) { let styleElement = document.createElement("style"); styleElement.id = styleName; styleElement.innerHTML = styleText; document.body.append(styleElement); } } function StyleHook_remove(styleName) { let e = document.getElementById(styleName); if (e !== null) { document.getElementById(styleName).remove(); } } /* DouyuEx WebSocket By: 小淳 此处为一些公共函数 */ function WebSocket_Packet(str) { const MSG_TYPE = 689; let bytesArr = stringToByte(str); let buffer = new Uint8Array(bytesArr.length + 4 + 4 + 2 + 1 + 1 + 1); let p_content = new Uint8Array(bytesArr.length); // 消息内容 for (let i = 0; i < p_content.length; i++) { p_content[i] = bytesArr[i]; } let p_length = new Uint32Array([bytesArr.length + 4 + 2 + 1 + 1 + 1]); // 消息长度 let p_type = new Uint32Array([MSG_TYPE]); // 消息类型 buffer.set(new Uint8Array(p_length.buffer), 0); buffer.set(new Uint8Array(p_length.buffer), 4); buffer.set(new Uint8Array(p_type.buffer), 8); buffer.set(p_content, 12); return buffer; } function stringToByte(str) { let bytes = new Array(); let len, c; len = str.length; for(let i = 0; i < len; i++) { c = String(str).charCodeAt(i); if(c >= 0x010000 && c <= 0x10FFFF) { bytes.push(((c >> 18) & 0x07) | 0xF0); bytes.push(((c >> 12) & 0x3F) | 0x80); bytes.push(((c >> 6) & 0x3F) | 0x80); bytes.push((c & 0x3F) | 0x80); } else if(c >= 0x000800 && c <= 0x00FFFF) { bytes.push(((c >> 12) & 0x0F) | 0xE0); bytes.push(((c >> 6) & 0x3F) | 0x80); bytes.push((c & 0x3F) | 0x80); } else if(c >= 0x000080 && c <= 0x0007FF) { bytes.push(((c >> 6) & 0x1F) | 0xC0); bytes.push((c & 0x3F) | 0x80); } else { bytes.push(c & 0xFF); } } return bytes; } function byteToString(arr) { if(typeof arr === 'string') { return arr; } let str = '', _arr = arr; for(let i = 0; i < _arr.length; i++) { let one = _arr[i].toString(2), v = one.match(/^1+?(?=0)/); if(v && one.length == 8) { let bytesLength = v[0].length; let store = _arr[i].toString(2).slice(7 - bytesLength); for(let st = 1; st < bytesLength; st++) { store += _arr[st + i].toString(2).slice(2); } str += String.fromCharCode(parseInt(store, 2)); i += bytesLength - 1; } else { str += String.fromCharCode(_arr[i]); } } return str; } function hex2bin(e) { if ("string" === typeof e && e.length % 8 === 0) { for (let r = [], t = e.length, o = 0; o < t;) r.push(e.substr(o, 2)), o += 2; for (let n = [], i = r.length, s = 0; s < i;) n.push(parseInt(r.slice(s, s + 4).reverse().join(""), 16)), s += 4; return n } return null } function hex(e) { if (Array.isArray(e)) { let r = "0123456789abcdef".split(""); return e.map(function (e) { for (let t = "", o = 0; o < 4; o++) t += r[e >> 8 * o + 4 & 15] + r[e >> 8 * o & 15]; return t }).join("") } return "" } /* DouyuEx WebSocket UnLogin By: 小淳 */ class Ex_WebSocket_UnLogin { // 调用方法: // 连接:let a = new Ex_WebSocket_UnLogin("房间号", 消息回调函数); // 关闭连接: a.WebSocket_Close(); a = null; 记得null掉变量再重新连接 // 消息回调函数建议用箭头函数,示例:(msg) => {// TODO} constructor(rid, callback) { if ("WebSocket" in window) { this.timer = 0; this.roomid = rid; this.ws = new WebSocket("wss://danmuproxy.douyu.com:850" + String(getRandom(2,5))); // 负载均衡 8502~8504都可以用 this.ws.onopen = () => { this.ws.send(WebSocket_Packet("type@=loginreq/roomid@=" + rid)); this.ws.send(WebSocket_Packet("type@=joingroup/rid@=" + rid + "/gid@=-9999/")); this.timer = setInterval(() => { this.ws.send(WebSocket_Packet("type@=mrkl/")); }, 40000) // console.log("WebSocket已连接"); }; this.ws.onmessage = (e) => { let reader = new FileReader(); reader.onload = () => { let arr = String(reader.result).split("type@="); // 分包 reader = null; for (let i = 0; i < arr.length; i++) { if (arr[i].length > 12) { // 过滤第一条和心跳包 callback("type@=" + arr[i]); } } }; reader.readAsText(e.data); }; this.ws.onclose = () => { showMessage("服务器连接丢失,请尝试刷新页面", "error"); console.log("服务器连接丢失"); }; } } close() { clearInterval(this.timer); this.ws.close(); } } function initRouter(href) { if (String(href).indexOf("msg.douyu.com") != -1) { initRouter_Motorcade(); } else { if (String(href).indexOf("exid=chun") != -1) { initRouter_DouyuRoom_Popup(); } else { initRouter_DouyuRoom_Main(); } } } function initRouter_Motorcade() { // 车队 if (getQueryString("exid") == "chun") { signMotorcade_Sign(); } } function initRouter_DouyuRoom_Popup() { // 画中画 let intID = setInterval(() => { if (typeof(document.querySelector('div.wfs-2a8e83')) != "undefined") { document.querySelector('div.wfs-2a8e83').click(); document.querySelector('label.layout-Player-asidetoggleButton').click(); let l = document.querySelectorAll(".tip-e3420a > ul > li").length; document.querySelectorAll(".tip-e3420a > ul > li")[l - 1].click(); clearInterval(intID); } }, 1000); } function initRouter_DouyuRoom_Main() { // 主要 init(); let intID = setInterval(() => { if (typeof(document.getElementsByClassName("BackpackButton")[0]) != "undefined") { setTimeout(() => { initStyles(); initPkg(); initPkgSpecial(); initTimer(); }, 1500) clearInterval(intID); } }, 1000); } function initPkgSpecial() { if (rid == "5189167") { initPkg_Point(); } } // function initRouter_Novel() { // startWatchNovel(); // }