Skip to content

Commit

Permalink
fix: 播放东南亚视频后其它地区视频不能播放
Browse files Browse the repository at this point in the history
播放东南亚视频后其它地区视频不能播放
Refs: #23
  • Loading branch information
msojocs committed Jun 6, 2022
1 parent 241fe6a commit 69340ce
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Prepare
run: |
sudo apt install wget
sudo apt install wget exiftool
sudo npm install asar -g
echo "$UID, $GID"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- feat: 弹幕支持添加港澳台
- update: 子版本更新 494 -> 542
- fix: 播放东南亚视频后其它地区视频不能播放

# v1.1.3-3 / 2022-06-03

Expand Down
16 changes: 11 additions & 5 deletions extensions/area_unlimit/hook/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ const AREA_MARK_CACHE = {}
// HOOK
const URL_HOOK = {
"https://api.bilibili.com/pgc/view/pc/season": async (req)=>{
UTILS.enableReferer();
console.log('HOOK', req)
const resp = JSON.parse(req.responseText || "{}")
if(resp.code !== 0){
Expand Down Expand Up @@ -223,10 +224,8 @@ const URL_HOOK = {
* 东南亚:替换 - 不要referer
*/
if(AREA_MARK_CACHE[params.ep_id] === 'th'){
console.log('remove referer')
UTILS.disableReferer()
}else{
console.log('add referer')
UTILS.enableReferer()
}
const api = new BiliBiliApi()
Expand All @@ -252,6 +251,7 @@ const URL_HOOK = {

let playURL
if(area !== "th"){
UTILS.enableReferer()
playURL = await api.getPlayURL(req, sessionStorage.access_key || "", area)
}else{
UTILS.disableReferer()
Expand Down Expand Up @@ -509,15 +509,21 @@ function __awaiter(thisArg, _arguments, P, generator) {
}
const UTILS = {
enableReferer(){
document.getElementById('refererMark') && document.getElementById('refererMark').remove()
const referrerEle = document.getElementById('referrerMark')
if(!referrerEle)return;

referrerEle.content = "strict-origin-when-cross-origin"
},
disableReferer(){
if(!document.getElementById('refererMark')){
const referrerEle = document.getElementById('referrerMark');
if(!referrerEle){
let meta = document.createElement('meta')
meta.id = "refererMark"
meta.id = "referrerMark"
meta.name = "referrer"
meta.content = "no-referrer"
document.head.appendChild(meta);
}else{
referrerEle.content = "no-referrer"
}
},
replaceUpos(playURL, host, replaceAkamai = false, area=""){
Expand Down
2 changes: 1 addition & 1 deletion tools/update-bilibili
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fi
tmp_dir="$root_dir/tmp"
mkdir -p "$tmp_dir/bili"

# notice "一次版本校验"
notice "一次版本校验"
BILIBILI_VERSION=$(exiftool -S -ProductVersionNumber "$root_dir/cache/bili_win-install.exe")
BILIBILI_VERSION=(${BILIBILI_VERSION//: / })
BILIBILI_VERSION=${BILIBILI_VERSION[1]}
Expand Down

0 comments on commit 69340ce

Please sign in to comment.