-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
398564d
commit 79f3215
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.room-vip { | ||
-moz-user-select:none;/*火狐*/ | ||
-webkit-user-select:none;/*webkit浏览器*/ | ||
-ms-user-select:none;/*IE10*/ | ||
-khtml-user-select:none;/*早期浏览器*/ | ||
user-select:none; | ||
vertical-align: middle; | ||
float: left; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const roomVipExpireDayLimit = 3; | ||
function initPkg_RoomVip() { | ||
setRoomVipExpireDays(); | ||
} | ||
|
||
function initPkg_RoomVip_Dom() { | ||
let a = document.createElement("span"); | ||
a.className = "room-vip"; | ||
a.innerHTML = ` | ||
距VIP到期 <span id="room-vip-expire-days">**</span> 天 | ||
`; | ||
let b = document.getElementsByClassName("PlayerToolbar-Wealth")[0]; | ||
b.insertBefore(a, b.childNodes[0]); | ||
} | ||
|
||
function setRoomVipExpireDays() { | ||
fetch("https://www.douyu.com/member/platform_task/effect_list", { | ||
method: "GET", | ||
mode: "no-cors", | ||
cache: "default", | ||
credentials: "include" | ||
}) | ||
.then((res) => { | ||
return res.text(); | ||
}) | ||
.then(async (doc) => { | ||
doc = new DOMParser().parseFromString(doc, "text/html"); | ||
const enterEffectDom = doc.getElementsByClassName("enter-wraper is-effect"); | ||
if (!enterEffectDom) return; | ||
if (enterEffectDom.length == 0) return; | ||
const showEffectMoreDom = enterEffectDom[0].getElementsByClassName("show-effect-more"); | ||
if (!showEffectMoreDom) return; | ||
if (showEffectMoreDom.length == 0) return; | ||
for (let i = 0; i < showEffectMoreDom.length; i++) { | ||
const detail = JSON.parse(showEffectMoreDom[i].getAttribute("data-detail")); | ||
if (String(detail.show_id_list) !== String(rid)) continue; | ||
const expireTime = detail.expire_time * 1000; | ||
const days = Math.floor((expireTime - Date.now()) / (1000 * 60 * 60 * 24)); | ||
initPkg_RoomVip_Dom(); | ||
document.getElementById("room-vip-expire-days").innerText = days; | ||
} | ||
}) | ||
.catch((err) => { | ||
console.log("请求失败!", err); | ||
}); | ||
} |