-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de0ff0a
commit b4bcd20
Showing
6 changed files
with
533 additions
and
224 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
</head> | ||
<body> | ||
<input id="k" type="hidden" value="NjMyZmVmZjFmNGM4Mzg1NDFhYjc1MTk1ZDFjZWIzZmE="> | ||
<input id="account" type="hidden" value="20190415185258_koh5p7y4pe0vqys"> | ||
<input id="token" type="hidden" value="d8ym9oebhq"> | ||
<input id="server-id" type="hidden" value="1213952"> | ||
|
||
<div id="root"></div> | ||
<script src="../../../node_modules/nim-web-sdk-ng/dist/QCHAT_BROWSER_SDK.js"></script> | ||
<script> | ||
/** | ||
* @param { Record<string, any> } obj | ||
* @param { (k: string, v: any) => boolean } callback | ||
*/ | ||
function objectSome(obj, callback) { | ||
let result = false; | ||
|
||
for (const key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
result = callback(key, obj[key]); | ||
|
||
if (result) break; | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
/* Hack */ | ||
globalThis.WebSocket.prototype.ORIGINAL_send = globalThis.WebSocket.prototype.send; | ||
|
||
globalThis.WebSocket.prototype.send = function() { | ||
if (/3:::/.test(arguments[0])) { | ||
const message = arguments[0].replace(/3:::/, ''); | ||
let data = null; | ||
|
||
try { | ||
data = JSON.parse(message); | ||
} catch { /* noop */ } | ||
|
||
if (data && data?.SER === 1 && data?.SID === 24 && data?.Q?.length) { | ||
for (const Q of data.Q) { | ||
if (/Property/i.test(Q.t) && Q.v && objectSome(Q.v, (k, v) => /Native\/[0-9]/i.test(v))) { | ||
Q.v['6'] = 2; | ||
arguments[0] = `3:::${ JSON.stringify(data) }`; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return this.ORIGINAL_send.apply(this, arguments); | ||
}; | ||
</script> | ||
<script> | ||
function getServerInfo(serverId) { | ||
return new Promise(async (resolve, reject) => { | ||
try { | ||
const qchat = new QChat({ | ||
appkey: atob(document.getElementById('k').value), | ||
account: document.getElementById('account').value, | ||
token: document.getElementById('token').value, | ||
linkAddresses: ['qchatweblink01.netease.im:443'] | ||
}); | ||
|
||
qchat.on('logined', async () => { | ||
const serverInfo = await qchat.qchatServer.getServers({ | ||
serverIds: [serverId] | ||
}); | ||
|
||
resolve({ | ||
serverInfo, | ||
// qchat, | ||
owner: serverInfo[0].owner, | ||
success: 1 | ||
}); | ||
}); | ||
|
||
await qchat.login(); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}); | ||
} | ||
|
||
globalThis.runGetServerInfo = function runGetServerInfo() { | ||
getServerInfo(String(document.getElementById('server-id').value)).then((r) => { | ||
let element = document.createElement('div'); | ||
|
||
element.innerText = JSON.stringify(r); | ||
element.id = 'result'; | ||
document.getElementById('root').appendChild(element); | ||
element = null; | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.