虎牙网页Cookie来源驱动合并与WSS传输门禁

This commit is contained in:
yml2213
2026-09-01 19:17:32 +08:00
parent 8e3c0e69bc
commit 48c37bb8d7
16 changed files with 840 additions and 57 deletions
+16 -2
View File
@@ -85,7 +85,10 @@ function makeEnv(overrides) {
addEventListener(){}, removeEventListener(){}, setAttribute(){}, getBoundingClientRect(){return {left:0,top:0,width:300,height:150}},
style:{}, width:300, height:150,
};
W.document = {
// hydevice writes browser device state through document.cookie. Keep a small
// in-memory jar so Node has the same read/append semantics as a WebView.
const cookieJar = {};
const document = {
createElement(tag){ const el = Object.assign({}, canvasProto, {tagName:String(tag||'div').toUpperCase(), style:{}, children:[],
setAttribute(){}, getAttribute(){return null}, appendChild(c){this.children.push(c)}, removeChild(){}, addEventListener(){}, removeEventListener(){},
classList:{add(){},remove(){},contains(){return false}}, attachShadow(){return {appendChild(){}}}, getBoundingClientRect(){return {left:0,top:0,right:100,bottom:30,width:100,height:30}} });
@@ -97,9 +100,20 @@ function makeEnv(overrides) {
getElementsByTagName(t){ if(String(t).toLowerCase()==='head') return [this.head]; return []; },
documentElement:{setAttribute(){}, getAttribute(){return null}, style:{}},
head:{appendChild(){}}, body:{appendChild(){}},
cookie:'', referrer:'', title:'pt_auth', domain:'aq.huya.com', readyState:'complete', visibilityState:'visible',
referrer:'', title:'pt_auth', domain:'aq.huya.com', readyState:'complete', visibilityState:'visible',
addEventListener(){}, removeEventListener(){},
};
Object.defineProperty(document, 'cookie', {
configurable: true,
get(){ return Object.entries(cookieJar).map(([k,v]) => `${k}=${v}`).join('; '); },
set(value){
const first = String(value || '').split(';', 1)[0];
const index = first.indexOf('=');
if (index > 0) cookieJar[first.slice(0, index).trim()] = first.slice(index + 1).trim();
},
});
W.__huyaCookieJar = cookieJar;
W.document = document;
W.localStorage = (()=>{const m={}; return {getItem:k=>m[k]??null,setItem:(k,v)=>m[k]=String(v),removeItem:k=>delete m[k],clear:()=>{},key:i=>Object.keys(m)[i]??null,get length(){return Object.keys(m).length}}})();
W.sessionStorage = (()=>{const m={}; return {getItem:k=>m[k]??null,setItem:(k,v)=>m[k]=String(v),removeItem:k=>delete m[k],clear:()=>{},key:i=>null,get length(){return 0}}})();
W.indexedDB = {open(){return {onsuccess:null,onerror:null,onupgradeneeded:null,result:{objectStoreNames:{contains(){return false}},createObjectStore(){return {createIndex(){}}}},set onsuccess(f){setTimeout(()=>{},0)}}}};