';
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, 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 += "
";
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 = 1016;
} else {
box.style.zIndex = 1015;
}
}
}
}
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, true, exVideoQn.value, (lurl) => {
videoPlayerArr[id].destroy();
setElementVideo(id, lurl);
})
}
exVideoCDN.onchange = function() {
getRealLive_Douyu(rid, true, 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, true, exVideoQn.value, (lurl) => {
GM_setClipboard(String(lurl).replace("https", "http"));
showMessage("复制成功", "success");
})
}
}
function createNewAudio_Douyu(id, rid) {
getRealLive_Douyu(rid, false, true, "1", (lurl) => {
console.log(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 += "
";
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);
}
});
}
// 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 += "
";
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 = 1016;
} else {
box.style.zIndex = 1015;
}
}
}
}
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 += "
";
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 = 1016;
} else {
box.style.zIndex = 1015;
}
}
}
}
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 = 1016;
} else {
box.style.zIndex = 1015;
}
}
}
}
}
let real_info = {
view: "",
showtime: 1015,
danmu_person_count: "",
gift_person_count: "",
paid_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();
setAvatarVideo();
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, 150000);
}).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(`https://www.doseeing.com/room/${rid}`, true);
})
}
function getRealViewer() {
if(document.querySelector(".MatchSystemChatRoomEntry") != null){
document.querySelector(".MatchSystemChatRoomEntry").style.display = "none";
}
GM_xmlhttpRequest({
method: "POST",
url: `https://www.doseeing.com/wecr/room/aggr`,
headers: {
"Connection": "keep-alive",
"Content-Type": "application/json;charset=UTF-8",
"Origin": "https://www.doseeing.com",
"Referer": "https://www.doseeing.com/room/" + rid,
"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 Edg/91.0.4472.77"
},
data: `{"m":"${window.btoa(`rid=${rid}&dt=0`).split("").reverse().join("")}"}`,
responseType: "json",
onload: function(response) {
let retData = response.response;
let showedTime = 0;
if (real_info.isShow == 2) {
showedTime = 0;
} else {
if (real_info.showtime == 1015) {
showedTime = 0;
} else {
showedTime = Math.floor(Date.now()/1000) - Number(real_info.showtime);
}
}
real_info.view = retData.data["active.uv"] || 0;
real_info.danmu_person_count = retData.data["chat.uv"] || 0;
real_info.gift_person_count = retData.data["gift.all.uv"] || 0;
real_info.paid_person_count = retData.data["gift.paid.uv"] || 0;
real_info.money_yc = Number(retData.data["gift.paid.price"] / 100 || 0).toFixed(2);
real_info.money_total = Number(retData.data["gift.all.price"] / 100 || 0).toFixed(2);
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 + " 付费人数:" + real_info.paid_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;
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"))));
}
});
}
function setAvatarVideo() {
// 1. 插入对应的dom
// 2. 绑定相应的函数
// 3. 拉高黑框
// 4. 对头像框鼠标移入移出事件绑定
let homeDom = document.querySelectorAll(".VideoEntry-tabItem>a")[0];
if (homeDom == undefined) {
return;
}
let videoUrl = homeDom.href + "?type=video";
let videoReplayUrl = homeDom.href + "?type=liveReplay";
setAvatarVideo_Dom();
setAvatarVideo_Func(videoUrl, videoReplayUrl);
document.getElementsByClassName("Title-anchorPic-bottom")[0].style.display = "none";
document.getElementsByClassName("Title-anchorPic-bottom")[0].style.height = "44px";
document.getElementsByClassName("Title-anchorPicBack")[0].addEventListener("mouseenter", () => {
document.getElementsByClassName("Title-anchorPic-bottom")[0].style.display = "block";
});
document.getElementsByClassName("Title-anchorPicBack")[0].addEventListener("mouseleave", () => {
document.getElementsByClassName("Title-anchorPic-bottom")[0].style.display = "none";
});
}
function setAvatarVideo_Dom() {
let a = document.createElement("div");
a.id = "Ex_VideoReview";
a.className = "Title-anchorPic-bottomItem";
a.innerHTML = "
回看 ";
let a1 = document.createElement("i");
a1.style = "top: 28px";
let a2 = document.createElement("div");
a2.id = "Ex_VideoSubmit";
a2.className = "Title-anchorPic-bottomItem";
a2.innerHTML = "
投稿 ";
let b = document.getElementsByClassName("Title-anchorPic-bottom")[0];
b.insertBefore(a, b.childNodes[0]);
b.insertBefore(a1, b.childNodes[0]);
b.insertBefore(a2, b.childNodes[0]);
}
function setAvatarVideo_Func(videoUrl, videoReplayUrl) {
document.getElementById("Ex_VideoSubmit").addEventListener("click", () => {
openPage(videoUrl, true);
})
document.getElementById("Ex_VideoReview").addEventListener("click", () => {
openPage(videoReplayUrl, true);
})
}
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-honor,.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]);
a = document.createElement("div");
a.id = "refresh-video2";
a.title = "视频区简洁模式";
a.innerHTML = '
';
b = document.getElementsByClassName("PlayerToolbar")[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];
let dom_refresh2 = document.getElementById("refresh-video2");
if (dom_toolbar.style.visibility == "hidden") {
dom_toolbar.style.visibility = "visible";
dom_video.style = "";
dom_refresh2.style.display = "none";
refresh_Video_removeStyle();
} else {
dom_toolbar.style.visibility = "hidden";
dom_video.style = "bottom:0;z-index:25";
dom_refresh2.style.display = "block";
refresh_Video_setStyle();
}
saveData_Refresh();
});
document.getElementById("refresh-video2").addEventListener("click", function() {
let dom_toolbar = document.getElementsByClassName("PlayerToolbar-Content")[0];
let dom_video = document.getElementsByClassName("layout-Player-video")[0];
let dom_refresh2 = document.getElementById("refresh-video2");
if (dom_toolbar.style.visibility == "hidden") {
dom_toolbar.style.visibility = "visible";
dom_video.style = "";
dom_refresh2.style.display = "none";
refresh_Video_removeStyle();
} else {
dom_toolbar.style.visibility = "hidden";
dom_video.style = "bottom:0;z-index:25";
dom_refresh2.style.display = "block";
refresh_Video_setStyle();
}
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;
}
}
// FullPageFollowGuide
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];
let dom_refresh2 = document.getElementById("refresh-video2");
dom_toolbar.style.visibility = "hidden";
dom_video.style = "bottom:0;z-index:25";
dom_refresh2.style.display = "block";
refresh_Video_setStyle();
}
}
}
function refresh_Video_setStyle() {
StyleHook_set("Ex_Style_VideoRefresh", `
.RandomPKBar,.LiveRoomLoopVideo,.LiveRoomDianzan,.maiMaitView-68e80c,.PkView{display:none !important;}
`)
}
function refresh_Video_removeStyle() {
StyleHook_remove("Ex_Style_VideoRefresh");
}
function initPkg_RemoveAD() {
let t = setInterval(() => {
let a = document.getElementsByClassName("PlayerToolbar-wealthNum")[0];
if (a != undefined) {
optimizePageStyle();
removeChatLimit();
clearInterval(t);
}
}, 1000);
}
// .dy-ModalRadius-mask,dy-ModalRadius-wrap{display:none !important;}
function removeAD() {
StyleHook_set("Ex_Style_RemoveAD", `
.XinghaiAd,.CustomGroupGuide,.FudaiGiftToolBarTips,.UserInfo-tryEnterHiddenLead,.BargainingKit,.AnchorPocketTips,.FishShopTip,.FollowGuide,#js-bottom-right-cloudGame,.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;}
.GuessGameMiniPanelB-wrapper{display:none !important;}
.ZoomTip{display:none !important;}
/*福利券*/
.PlayerToolbar-couponInfo{display:none !important;}
/*太空探险tips*/
.AroundStarsActTips-actTips,.AroundStarsMoonBoxTips,.AroundStarsPlanetTips{display:none !important;}
/*优化页面*/
#js-barrage-list-parent{scrollbar-width: none;-ms-overflow-style: none;width:98%;height:100%}
#js-barrage-list-parent::-webkit-scrollbar{display: none;}
/*陪玩*/
.InteractPlayWithEnter-enterTips1{display:none !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 optimizePageStyle() {
// 弹幕框滚动条隐藏
let dom_barrage = document.getElementById("js-barrage-list").parentNode;
dom_barrage.id = "js-barrage-list-parent";
}
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 "doSign":
await doSign(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(1015)
// 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=1015',{
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 = "502737841569427537";
// likeYubaPostComment(pid, "1483548421625277411", "-1").then(() => {likeYubaPostComment(pid, "1483548421625277411", "1")});
// likeYubaPostComment(pid, "1483548421625277411", "-1").then(() => {likeYubaPostComment(pid, "1483548421625277411", "1")});
// likeYubaPostComment(pid, "1482171839375552044", "-1").then(() => {likeYubaPostComment(pid, "1482171839375552044", "1")});
// likeYubaPostComment(pid, "1481389816302095706", "-1").then(() => {likeYubaPostComment(pid, "1481389816302095706", "1")});
// likeYubaPostComment(pid, "1470603012833589758", "-1").then(() => {likeYubaPostComment(pid, "1470603012833589758", "1")});
likeYubaPost(pid, "-1").then(() => {likeYubaPost(pid, "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/502737841569427537"
},
onload: function(response) {
let ret = response.response;
resolve(ret);
}
});
})
}
function likeYubaPost(post_id, type) {
let data = `pid=${ post_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/" + post_id
},
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);
}
function initPkg_TabSwitch() {
// Try to trick the site into thinking it's never hidden
Object.defineProperty(document, 'hidden', {value: false, writable: false});
Object.defineProperty(document, 'visibilityState', {value: 'visible', writable: false});
Object.defineProperty(document, 'webkitVisibilityState', {value: 'visible', writable: false});
document.dispatchEvent(new Event('visibilitychange'));
document.hasFocus = function () { return true; };
// visibilitychange events are captured and stopped
document.addEventListener('visibilitychange', function(e) {
e.stopImmediatePropagation();
}, true, true);
}
// 版本号
// 格式 yyyy.MM.dd.**
// var curVersion = "2020.01.12.01";
var curVersion = "2021.06.16.01"
var isNeedUpdate = false
var lastestVersion = ""
function initPkg_Update() {
initPkg_Update_Dom();
initPkg_Update_Func();
// Update_checkVersion(); // 首次检查更新
if (isNeedUpdate) {
Update_showTip(true);
}
}
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 checkUpdate_Src() {
return new Promise((resolve, reject) => {
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) {
resolve([true, txt]);
}
}
resolve(false);
}).catch(err => {
console.error('请求失败', err);
reject();
})
})
}
function checkUpdate_GreasyFork() {
return new Promise((resolve, reject) => {
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) {
resolve([true, v.innerText]);
}
}
resolve(false);
}).catch(err => {
console.error('请求失败', err);
reject();
})
})
}
async function Update_checkVersion(isShowNotUpdate = false) {
// 用解构赋值会导致函数undefined,暂不知原因
let tmp = [];
tmp = await checkUpdate_Src().catch(async (err) => {
tmp = await checkUpdate_GreasyFork().catch(err => {
tmp = [false, curVersion];
isNeedUpdate = tmp[0];
lastestVersion = tmp[1];
if (isNeedUpdate) {
Update_showMessage();
if (isNeedUpdate) {
Update_showTip(true);
}
} else {
if (isShowNotUpdate) {
showMessage(`【版本更新】当前版本${curVersion}已为最新`, "success")
}
}
})
})
isNeedUpdate = tmp[0];
lastestVersion = tmp[1];
if (isNeedUpdate) {
Update_showMessage();
if (isNeedUpdate) {
Update_showTip(true);
}
} else {
if (isShowNotUpdate) {
showMessage(`【版本更新】当前版本${curVersion}已为最新`, "success")
}
}
}
function Update_openUpdatePage() {
openPage("https://www.douyuex.com/install/web.html", true);
}
function Update_showTip(a) {
let d = document.getElementById("ex-update__tip");
if (d) {
if (a) {
if (d.style.display != "block") {
d.style.display = "block";
}
} else {
d.style.display = "none";
}
}
}
// 【版本更新】最新版本:2010.02.10.01,点击官方源或者greasyfork源更新
function Update_showMessage() {
let msg = `【版本更新】最新版本:${lastestVersion},点击
官方源 或者
GreasyFork源 更新`
showMessage(msg, "error");
}
let videoStartTime = 0;
let videoTime_domhook_videoChange = null;
let videoTime_domhook_showtime = null;
let videoTime_timeout = 0;
function initPkg_VideoTime() {
let timer = setInterval(() => {
VideoTime_setData();
let videoDom = document.getElementsByTagName("demand-video")[0].shadowRoot.getElementById("__video");
let showtimeDom = document.getElementsByTagName("demand-video")[0].shadowRoot.getElementById("demandcontroller-bar").shadowRoot.querySelector("demand-video-controller-progress").shadowRoot.querySelector("demand-video-controller-preview");
if (videoDom !== undefined && videoDom !== null) {
clearInterval(timer);
videoTime_domhook_videoChange = new MutationObserver(function(mutations) {
VideoTime_setData();
});
videoTime_domhook_videoChange.observe(videoDom, { attributes: true, childList: true, subtree: false });
videoTime_domhook_showtime = new MutationObserver(function(mutations) {
for (let i = 0; i < mutations.length; i++) {
let item = mutations[i];
if (item.attributeName == "showtime") {
// 此时修改时间
let showtime = Number(VideoTime_getShowTime());
VideoTime_setShowTime(String(dateFormat("yyyy-MM-dd hh:mm:ss", new Date(Number(videoStartTime + showtime * 1000)))) + "
" + formatSeconds2(showtime));
break;
} else if (item.attributeName == "isshow") {
clearTimeout(videoTime_timeout);
let showtime = Number(VideoTime_getShowTime());
// 宏任务 模拟nextTick
videoTime_timeout = setTimeout(() => {
VideoTime_setShowTime(String(dateFormat("yyyy-MM-dd hh:mm:ss", new Date(Number(videoStartTime + showtime * 1000)))) + "
" + formatSeconds2(showtime));
}, 0);
break;
}
}
});
videoTime_domhook_showtime.observe(showtimeDom, { attributes: true, childList: true, subtree: false });
}
}, 1000)
}
function VideoTime_setData() {
let pathnameArr = String(window.location.pathname).split("/");
let videoId = pathnameArr[pathnameArr.length - 1];
fetch("https://v.douyu.com/video/video/getVideoUrl?vid=" + videoId, {
method: 'GET',
mode: 'no-cors',
credentials: 'include',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
}).then(res => {
return res.json();
}).then(ret => {
let imgUrl = ret.data.viewthumb[0].url;
let timeStr = getStrMiddle(imgUrl, "--", "/");
videoStartTime = new Date(timeStr.replace(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/, "$1-$2-$3 $4:$5:$6")).getTime();
}).catch(err => {
console.log("请求失败!", err);
})
}
function VideoTime_getShowTime() {
let t = document.getElementsByTagName("demand-video")[0].shadowRoot.getElementById("demandcontroller-bar").shadowRoot.querySelector("demand-video-controller-progress").shadowRoot.querySelector("demand-video-controller-preview").getAttribute("showtime");
return Number(t).toFixed(0);
}
function VideoTime_setShowTime(timeStr) {
let dom = document.getElementsByTagName("demand-video")[0].shadowRoot.getElementById("demandcontroller-bar").shadowRoot.querySelector("demand-video-controller-progress").shadowRoot.querySelector("demand-video-controller-preview").shadowRoot.querySelector(".Preview-Time");
if (dom) {
dom.style.position = "relative";
dom.style.bottom = "60px"
dom.style.backgroundColor = "rgba(0,0,0,0.4)";
dom.innerHTML = timeStr;
}
}
var gifworkerStr = `(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
=ByteArray.pageSize)this.newPage();this.pages[this.page][this.cursor++]=val};ByteArray.prototype.writeUTFBytes=function(string){for(var l=string.length,i=0;i=0)this.dispose=disposalCode};GIFEncoder.prototype.setRepeat=function(repeat){this.repeat=repeat};GIFEncoder.prototype.setTransparent=function(color){this.transparent=color};GIFEncoder.prototype.addFrame=function(imageData){this.image=imageData;this.colorTab=this.globalPavarte&&this.globalPavarte.slice?this.globalPavarte:null;this.getImagePixels();this.analyzePixels();if(this.globalPavarte===true)this.globalPavarte=this.colorTab;if(this.firstFrame){this.writeLSD();this.writePavarte();if(this.repeat>=0){this.writeNetscapeExt()}}this.writeGraphicCtrlExt();this.writeImageDesc();if(!this.firstFrame&&!this.globalPavarte)this.writePavarte();this.writePixels();this.firstFrame=false};GIFEncoder.prototype.finish=function(){this.out.writeByte(59)};GIFEncoder.prototype.setQuality=function(quality){if(quality<1)quality=1;this.sample=quality};GIFEncoder.prototype.setDither=function(dither){if(dither===true)dither="FloydSteinberg";this.dither=dither};GIFEncoder.prototype.setGlobalPavarte=function(pavarte){this.globalPavarte=pavarte};GIFEncoder.prototype.getGlobalPavarte=function(){return this.globalPavarte&&this.globalPavarte.slice&&this.globalPavarte.slice(0)||this.globalPavarte};GIFEncoder.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")};GIFEncoder.prototype.analyzePixels=function(){if(!this.colorTab){this.neuQuant=new NeuQuant(this.pixels,this.sample);this.neuQuant.buildColormap();this.colorTab=this.neuQuant.getColormap()}if(this.dither){this.ditherPixels(this.dither.replace("-serpentine",""),this.dither.match(/-serpentine/)!==null)}else{this.indexPixels()}this.pixels=null;this.colorDepth=8;this.palSize=7;if(this.transparent!==null){this.transIndex=this.findClosest(this.transparent,true)}};GIFEncoder.prototype.indexPixels=function(imgq){var nPix=this.pixels.length/3;this.indexedPixels=new Uint8Array(nPix);var k=0;for(var j=0;j=0&&x1+x=0&&y1+y>16,(c&65280)>>8,c&255,used)};GIFEncoder.prototype.findClosestRGB=function(r,g,b,used){if(this.colorTab===null)return-1;if(this.neuQuant&&!used){return this.neuQuant.lookupRGB(r,g,b)}var c=b|g<<8|r<<16;var minpos=0;var dmin=256*256*256;var len=this.colorTab.length;for(var i=0,index=0;i=0){disp=dispose&7}disp<<=2;this.out.writeByte(0|disp|0|transp);this.writeShort(this.delay);this.out.writeByte(this.transIndex);this.out.writeByte(0)};GIFEncoder.prototype.writeImageDesc=function(){this.out.writeByte(44);this.writeShort(0);this.writeShort(0);this.writeShort(this.width);this.writeShort(this.height);if(this.firstFrame||this.globalPavarte){this.out.writeByte(0)}else{this.out.writeByte(128|0|0|0|this.palSize)}};GIFEncoder.prototype.writeLSD=function(){this.writeShort(this.width);this.writeShort(this.height);this.out.writeByte(128|112|0|this.palSize);this.out.writeByte(0);this.out.writeByte(0)};GIFEncoder.prototype.writeNetscapeExt=function(){this.out.writeByte(33);this.out.writeByte(255);this.out.writeByte(11);this.out.writeUTFBytes("NETSCAPE2.0");this.out.writeByte(3);this.out.writeByte(1);this.writeShort(this.repeat);this.out.writeByte(0)};GIFEncoder.prototype.writePavarte=function(){this.out.writeBytes(this.colorTab);var n=3*256-this.colorTab.length;for(var i=0;i>8&255)};GIFEncoder.prototype.writePixels=function(){var enc=new LZWEncoder(this.width,this.height,this.indexedPixels,this.colorDepth);enc.encode(this.out)};GIFEncoder.prototype.stream=function(){return this.out};module.exports=GIFEncoder},{"./LZWEncoder.js":2,"./TypedNeuQuant.js":3}],2:[function(require,module,exports){var EOF=-1;var BITS=12;var HSIZE=5003;var masks=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function LZWEncoder(width,height,pixels,colorDepth){var initCodeSize=Math.max(2,colorDepth);var accum=new Uint8Array(256);var htab=new Int32Array(HSIZE);var codetab=new Int32Array(HSIZE);var cur_accum,cur_bits=0;var a_count;var free_ent=0;var maxcode;var clear_flg=false;var g_init_bits,ClearCode,EOFCode;function char_out(c,outs){accum[a_count++]=c;if(a_count>=254)flush_char(outs)}function cl_block(outs){cl_hash(HSIZE);free_ent=ClearCode+2;clear_flg=true;output(ClearCode,outs)}function cl_hash(hsize){for(var i=0;i=0){disp=hsize_reg-i;if(i===0)disp=1;do{if((i-=disp)<0)i+=hsize_reg;if(htab[i]===fcode){ent=codetab[i];continue outer_loop}}while(htab[i]>=0)}output(ent,outs);ent=c;if(free_ent<1<0){outs.writeByte(a_count);outs.writeBytes(accum,0,a_count);a_count=0}}function MAXCODE(n_bits){return(1<0)cur_accum|=code<=8){char_out(cur_accum&255,outs);cur_accum>>=8;cur_bits-=8}if(free_ent>maxcode||clear_flg){if(clear_flg){maxcode=MAXCODE(n_bits=g_init_bits);clear_flg=false}else{++n_bits;if(n_bits==BITS)maxcode=1<0){char_out(cur_accum&255,outs);cur_accum>>=8;cur_bits-=8}flush_char(outs)}}this.encode=encode}module.exports=LZWEncoder},{}],3:[function(require,module,exports){var ncycles=100;var netsize=256;var maxnetpos=netsize-1;var netbiasshift=4;var intbiasshift=16;var intbias=1<>betashift;var betagamma=intbias<>3;var radiusbiasshift=6;var radiusbias=1<>3);var i,v;for(i=0;i>=netbiasshift;network[i][1]>>=netbiasshift;network[i][2]>>=netbiasshift;network[i][3]=i}}function altersingle(alpha,i,b,g,r){network[i][0]-=alpha*(network[i][0]-b)/initalpha;network[i][1]-=alpha*(network[i][1]-g)/initalpha;network[i][2]-=alpha*(network[i][2]-r)/initalpha}function alterneigh(radius,i,b,g,r){var lo=Math.abs(i-radius);var hi=Math.min(i+radius,netsize);var j=i+1;var k=i-1;var m=1;var p,a;while(jlo){a=radpower[m++];if(jlo){p=network[k--];p[0]-=a*(p[0]-b)/alpharadbias;p[1]-=a*(p[1]-g)/alpharadbias;p[2]-=a*(p[2]-r)/alpharadbias}}}function contest(b,g,r){var bestd=~(1<<31);var bestbiasd=bestd;var bestpos=-1;var bestbiaspos=bestpos;var i,n,dist,biasdist,betafreq;for(i=0;i>intbiasshift-netbiasshift);if(biasdist>betashift;freq[i]-=betafreq;bias[i]+=betafreq<>1;for(j=previouscol+1;j>1;for(j=previouscol+1;j<256;j++)netindex[j]=maxnetpos}function inxsearch(b,g,r){var a,p,dist;var bestd=1e3;var best=-1;var i=netindex[g];var j=i-1;while(i=0){if(i=bestd)i=netsize;else{i++;if(dist<0)dist=-dist;a=p[0]-b;if(a<0)a=-a;dist+=a;if(dist=0){p=network[j];dist=g-p[1];if(dist>=bestd)j=-1;else{j--;if(dist<0)dist=-dist;a=p[0]-b;if(a<0)a=-a;dist+=a;if(dist>radiusbiasshift;if(rad<=1)rad=0;for(i=0;i=lengthcount)pix-=lengthcount;i++;if(delta===0)delta=1;if(i%delta===0){alpha-=alpha/alphadec;radius-=radius/radiusdec;rad=radius>>radiusbiasshift;if(rad<=1)rad=0;for(j=0;j
`;
let b = document.getElementsByClassName("player-dialog")[0];
b.insertBefore(a, b.childNodes[0]);
}
function initPkg_VideoTools_Camera_Func() {
let dom = document.getElementsByClassName("layout-Player-video")[0];
let dom_video = document.getElementsByClassName("room-Player-Box")[0];
let camera = document.getElementById("ex-camera");
let gif = null;
let timer = 0;
let downTime = 0;
let imgBase64;
let timer_timeout = 0;
dom.addEventListener("mouseenter", () => {
camera.style.display = "flex";
timer_timeout = setTimeout(() => {
camera.style.display = "none";
}, 2000);
})
dom_video.addEventListener("mousemove", () => {
camera.style.display = "flex";
clearTimeout(timer_timeout);
timer_timeout = setTimeout(() => {
camera.style.display = "none";
}, 2000);
})
camera.addEventListener("mouseenter", () => {
camera.style.display = "flex";
clearTimeout(timer_timeout);
})
dom.addEventListener("mouseleave", () => {
camera.style.display = "none";
})
camera.addEventListener("mousedown", (e) => {
downTime = new Date().getTime();
camera_canvas_img.getContext('2d').drawImage(liveVideoNode, 0, 0, camera_canvas_img.width, camera_canvas_img.height);
imgBase64 = camera_canvas_img.toDataURL("image/png");
gif = new GIF({
workers: 5,
quality: 3,
width: camera_width,
height: camera_height,
workerScript: gifworkerBlob
});;
cameraAddFrame(liveVideoNode, camera_canvas, gif, camera_fps);
timer = setInterval(() => {cameraAddFrame(liveVideoNode, camera_canvas, gif, camera_fps)}, camera_fps);
})
camera.addEventListener("mouseup", (e) => {
let upTime = new Date().getTime();
clearInterval(timer);
if (upTime - downTime >= 800) {
showMessage("【录制】正在生成gif...", "info");
gif.on('finished', blob => {
let el = document.createElement('a');
el.href = URL.createObjectURL(blob);
el.download = `【${camera_anchorName}】${dateFormat("yyyy-MM-dd hh-mm-ss",new Date())}`;
document.body.appendChild(el);
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
el.dispatchEvent(evt);
document.body.removeChild(el);
});
gif.render();
} else {
let el = document.createElement("a");
el.download = `【${camera_anchorName}】${dateFormat("yyyy-MM-dd hh-mm-ss",new Date())}`;
el.href = imgBase64;
document.body.appendChild(el);
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
el.dispatchEvent(evt);
document.body.removeChild(el);
}
})
}
function initPkg_VideoTools_Camera_Video() {
let timer = setInterval(() => {
liveVideoNode = document.getElementsByTagName("demand-video")[0].shadowRoot.getElementById("__video");
if (liveVideoNode !== undefined && liveVideoNode !== null && liveVideoNode.videoWidth) {
clearInterval(timer);
camera_anchorName = document.getElementsByTagName("demand-video-anchor")[0].shadowRoot.querySelector(".anchor-name").innerText;
camera_width = liveVideoNode.videoWidth * 0.25;
camera_height = liveVideoNode.videoHeight * 0.25;
camera_canvas = document.createElement("canvas");
camera_canvas.width = camera_width;
camera_canvas.height = camera_height;
camera_canvas_img = document.createElement("canvas");
camera_canvas_img.width = liveVideoNode.videoWidth;
camera_canvas_img.height = liveVideoNode.videoHeight;
initPkg_VideoTools_Camera_Video_Dom();
initPkg_VideoTools_Camera_Video_Func();
}
}, 1000)
}
function initPkg_VideoTools_Camera_Video_Dom() {
Camera_Video_insertIcon();
}
function Camera_Video_insertIcon() {
let a = document.createElement("div");
a.id = "ex-camera";
a.title = "单击截图 长按录制gif"
a.innerHTML = `
`;
let b = document.getElementsByClassName("Video")[0];
b.insertBefore(a, b.childNodes[0]);
}
function initPkg_VideoTools_Camera_Video_Func() {
let dom = document.getElementsByTagName("demand-video")[0];
let camera = document.getElementById("ex-camera");
let gif = null;
let timer = 0;
let downTime = 0;
let imgBase64;
let timer_timeout = 0;
dom.addEventListener("mouseenter", () => {
camera.style.display = "flex";
timer_timeout = setTimeout(() => {
camera.style.display = "none";
}, 2000);
})
dom.addEventListener("mousemove", () => {
camera.style.display = "flex";
clearTimeout(timer_timeout);
timer_timeout = setTimeout(() => {
camera.style.display = "none";
}, 2000);
})
camera.addEventListener("mouseenter", () => {
camera.style.display = "flex";
clearTimeout(timer_timeout);
})
dom.addEventListener("mouseleave", () => {
camera.style.display = "none";
})
camera.addEventListener("mousedown", (e) => {
downTime = new Date().getTime();
camera_canvas_img.getContext('2d').drawImage(liveVideoNode, 0, 0, camera_canvas_img.width, camera_canvas_img.height);
imgBase64 = camera_canvas_img.toDataURL("image/png");
gif = new GIF({
workers: 5,
quality: 3,
width: camera_width,
height: camera_height,
workerScript: gifworkerBlob
});;
cameraAddFrame(liveVideoNode, camera_canvas, gif, camera_fps);
timer = setInterval(() => {
cameraAddFrame(liveVideoNode, camera_canvas, gif, camera_fps)
}, camera_fps);
})
camera.addEventListener("mouseup", (e) => {
let upTime = new Date().getTime();
clearInterval(timer);
if (upTime - downTime >= 800) {
showMessage("【录制】正在生成gif...", "info");
gif.on('finished', blob => {
let el = document.createElement('a');
el.href = URL.createObjectURL(blob);
el.download = `【${camera_anchorName}】${dateFormat("yyyy-MM-dd hh-mm-ss",new Date())}`;
document.body.appendChild(el);
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
el.dispatchEvent(evt);
document.body.removeChild(el);
});
gif.render();
} else {
let el = document.createElement("a");
el.download = `【${camera_anchorName}】${dateFormat("yyyy-MM-dd hh-mm-ss",new Date())}`;
el.href = imgBase64;
document.body.appendChild(el);
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
el.dispatchEvent(evt);
document.body.removeChild(el);
}
})
}
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 = `
滤镜
无
1977
Aden
Amaro
Brannan
Brooklyn
Claredon
Earlybird
Gingham
Hudson
Inkwell
Lofi
Maven
Perpetua
Reyes
Stinson
Toaster
Walden
Valencia
Xpro2
`;
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();
initPkg_VideoTools_Camera();
}
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 doSign(alias) {
return new Promise(resolve => {
fetch('https://www.douyu.com/japi/carnival/nc/hostSnowSign/doSign',{
method: 'POST',
mode: 'no-cors',
credentials: 'include',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: `actAlias=${alias}&token=${dyToken}&ctn=${getCCN()}`
}).then(res => {
return res.json();
}).then(ret => {
resolve(ret);
}).catch(err => {
console.log("请求失败!", err);
})
})
}
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.content+" "+"
"+'"+" "+"";return temp},getConfirmTemplate:function(){return'