Skip to content

Commit e3f1587

Browse files
committed
1 parent 29a9975 commit e3f1587

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

src/bilitwin.entry.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class BiliTwin extends BiliUserJS {
135135
static async init() {
136136
if (!document.body) return;
137137

138-
if (location.href.includes("www.biligame.com")) {
138+
if (location.hostname == "www.biligame.com") {
139139
return BiliPolyfill.biligameInit();
140140
}
141141
else if (location.pathname.startsWith("/bangumi/media/md")) {
@@ -147,6 +147,11 @@ class BiliTwin extends BiliUserJS {
147147

148148
const twin = new BiliTwin();
149149

150+
if (location.hostname == "vc.bilibili.com") {
151+
const vc_info = await BiliMonkey.getBiliShortVideoInfo()
152+
return twin.ui.appendShortVideoTitle(vc_info);
153+
}
154+
150155
while (1) {
151156
await twin.runCidSession();
152157
}

src/bilitwin.meta.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// @match *://www.bilibili.com/bangumi/play/ss*
1111
// @match *://www.bilibili.com/bangumi/media/md*
1212
// @match *://www.biligame.com/detail/*
13+
// @match *://vc.bilibili.com/video/*
1314
// @match *://www.bilibili.com/watchlater/
1415
// @version 1.18.4
1516
// @author qli5

src/biliuserjs/bilimonkey.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,17 @@ class BiliMonkey {
505505
return ret;
506506
}
507507

508+
static async getBiliShortVideoInfo() {
509+
const video_id = location.pathname.match(/\/video\/(\d+)/)[1]
510+
const api_url = `https://api.vc.bilibili.com/clip/v1/video/detail?video_id=${video_id}&need_playurl=1`
511+
512+
const req = await fetch(api_url, { credentials: 'include' })
513+
const data = (await req.json()).data
514+
const { video_playurl, first_pic: cover_img } = data.item
515+
516+
return { video_playurl, cover_img }
517+
}
518+
508519
static formatToValue(format) {
509520
if (format == 'does_not_exist') throw `formatToValue: cannot lookup does_not_exist`;
510521
if (typeof BiliMonkey.formatToValue.dict == 'undefined') BiliMonkey.formatToValue.dict = {

src/biliuserjs/biliuserjs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class BiliUserJS {
5656
throw 'Need H5 Player';
5757
}
5858
else if (!(document.getElementById('bofqi') instanceof Node) && document.querySelector("video")) {
59-
location.href = location.href // 刷新
59+
top.location.reload() // 刷新
6060
}
6161
else {
6262
return new Promise(resolve => {

src/ui/ui.entry.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ class UI {
161161
return div;
162162
}
163163

164+
appendShortVideoTitle({ video_playurl, cover_img }) {
165+
const fontSize = '15px';
166+
const marginRight = '15px';
167+
const videoA = <a style={{ fontSize, marginRight }} href={video_playurl} target="_blank">下载视频</a>;
168+
const coverA = <a style={{ fontSize }} href={cover_img} target="_blank">获取封面</a>;
169+
170+
const span = <span
171+
onClick={e => e.stopPropagation()}
172+
className="bilitwin"
173+
>{...[videoA, ' ', coverA]}</span>;
174+
175+
const infoDiv = document.querySelector('div.base-info div.info');
176+
infoDiv.appendChild(span);
177+
}
178+
164179
buildFLVDiv(monkey = this.twin.monkey, flvs = monkey.flvs, cache = monkey.cache, format = monkey.video_format) {
165180
// 1. build video splits
166181
const flvTrs = flvs.map((href, index) => {

0 commit comments

Comments
 (0)