diff --git a/packages/unblock-area-limit/src/feature/bili/area_limit_fetch.ts b/packages/unblock-area-limit/src/feature/bili/area_limit_fetch.ts index 6cb9102f..09e2da39 100644 --- a/packages/unblock-area-limit/src/feature/bili/area_limit_fetch.ts +++ b/packages/unblock-area-limit/src/feature/bili/area_limit_fetch.ts @@ -3,17 +3,28 @@ import { Async } from "../../util/async" import { log, util_debug } from "../../util/log" import { RegExps } from "../../util/regexps" import { Strings } from "../../util/strings" - +import space_account_info_map from "./space_account_info_map" +export const spaceAccountInfoMap: Record & typeof space_account_info_map = space_account_info_map export function injectFetch() { - // 当前未替换任何内容... const originFetch = window.fetch; - window.fetch = function (input: RequestInfo | URL, init?: RequestInit): Promise { - log('fetch', input, init) - return originFetch(input, init) - .then(r => { - // log('then', r) - return r - }) + window.fetch = async function (input: RequestInfo | URL, init?: RequestInit): Promise { + const originResponse = await originFetch(input, init) + switch (typeof input) { + case 'string': { + if (input.match(RegExps.url('api.bilibili.com/x/space/wbi/acc/info?'))) { + let json = await originResponse.json() + if (json.code === -404) { + const mid = new URL(input, document.location.href).searchParams.get('mid') + if (mid && spaceAccountInfoMap[mid || '']) { + return new Response(JSON.stringify(spaceAccountInfoMap[mid])) + } + } + return new Response(JSON.stringify(json)) + } + break + } + } + return originResponse } } export function injectFetch4Mobile() { diff --git a/packages/unblock-area-limit/src/feature/bili/space_account_info_map.ts b/packages/unblock-area-limit/src/feature/bili/space_account_info_map.ts index ac2344a7..6a741b80 100644 --- a/packages/unblock-area-limit/src/feature/bili/space_account_info_map.ts +++ b/packages/unblock-area-limit/src/feature/bili/space_account_info_map.ts @@ -1,5 +1,5 @@ export default { - "11783021": { "code": 0, "message": "0", "ttl": 1, "data": { "mid": 11783021, "name": "哔哩哔哩番剧出差", "sex": "保密", "face": "http://i0.hdslb.com/bfs/face/9f10323503739e676857f06f5e4f5eb323e9f3f2.jpg", "sign": "", "rank": 10000, "level": 6, "jointime": 0, "moral": 0, "silence": 0, "coins": 0, "fans_badge": false, "fans_medal": { "show": false, "wear": false, "medal": null }, "official": { "role": 3, "title": "哔哩哔哩番剧出差 官方账号", "desc": "", "type": 1 }, "vip": { "type": 0, "status": 0, "due_date": 0, "vip_pay_type": 0, "theme_type": 0, "label": { "path": "", "text": "", "label_theme": "", "text_color": "", "bg_style": 0, "bg_color": "", "border_color": "" }, "avatar_subscript": 0, "nickname_color": "", "role": 0, "avatar_subscript_url": "" }, "pendant": { "pid": 0, "name": "", "image": "", "expire": 0, "image_enhance": "", "image_enhance_frame": "" }, "nameplate": { "nid": 0, "name": "", "image": "", "image_small": "", "level": "", "condition": "" }, "user_honour_info": { "mid": 0, "colour": null, "tags": [] }, "is_followed": true, "top_photo": "http://i2.hdslb.com/bfs/space/cb1c3ef50e22b6096fde67febe863494caefebad.png", "theme": {}, "sys_notice": {}, "live_room": { "roomStatus": 1, "liveStatus": 0, "url": "https://live.bilibili.com/931774", "title": "「梦之祭!部」 社团活动最终回", "cover": "http://i0.hdslb.com/bfs/live/c89c499096fa6527765de1fcaa021c9e2db7fbf8.jpg", "online": 0, "roomid": 931774, "roundStatus": 0, "broadcast_type": 0 }, "birthday": "", "school": { "name": "" }, "profession": { "name": "" }, "tags": null, "series": { "user_upgrade_status": 3, "show_upgrade_window": false } } }, - "1988098633": { "code": 0, "message": "0", "ttl": 1, "data": { "mid": 1988098633, "name": "b站_戲劇咖", "sex": "保密", "face": "http://i0.hdslb.com/bfs/face/member/noface.jpg", "sign": "提供bilibili港澳台地區專屬戲劇節目。", "rank": 10000, "level": 2, "jointime": 0, "moral": 0, "silence": 0, "coins": 0, "fans_badge": false, "fans_medal": { "show": false, "wear": false, "medal": null }, "official": { "role": 0, "title": "", "desc": "", "type": -1 }, "vip": { "type": 0, "status": 0, "due_date": 0, "vip_pay_type": 0, "theme_type": 0, "label": { "path": "", "text": "", "label_theme": "", "text_color": "", "bg_style": 0, "bg_color": "", "border_color": "" }, "avatar_subscript": 0, "nickname_color": "", "role": 0, "avatar_subscript_url": "" }, "pendant": { "pid": 0, "name": "", "image": "", "expire": 0, "image_enhance": "", "image_enhance_frame": "" }, "nameplate": { "nid": 0, "name": "", "image": "", "image_small": "", "level": "", "condition": "" }, "user_honour_info": { "mid": 0, "colour": null, "tags": [] }, "is_followed": true, "top_photo": "http://i0.hdslb.com/bfs/space/cb1c3ef50e22b6096fde67febe863494caefebad.png", "theme": {}, "sys_notice": {}, "live_room": { "roomStatus": 0, "liveStatus": 0, "url": "", "title": "", "cover": "", "online": 0, "roomid": 0, "roundStatus": 0, "broadcast_type": 0 }, "birthday": "01-01", "school": { "name": "" }, "profession": { "name": "" }, "tags": null, "series": { "user_upgrade_status": 3, "show_upgrade_window": false } } }, - "2042149112": { "code": 0, "message": "0", "ttl": 1, "data": { "mid": 2042149112, "name": "b站_綜藝咖", "sex": "保密", "face": "http://i0.hdslb.com/bfs/face/member/noface.jpg", "sign": "提供bilibili港澳台地區專屬綜藝節目。", "rank": 10000, "level": 3, "jointime": 0, "moral": 0, "silence": 0, "coins": 0, "fans_badge": false, "fans_medal": { "show": false, "wear": false, "medal": null }, "official": { "role": 0, "title": "", "desc": "", "type": -1 }, "vip": { "type": 0, "status": 0, "due_date": 0, "vip_pay_type": 0, "theme_type": 0, "label": { "path": "", "text": "", "label_theme": "", "text_color": "", "bg_style": 0, "bg_color": "", "border_color": "" }, "avatar_subscript": 0, "nickname_color": "", "role": 0, "avatar_subscript_url": "" }, "pendant": { "pid": 0, "name": "", "image": "", "expire": 0, "image_enhance": "", "image_enhance_frame": "" }, "nameplate": { "nid": 0, "name": "", "image": "", "image_small": "", "level": "", "condition": "" }, "user_honour_info": { "mid": 0, "colour": null, "tags": [] }, "is_followed": true, "top_photo": "http://i0.hdslb.com/bfs/space/cb1c3ef50e22b6096fde67febe863494caefebad.png", "theme": {}, "sys_notice": {}, "live_room": { "roomStatus": 0, "liveStatus": 0, "url": "", "title": "", "cover": "", "online": 0, "roomid": 0, "roundStatus": 0, "broadcast_type": 0 }, "birthday": "", "school": { "name": "" }, "profession": { "name": "" }, "tags": null, "series": { "user_upgrade_status": 3, "show_upgrade_window": false } } }, + "11783021": { "code": 0, "message": "0", "ttl": 1, "data": { "mid": 11783021, "name": "哔哩哔哩番剧出差", "sex": "保密", "face": "http://i2.hdslb.com/bfs/face/9f10323503739e676857f06f5e4f5eb323e9f3f2.jpg", "face_nft": 0, "face_nft_type": 0, "sign": "", "rank": 10000, "level": 6, "jointime": 0, "moral": 0, "silence": 0, "coins": 0, "fans_badge": false, "fans_medal": { "show": false, "wear": false, "medal": null }, "official": { "role": 3, "title": "哔哩哔哩番剧出差 官方账号", "desc": "", "type": 1 }, "vip": { "type": 0, "status": 0, "due_date": 0, "vip_pay_type": 0, "theme_type": 0, "label": { "path": "", "text": "", "label_theme": "", "text_color": "", "bg_style": 0, "bg_color": "", "border_color": "", "use_img_label": true, "img_label_uri_hans": "", "img_label_uri_hant": "", "img_label_uri_hans_static": "https://i0.hdslb.com/bfs/vip/d7b702ef65a976b20ed854cbd04cb9e27341bb79.png", "img_label_uri_hant_static": "https://i0.hdslb.com/bfs/activity-plat/static/20220614/e369244d0b14644f5e1a06431e22a4d5/KJunwh19T5.png" }, "avatar_subscript": 0, "nickname_color": "", "role": 0, "avatar_subscript_url": "", "tv_vip_status": 0, "tv_vip_pay_type": 0, "tv_due_date": 0 }, "pendant": { "pid": 0, "name": "", "image": "", "expire": 0, "image_enhance": "", "image_enhance_frame": "", "n_pid": 0 }, "nameplate": { "nid": 0, "name": "", "image": "", "image_small": "", "level": "", "condition": "" }, "user_honour_info": { "mid": 0, "colour": null, "tags": [], "is_latest_100honour": 0 }, "top_photo": "http://i1.hdslb.com/bfs/space/cb1c3ef50e22b6096fde67febe863494caefebad.png", "theme": {}, "sys_notice": {}, "live_room": { "roomStatus": 1, "liveStatus": 0, "url": "https://live.bilibili.com/931774?broadcast_type=0\u0026is_room_feed=0", "title": "", "cover": "", "roomid": 931774, "roundStatus": 0, "broadcast_type": 0 }, "birthday": "", "school": { "name": "" }, "profession": { "name": "", "department": "", "title": "", "is_show": 0 }, "tags": null, "series": { "user_upgrade_status": 3, "show_upgrade_window": false }, "is_senior_member": 0, "mcn_info": null, "gaia_res_type": 0, "gaia_data": null, "is_risk": false, "elec": { "show_info": { "show": false, "state": -1, "title": "", "icon": "", "jump_url": "?oid=11783021" } }, "contract": { "is_display": false, "is_follow_display": false }, "certificate_show": false } }, + "1988098633": { "code": 0, "message": "0", "ttl": 1, "data": { "mid": 1988098633, "name": "b站_戲劇咖", "sex": "保密", "face": "https://i1.hdslb.com/bfs/face/9718fb1aa9fa37d62749506f677c8f2f5804c725.jpg", "face_nft": 0, "face_nft_type": 0, "sign": "提供bilibili港澳台地區專屬戲劇節目。", "rank": 10000, "level": 6, "jointime": 0, "moral": 0, "silence": 0, "coins": 0, "fans_badge": false, "fans_medal": { "show": false, "wear": false, "medal": null }, "official": { "role": 0, "title": "", "desc": "", "type": -1 }, "vip": { "type": 0, "status": 0, "due_date": 0, "vip_pay_type": 0, "theme_type": 0, "label": { "path": "", "text": "", "label_theme": "", "text_color": "", "bg_style": 0, "bg_color": "", "border_color": "", "use_img_label": true, "img_label_uri_hans": "", "img_label_uri_hant": "", "img_label_uri_hans_static": "https://i0.hdslb.com/bfs/vip/d7b702ef65a976b20ed854cbd04cb9e27341bb79.png", "img_label_uri_hant_static": "https://i0.hdslb.com/bfs/activity-plat/static/20220614/e369244d0b14644f5e1a06431e22a4d5/KJunwh19T5.png" }, "avatar_subscript": 0, "nickname_color": "", "role": 0, "avatar_subscript_url": "", "tv_vip_status": 0, "tv_vip_pay_type": 0, "tv_due_date": 0 }, "pendant": { "pid": 0, "name": "", "image": "", "expire": 0, "image_enhance": "", "image_enhance_frame": "", "n_pid": 0 }, "nameplate": { "nid": 0, "name": "", "image": "", "image_small": "", "level": "", "condition": "" }, "user_honour_info": { "mid": 0, "colour": null, "tags": [], "is_latest_100honour": 0 }, "top_photo": "http://i1.hdslb.com/bfs/space/cb1c3ef50e22b6096fde67febe863494caefebad.png", "theme": {}, "sys_notice": {}, "live_room": null, "birthday": "01-01", "school": { "name": "" }, "profession": { "name": "", "department": "", "title": "", "is_show": 0 }, "tags": null, "series": { "user_upgrade_status": 3, "show_upgrade_window": false }, "is_senior_member": 0, "mcn_info": null, "gaia_res_type": 0, "gaia_data": null, "is_risk": false, "elec": { "show_info": { "show": false, "state": -1, "title": "", "icon": "", "jump_url": "?oid=1988098633" } }, "contract": { "is_display": false, "is_follow_display": false }, "certificate_show": false } }, + "2042149112": { "code": 0, "message": "0", "ttl": 1, "data": { "mid": 2042149112, "name": "b站_綜藝咖", "sex": "保密", "face": "https://i0.hdslb.com/bfs/face/member/noface.jpg", "face_nft": 0, "face_nft_type": 0, "sign": "", "rank": 10000, "level": 6, "jointime": 0, "moral": 0, "silence": 0, "coins": 0, "fans_badge": false, "fans_medal": { "show": false, "wear": false, "medal": null }, "official": { "role": 0, "title": "", "desc": "", "type": -1 }, "vip": { "type": 0, "status": 0, "due_date": 0, "vip_pay_type": 0, "theme_type": 0, "label": { "path": "", "text": "", "label_theme": "", "text_color": "", "bg_style": 0, "bg_color": "", "border_color": "", "use_img_label": true, "img_label_uri_hans": "", "img_label_uri_hant": "", "img_label_uri_hans_static": "https://i0.hdslb.com/bfs/vip/d7b702ef65a976b20ed854cbd04cb9e27341bb79.png", "img_label_uri_hant_static": "https://i0.hdslb.com/bfs/activity-plat/static/20220614/e369244d0b14644f5e1a06431e22a4d5/KJunwh19T5.png" }, "avatar_subscript": 0, "nickname_color": "", "role": 0, "avatar_subscript_url": "", "tv_vip_status": 0, "tv_vip_pay_type": 0, "tv_due_date": 0 }, "pendant": { "pid": 0, "name": "", "image": "", "expire": 0, "image_enhance": "", "image_enhance_frame": "", "n_pid": 0 }, "nameplate": { "nid": 0, "name": "", "image": "", "image_small": "", "level": "", "condition": "" }, "user_honour_info": { "mid": 0, "colour": null, "tags": [], "is_latest_100honour": 0 }, "top_photo": "http://i1.hdslb.com/bfs/space/cb1c3ef50e22b6096fde67febe863494caefebad.png", "theme": {}, "sys_notice": {}, "live_room": null, "birthday": "", "school": { "name": "" }, "profession": { "name": "", "department": "", "title": "", "is_show": 0 }, "tags": null, "series": { "user_upgrade_status": 3, "show_upgrade_window": false }, "is_senior_member": 0, "mcn_info": null, "gaia_res_type": 0, "gaia_data": null, "is_risk": false, "elec": { "show_info": { "show": false, "state": -1, "title": "", "icon": "", "jump_url": "?oid=2042149112" } }, "contract": { "is_display": false, "is_follow_display": false }, "certificate_show": false } }, } \ No newline at end of file