// ==UserScript==
// @name 获取用户昵称、头像、评论
// @namespace http://xxx
// @version 0.2
// @description 当你打开xx直播页,获取danmu信息
// @author Ganb
// @match https://live.douyin.com/*
// @icon http://xxxxx
// @run-at document-start
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @grant GM_xmlhttpRequest
// @connect api.movloft.cn
// ==/UserScript==
(function() {
'use strict';
console.log('抖音实时websocket消息获取')
window.addEventListener('test', d => {
let e=d.detail
//console.log(e)
if(e.common.method=="WebcastChatMessage"){
var nickname=e.user.nickname
var content=e.content
var gender=e.user.gender
if (typeof(content) == "undefined"){
content='';
}
var avatar=e.user.avatarThumb.urlListList[0]
var data={
nickname:nickname,content,gender,avatar:avatar}
console.log(data)
GM_xmlhttpRequest ( {
method: "POST",
url: "https://api.movloft.cn:8085/danmu2",
headers: {
"Content-Type": "application/json"
},
data: JSON.stringify(data),
onload: function (res) {
console.log("弹幕",res.response)
}
});
}
})
})();
try{
let event = new CustomEvent('test', { detail: s.toObject() });
window.dispatchEvent(event);
}
catch(e){
this.info("my error check");
};