Skip to content

Commit

Permalink
perf(webview): prefer hevc codec for bilibili
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenlx committed Apr 9, 2024
1 parent 5890c31 commit 7c67ee7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 19 additions & 0 deletions apps/app/src/web/bili-req/scripts/userscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,23 @@ const intercepter = new XHRIntercepter((url) =>
intercepter.load();
(window as any)[storeId] = intercepter;

const enum Codec {
default = 0,
hevc = 1,
avc = 2,
av1 = 3,
}

localStorage.setItem("recommend_auto_play", "close");
// disable autoplay
localStorage.setItem(
"bpx_player_profile",
JSON.stringify({ media: { autoplay: false } }),
);
// default to hevc
localStorage.setItem(
"bilibili_player_codec_prefer_type",
JSON.stringify(Codec.hevc),
);

console.log("intercepter loaded");
6 changes: 0 additions & 6 deletions apps/app/src/web/userscript/bilibili.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ export default class BilibiliPlugin extends MediaPlugin {
}),
);

localStorage.setItem("recommend_auto_play", "close");
// disable autoplay
localStorage.setItem(
"bpx_player_profile",
JSON.stringify({ media: { autoplay: false } }),
);
await super.onload();
this.revertAutoSeek();
Promise.all([this.toggleDanmaku(false)]);
Expand Down

0 comments on commit 7c67ee7

Please sign in to comment.