Scripts目录不再必要存在,并移除 livePage.js; 调整项目结构
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
<!--系统代理端口-->
|
<!--系统代理端口-->
|
||||||
<add key="proxyPort" value="8827" />
|
<add key="proxyPort" value="8827" />
|
||||||
<!--是否启用系统代理,若设置为false 则需要在程序手动指定代理地址 -->
|
<!--是否启用系统代理,若设置为false 则需要在程序手动指定代理地址 -->
|
||||||
<add key="usedProxy" value="true" />
|
<add key="sysProxy" value="true" />
|
||||||
<!--上游代理地址,例如开启了系统代理,但是需要将其他无关请求转发到VPN工具中,例如:127.0.0.1:11223,不要带http://-->
|
<!--上游代理地址,例如开启了系统代理,但是需要将其他无关请求转发到VPN工具中,例如:127.0.0.1:11223,不要带http://-->
|
||||||
<add key="upstreamProxy" value="" />
|
<add key="upstreamProxy" value="" />
|
||||||
<!--在控制台输出弹幕-->
|
<!--在控制台输出弹幕-->
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace BarrageGrab
|
|||||||
LogFilter = Enum.GetValues(typeof(PackMsgType)).Cast<int>().Where(w => w > 0).ToArray();
|
LogFilter = Enum.GetValues(typeof(PackMsgType)).Cast<int>().Where(w => w > 0).ToArray();
|
||||||
FilterHostName = bool.Parse(AppSettings["filterHostName"].Trim());
|
FilterHostName = bool.Parse(AppSettings["filterHostName"].Trim());
|
||||||
HostNameFilter = AppSettings["hostNameFilter"].Trim().Split(',').Where(w => !string.IsNullOrWhiteSpace(w)).ToArray();
|
HostNameFilter = AppSettings["hostNameFilter"].Trim().Split(',').Where(w => !string.IsNullOrWhiteSpace(w)).ToArray();
|
||||||
UsedProxy = bool.Parse(AppSettings["usedProxy"].Trim());
|
UsedProxy = bool.Parse(AppSettings["sysProxy"].Trim());
|
||||||
ListenAny = bool.Parse(AppSettings["listenAny"].Trim());
|
ListenAny = bool.Parse(AppSettings["listenAny"].Trim());
|
||||||
UpstreamProxy = AppSettings["upstreamProxy"].Trim();
|
UpstreamProxy = AppSettings["upstreamProxy"].Trim();
|
||||||
HideConsole = bool.Parse(AppSettings["hideConsole"].Trim());
|
HideConsole = bool.Parse(AppSettings["hideConsole"].Trim());
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace BarrageGrab
|
|||||||
public static string GetJsFile(string fileName)
|
public static string GetJsFile(string fileName)
|
||||||
{
|
{
|
||||||
var path = Path.Combine(AppContext.BaseDirectory, "Scripts", "engine", fileName);
|
var path = Path.Combine(AppContext.BaseDirectory, "Scripts", "engine", fileName);
|
||||||
if (!File.Exists(path)) throw new FileNotFoundException("不存在的文件", path);
|
if (!File.Exists(path)) return null;
|
||||||
return File.ReadAllText(path, Encoding.UTF8);
|
return File.ReadAllText(path, Encoding.UTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace BarrageGrab
|
|||||||
static bool formExited = false;
|
static bool formExited = false;
|
||||||
static WinApi.ControlCtrlDelegate controlCtr = ControlCtrlHandle;
|
static WinApi.ControlCtrlDelegate controlCtr = ControlCtrlHandle;
|
||||||
static Mutex mutex = new Mutex(false, "DyBarrageGrab");
|
static Mutex mutex = new Mutex(false, "DyBarrageGrab");
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
if (!mutex.WaitOne(TimeSpan.Zero, true))
|
if (!mutex.WaitOne(TimeSpan.Zero, true))
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ namespace BarrageGrab.Proxy
|
|||||||
{
|
{
|
||||||
lock (rinfoRequestings) rinfoRequestings.Add(webroomid);
|
lock (rinfoRequestings) rinfoRequestings.Add(webroomid);
|
||||||
//查询后会自动缓存
|
//查询后会自动缓存
|
||||||
DyServer.GetRoomInfoForApi(webroomid, cookie).ContinueWith(t =>
|
DyApiHelper.GetRoomInfoForApi(webroomid, cookie).ContinueWith(t =>
|
||||||
{
|
{
|
||||||
var rinfo = t.Result;
|
var rinfo = t.Result;
|
||||||
//限制只尝试一次
|
//限制只尝试一次
|
||||||
@@ -333,22 +333,6 @@ namespace BarrageGrab.Proxy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取配置的注入的js
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private string GetInjectScript(string name)
|
|
||||||
{
|
|
||||||
//获取exe所在目录路径
|
|
||||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Scripts", "inject", name + ".js");
|
|
||||||
if (File.Exists(path))
|
|
||||||
{
|
|
||||||
return File.ReadAllText(path);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hook 直播页面
|
// Hook 直播页面
|
||||||
private async Task HookPageAsync(SessionEventArgs e)
|
private async Task HookPageAsync(SessionEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -377,8 +361,7 @@ namespace BarrageGrab.Proxy
|
|||||||
{
|
{
|
||||||
string webrid = liveRoomMactch.Groups[1].Value;
|
string webrid = liveRoomMactch.Groups[1].Value;
|
||||||
//获取直播页注入js
|
//获取直播页注入js
|
||||||
string liveRoomInjectScript = GetInjectScript("livePage");
|
string liveRoomInjectScript = EmbResource.GetFileContent("livePage.js");
|
||||||
|
|
||||||
//注入上下文变量;
|
//注入上下文变量;
|
||||||
var scriptContext = BuildContext(new Dictionary<string, string>()
|
var scriptContext = BuildContext(new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
@@ -435,7 +418,7 @@ namespace BarrageGrab.Proxy
|
|||||||
script.InnerHtml = liveRoomInjectScript;
|
script.InnerHtml = liveRoomInjectScript;
|
||||||
body.AppendChild(script);
|
body.AppendChild(script);
|
||||||
html = doc.DocumentNode.OuterHtml;
|
html = doc.DocumentNode.OuterHtml;
|
||||||
Logger.PrintColor($"直播页{urlNoQuery},用户脚本已成功注入!\n", ConsoleColor.Green);
|
Logger.LogTrace($"直播页{urlNoQuery},用户脚本已成功注入!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -459,7 +442,7 @@ namespace BarrageGrab.Proxy
|
|||||||
if (liveHomeMatch.Success)
|
if (liveHomeMatch.Success)
|
||||||
{
|
{
|
||||||
//获取直播页注入js
|
//获取直播页注入js
|
||||||
string liveHoomInjectScript = GetInjectScript("livePage");
|
string liveHoomInjectScript = EmbResource.GetFileContent("livePage.js");
|
||||||
|
|
||||||
//注入上下文变量;
|
//注入上下文变量;
|
||||||
var scriptContext = BuildContext(new Dictionary<string, string>()
|
var scriptContext = BuildContext(new Dictionary<string, string>()
|
||||||
|
|||||||
@@ -6,35 +6,9 @@
|
|||||||
* 正则: @".*:\/\/live.douyin\.com\/\d+"
|
* 正则: @".*:\/\/live.douyin\.com\/\d+"
|
||||||
**/
|
**/
|
||||||
|
|
||||||
/*注入脚本 定时触发全局keydown,避免直播流被无操作阻断*/
|
|
||||||
|
|
||||||
// 创建一个虚拟的按键事件
|
|
||||||
const simulatedEvent = new KeyboardEvent('keydown', {
|
|
||||||
key: 'Virtual_Alt',
|
|
||||||
keyCode: 18, //alt
|
|
||||||
bubbles: true,
|
|
||||||
cancelable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取要分派事件的目标元素,例如文档的根元素
|
|
||||||
const targetElement = document.documentElement;
|
|
||||||
|
|
||||||
// 设置定时器,每隔60秒模拟一次按键事件
|
|
||||||
setInterval(() => {
|
|
||||||
targetElement.dispatchEvent(simulatedEvent);
|
|
||||||
}, 1000 * 60);
|
|
||||||
|
|
||||||
// 订阅 keydown 事件 (Debug)
|
|
||||||
targetElement.addEventListener('keydown', event => {
|
|
||||||
if (event.key == "Virtual_Alt") {
|
|
||||||
console.log('[防挂机处理] 按下了', event.key);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/*禁止关闭 Websocket*/
|
/*禁止关闭 Websocket*/
|
||||||
WebSocket.prototype.close = function () { return; }
|
WebSocket.prototype.close = function () { return; }
|
||||||
|
|
||||||
|
|
||||||
/*判断是否自动关闭 */
|
/*判断是否自动关闭 */
|
||||||
//获取路由参数
|
//获取路由参数
|
||||||
function getQueryString(name) {
|
function getQueryString(name) {
|
||||||
|
|||||||
@@ -25,7 +25,13 @@ namespace BarrageGrab
|
|||||||
if (AppSetting.Current.UseComPortFilter)
|
if (AppSetting.Current.UseComPortFilter)
|
||||||
{
|
{
|
||||||
jsEngine = JsEngine.CreateNewEngine();
|
jsEngine = JsEngine.CreateNewEngine();
|
||||||
|
|
||||||
var jsFile = JsEngine.GetJsFile("comPortFilter.js");
|
var jsFile = JsEngine.GetJsFile("comPortFilter.js");
|
||||||
|
if (jsFile.IsNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
jsFile = EmbResource.GetFileContent("comPortFilter.js");
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
jsEngine.Execute(jsFile);
|
jsEngine.Execute(jsFile);
|
||||||
@@ -176,6 +176,7 @@ namespace BarrageGrab
|
|||||||
return obj.GetType().GetProperty(propertyName) != null;
|
return obj.GetType().GetProperty(propertyName) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//创建消息对象
|
||||||
private T CreateMsg<T>(dynamic msg) where T : Msg, new()
|
private T CreateMsg<T>(dynamic msg) where T : Msg, new()
|
||||||
{
|
{
|
||||||
var roomid = msg.Common.roomId.ToString();
|
var roomid = msg.Common.roomId.ToString();
|
||||||
@@ -581,28 +582,6 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
var cmdPack = JsonConvert.DeserializeObject<Command>(message);
|
var cmdPack = JsonConvert.DeserializeObject<Command>(message);
|
||||||
if (cmdPack == null) return;
|
if (cmdPack == null) return;
|
||||||
|
|
||||||
switch (cmdPack.Cmd)
|
|
||||||
{
|
|
||||||
case CommandCode.Close:
|
|
||||||
this.Dispose();
|
|
||||||
break;
|
|
||||||
case CommandCode.EnableProxy:
|
|
||||||
{
|
|
||||||
var enable = (bool)cmdPack.Data;
|
|
||||||
if (enable)
|
|
||||||
this.grab.Proxy.RegisterSystemProxy();
|
|
||||||
else
|
|
||||||
this.grab.Proxy.CloseSystemProxy();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CommandCode.DisplayConsole:
|
|
||||||
{
|
|
||||||
var display = (bool)cmdPack.Data;
|
|
||||||
AppRuntime.DisplayConsole(display);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
};
|
};
|
||||||
@@ -15,7 +15,7 @@ namespace BarrageGrab
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 抖音服务
|
/// 抖音服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class DyServer
|
internal class DyApiHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取直播礼物列表
|
/// 获取直播礼物列表
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BarrageGrab
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源文件
|
||||||
|
/// </summary>
|
||||||
|
public static class EmbResource
|
||||||
|
{
|
||||||
|
static Dictionary<string,string> cache = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取 嵌入式资源文件内容
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="Exception"></exception>
|
||||||
|
public static string GetFileContent(string fileName)
|
||||||
|
{
|
||||||
|
if(cache.ContainsKey(fileName))
|
||||||
|
{
|
||||||
|
return cache[fileName];
|
||||||
|
}
|
||||||
|
|
||||||
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||||
|
//读取嵌入式资源文件
|
||||||
|
var resourceName = assembly.GetManifestResourceNames().FirstOrDefault(s => s.EndsWith(fileName));
|
||||||
|
if (resourceName == null)
|
||||||
|
{
|
||||||
|
throw new Exception($"{fileName} 嵌入式资源不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
using (Stream stream = assembly.GetManifestResourceStream(resourceName))
|
||||||
|
{
|
||||||
|
using (StreamReader reader = new StreamReader(stream,Encoding.UTF8))
|
||||||
|
{
|
||||||
|
var text = reader.ReadToEnd();
|
||||||
|
cache.Add(fileName, text);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,8 +28,6 @@ namespace BarrageGrab
|
|||||||
internal static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint mode);
|
internal static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint mode);
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
internal static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint mode);
|
internal static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint mode);
|
||||||
|
|
||||||
///If the function fails, the return value is NULL.</returns>
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||||
|
|
||||||
@@ -218,8 +218,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AppRuntime.cs" />
|
<Compile Include="AppRuntime.cs" />
|
||||||
<Compile Include="AppSetting.cs" />
|
<Compile Include="AppSetting.cs" />
|
||||||
<Compile Include="ComPortServer.cs" />
|
<Compile Include="Server\ComPortServer.cs" />
|
||||||
<Compile Include="DyServer.cs" />
|
<Compile Include="Utility\DyApiHelper.cs" />
|
||||||
|
<Compile Include="Utility\EmbResource.cs" />
|
||||||
<Compile Include="Forms\FormView.cs">
|
<Compile Include="Forms\FormView.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -234,7 +235,7 @@
|
|||||||
<DependentUpon>RoomDetail.cs</DependentUpon>
|
<DependentUpon>RoomDetail.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="JsEngine.cs" />
|
<Compile Include="JsEngine.cs" />
|
||||||
<Compile Include="LiveCompanHelper.cs" />
|
<Compile Include="Utility\LiveCompanHelper.cs" />
|
||||||
<Compile Include="Logger.cs" />
|
<Compile Include="Logger.cs" />
|
||||||
<Compile Include="Modles\BusinessExecption.cs" />
|
<Compile Include="Modles\BusinessExecption.cs" />
|
||||||
<Compile Include="Modles\JsonEntity\BarrageMessages.cs" />
|
<Compile Include="Modles\JsonEntity\BarrageMessages.cs" />
|
||||||
@@ -251,10 +252,10 @@
|
|||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Proxy\SystemProxy.cs" />
|
<Compile Include="Proxy\SystemProxy.cs" />
|
||||||
<Compile Include="Proxy\TitaniumProxy.cs" />
|
<Compile Include="Proxy\TitaniumProxy.cs" />
|
||||||
<Compile Include="WinApi.cs" />
|
<Compile Include="Utility\WinApi.cs" />
|
||||||
<Compile Include="WssBarrageGrab.cs" />
|
<Compile Include="Server\WssBarrageGrab.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="WsBarrageServer.cs" />
|
<Compile Include="Server\WsBarrageServer.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
@@ -266,12 +267,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="FodyWeavers.xml" />
|
<Content Include="FodyWeavers.xml" />
|
||||||
<Content Include="Scripts\engine\comPortFilter.js">
|
<EmbeddedResource Include="Scripts\engine\comPortFilter.js" />
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<EmbeddedResource Include="Scripts\inject\livePage.js" />
|
||||||
</Content>
|
|
||||||
<Content Include="Scripts\inject\livePage.js">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
|
||||||
|
|||||||
@@ -16,8 +16,12 @@
|
|||||||
+ 如果好用,请<a href="#user-content-支持一下">捐赠</a>个仨瓜俩枣,白某谢过各位老板
|
+ 如果好用,请<a href="#user-content-支持一下">捐赠</a>个仨瓜俩枣,白某谢过各位老板
|
||||||
|
|
||||||
## ⛳近期更新
|
## ⛳近期更新
|
||||||
|
2025-04-14 v2.7.9
|
||||||
|
1. **[重要优化]** 大幅降低了程序包的体积
|
||||||
|
2. `nlog.config` 改为内嵌
|
||||||
|
|
||||||
2025-04-09 v2.7.8
|
2025-04-09 v2.7.8
|
||||||
|
|
||||||
1. 修复页面无操作检测拦截失效的问题,因为更新了脚本
|
1. 修复页面无操作检测拦截失效的问题,因为更新了脚本
|
||||||
2. 修复弹幕日志因主播昵称的特殊字符导致无法写入的问题
|
2. 修复弹幕日志因主播昵称的特殊字符导致无法写入的问题
|
||||||
|
|
||||||
@@ -58,24 +62,6 @@
|
|||||||
2. **[破坏性更新]** `WebRoomid` 和 `Roomid` 改为String类型
|
2. **[破坏性更新]** `WebRoomid` 和 `Roomid` 改为String类型
|
||||||
3. 之前直播伴侣开播会导致`WebRoomid`为-1,现会抓取直播伴侣开播响应信息,并填充`WebRoomid`,但直播伴侣的`WebRoomid`设定为主播**抖音号**,需要根据进程名做判断,使用请注意
|
3. 之前直播伴侣开播会导致`WebRoomid`为-1,现会抓取直播伴侣开播响应信息,并填充`WebRoomid`,但直播伴侣的`WebRoomid`设定为主播**抖音号**,需要根据进程名做判断,使用请注意
|
||||||
|
|
||||||
2024-03-10 v2.7.2
|
|
||||||
|
|
||||||
1. [**重要更新**] 支持设置为轮询模式监听(见配置项**forcePolling**,直播伴侣尚未支持),比起ws更稳定,适合长时间监听
|
|
||||||
2. 支持进入直播间画面自动暂停
|
|
||||||
3. 优化礼物连击判定规则,可区分出可连击的礼物,进一步避免礼物数量推送不准确的问题,并新增字段:
|
|
||||||
1. Combo 礼物是否可连击
|
|
||||||
2. ImgUrl 礼物图像地址
|
|
||||||
3. ToUser 送礼目标
|
|
||||||
4. roomId过滤改为 WebRoomid 过滤(仅支持已经被缓存的直播间,对直播伴侣可能无效)
|
|
||||||
5. 添加“关闭代理.bat” 批处理脚本,见根目录或者上方文件,便于无法上网时双击执行
|
|
||||||
6. 更多介绍请查看底下新增配置项
|
|
||||||
|
|
||||||
2023-11-23 v2.7.0
|
|
||||||
|
|
||||||
1. 修复了因抖音版本升级导致的WebRoomId获取不到的问题,并更近了正则表达式尽量兼容后续的变更
|
|
||||||
2. 添加了winfrom窗体,功能有限,默认隐藏
|
|
||||||
3. 支持了控制台隐藏,推送器弹幕类型过滤,日志弹幕类型过滤,弹幕文件日志 (见<a href="#tag1">配置文件</a>)
|
|
||||||
4. 支持了更多的ws命令,见 [Command.cs](./BarrageGrab/Modles/JsonEntity/Command.cs)
|
|
||||||
|
|
||||||
## 🖼️控制台截图
|
## 🖼️控制台截图
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user