Use document.contentType to detect json page

This commit is contained in:
the1812 2020-05-18 17:07:32 +08:00
parent f5f6e2b821
commit f6891f1732
10 changed files with 13062 additions and 13074 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,7 +34,7 @@
"custom-control-background.min.js": "B9F366B251D1572ACE801FF6ECF15D4D1AAB3EA5A5B04B961B6F4310E2AB1A84",
"custom-navbar.min.css": "9A928621375DCBCB93199AEA82E1A5EA58C2C0D25BF36BC26620F0CC91E227ED",
"custom-navbar.min.html": "269CEAA9877456B824BC17D4FA4FC62CBFE767EF14715DD0E75443185DFD032C",
"custom-navbar.min.js": "A6BBE470458D19CD25EED872A5DF218F28DFEBBBEF3024989D7BE867E7DCB019",
"custom-navbar.min.js": "423E84D6EC116512C8059E924F82EDC94E95B5F27DDD48AA508800F1E76666AE",
"custom-navbar-activities.min.js": "802226FE2C24D56379A6EAD13D3697A4D5A46109D0C63EDACAE8E667ED267EA1",
"custom-navbar-blank.min.js": "DC2B75D5760EECD3A257785FDFBB7E5DEBF61CD9083C68DD5BCE468B093F54F3",
"custom-navbar-category.min.js": "CBD31D61E11985A03CC690BFB65082543AF63817D74398555786927445EB19D5",
@ -221,7 +221,7 @@
"trending-videos.min.js": "1ED73F10D5A7C409CCBF91A97FBB0DE2AA16426F2216DF75F904E8A6389A46E9",
"trending-videos.vue.min.js": "24E8616129DDEC7D014B1836DB6E54A5AF35578D1F4586EE827A962312EA7049",
"tweets.min.css": "9015C1F165C91B9205ABBE4E8A3B5FA83DB1EB4B5CF2442846AF61E44FF178A8",
"url-params-clean.min.js": "6BC9CB2A5732FDADE8D4D21FA269DA9B574E6BAF34D7F0FF7F221E24A6D7AE78",
"url-params-clean.min.js": "50D1D3D84CCCD475EF69F81955A529B1DD9F4BB2EF0E25ADD523EAFA59F0E643",
"v-checkbox.vue.min.js": "A23C35D5627009A29FD396A024442A19E37DEE70674BF3CE0FA377D781ED2231",
"v-dropdown.vue.min.js": "BA1142E2D44CC9593DA803CAA76FA2B814CBD65D4D4210ABF00E811C361D8A37",
"video-card.vue.min.js": "E67A429519E70AB872B0EF8DB9B5A6992F0C474E98AAEC12468F41C982ABD9C5",

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(()=>{return(t,e)=>{const r=["spm_id_from","from_source","from_spmid","from","seid","share_source","share_medium","share_plat","share_tag","bbid","ts","timestamp","unique_k","rt","tdsourcetag","accept_quality","broadcast_type","current_qn","current_quality","playurl_h264","playurl_h265","quality_description","network","network_status","platform_network_status"];const s=[/game\.bilibili\.com\/fgo/];const o=t=>{return t};const a=()=>{const t=location.search.substring(1).split("&");const e=t.filter(t=>{if(r.some(e=>t.startsWith(`${e}=`))){return false}return true});const s=e.join("&");const a=o(document.URL.replace(location.search,""));const n=s?"?"+s:"";const c=a+n;if(c!==document.URL){console.log("[URL params clean]",document.URL,c);history.replaceState({},document.title,c)}};let n=false;try{JSON.parse(document.body.innerText);n=true}catch(t){n=false}fullyLoaded(()=>{if(!n){a();Observer.videoChange(()=>a())}})}})();
(()=>{return(t,e)=>{const r=["spm_id_from","from_source","from_spmid","from","seid","share_source","share_medium","share_plat","share_tag","bbid","ts","timestamp","unique_k","rt","tdsourcetag","accept_quality","broadcast_type","current_qn","current_quality","playurl_h264","playurl_h265","quality_description","network","network_status","platform_network_status"];const o=[/game\.bilibili\.com\/fgo/];const s=t=>{return t};const n=()=>{const t=location.search.substring(1).split("&");const e=t.filter(t=>{if(r.some(e=>t.startsWith(`${e}=`))){return false}return true});const o=e.join("&");const n=s(document.URL.replace(location.search,""));const a=o?"?"+o:"";const c=n+a;if(c!==document.URL){console.log("[URL params clean]",document.URL,c);history.replaceState({},document.title,c)}};fullyLoaded(()=>{if(document.contentType==="text/html"){n();Observer.videoChange(()=>n())}})}})();

View File

@ -37,18 +37,10 @@ const darkHandler = (force: boolean) => {
(dq('.custom-navbar') as HTMLElement).classList.toggle('dark', force);
(dq('.custom-navbar-settings') as HTMLElement).classList.toggle('dark', force)
}
const isJSON = () => {
try {
JSON.parse(document.body.innerText);
return true
} catch (error) {
return false
}
}
export default (() => {
const url = document.URL.replace(location.search, '')
const isHome = url === 'https://www.bilibili.com/' || url === 'https://www.bilibili.com/index.html'
if (isIframe() || (settings.bilibiliSimpleNewHomeCompatible && isHome) || isJSON()) {
if (isIframe() || (settings.bilibiliSimpleNewHomeCompatible && isHome) || document.contentType !== 'text/html') {
resources.removeStyle('customNavbarStyle')
return
}

View File

@ -51,16 +51,8 @@ const clean = () => {
}
// }
}
let isJSON = false;
try {
JSON.parse(document.body.innerText);
isJSON = true
} catch (error) {
isJSON = false
}
fullyLoaded(() => {
if (!isJSON) {
if (document.contentType === 'text/html') {
clean()
Observer.videoChange(() => clean())
}