Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tqk2811/d1c3ee765fecaf2e24c393c274dd0342 to your computer and use it in GitHub Desktop.
Save tqk2811/d1c3ee765fecaf2e24c393c274dd0342 to your computer and use it in GitHub Desktop.
Replace JS
using AutoGamblingSelenium.DataClass;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using TqkLibrary.Proxy.Authentications;
using TqkLibrary.Proxy.Handlers;
using TqkLibrary.Proxy.Interfaces;
using TqkLibrary.Proxy.ProxySources;
namespace AutoGamblingSelenium.SeleniumProfiles.Proxies
{
partial class MyHttpProxyServerHandler : BaseProxyServerHandler
{
readonly IProxySource _LocalProxySource;
IProxySource? _httpProxySource = null;
public bool IsUseProxy { get; set; } = true;
IReadOnlyDictionary<string, WebJsInjectData> _webJsInjectData;
public MyHttpProxyServerHandler(
IReadOnlyDictionary<string, WebJsInjectData> webJsInjectData,
string? proxy = null
)
{
this._webJsInjectData = webJsInjectData ?? throw new ArgumentNullException(nameof(webJsInjectData));
_LocalProxySource = new MyLocalProxySource(webJsInjectData);
SetProxy(proxy);
}
public void SetProxy(string? proxy)
{
if (!string.IsNullOrWhiteSpace(proxy))
{
var split = proxy.Split(':');
if (split.Length == 2 || split.Length == 4)
{
HttpProxyAuthentication? auth = null;
if (split.Length == 4)
{
auth = new HttpProxyAuthentication(split[2], split[3]);
_httpProxySource = new MyHttpProxySource(new Uri($"http://{split[0]}:{split[1]}"), auth, _webJsInjectData);
}
else
{
_httpProxySource = new MyHttpProxySource(new Uri($"http://{split[0]}:{split[1]}"), _webJsInjectData);
}
}
else
throw new InvalidOperationException("Proxy sai định dạng");
}
else
{
_httpProxySource = null;
}
}
public override Task<IProxySource> GetProxySourceAsync(Uri? uri, IUserInfo userInfo, CancellationToken cancellationToken = default)
{
return Task.FromResult(_httpProxySource ?? _LocalProxySource);
}
}
}
using System;
using TqkLibrary.Proxy.Interfaces;
using TqkLibrary.Proxy.Authentications;
using TqkLibrary.Proxy.ProxySources;
using System.Threading.Tasks;
using System.Threading;
using System.IO;
using System.Diagnostics;
using System.Net.Security;
using System.Linq;
using System.Collections.Generic;
using AutoGamblingSelenium.DataClass;
namespace AutoGamblingSelenium.SeleniumProfiles.Proxies
{
partial class MyHttpProxyServerHandler
{
class MyHttpProxySource : HttpProxySource
{
class MyConnectTunnel : HttpProxySource.ConnectTunnel
{
IReadOnlyDictionary<string, WebJsInjectData> _webJsInjectData;
public MyConnectTunnel(
IReadOnlyDictionary<string, WebJsInjectData> webJsInjectData,
HttpProxySource proxySource,
Guid tunnelId
) : base(proxySource, tunnelId)
{
this._webJsInjectData = webJsInjectData ?? throw new ArgumentNullException(nameof(webJsInjectData));
}
Uri? _address;
public override async Task ConnectAsync(Uri address, CancellationToken cancellationToken = default)
{
Debug.WriteLine($"MyConnectTunnel.ConnectAsync: {address}");
if (_webJsInjectData.Keys.Any(x => address.Host.Equals(x)))
{
Uri newAddress = new Uri($"https://{address.Host}{address.PathAndQuery}");
await base.ConnectAsync(newAddress, cancellationToken);
this._address = newAddress;
}
else
{
await base.ConnectAsync(address, cancellationToken);
}
}
public override async Task<Stream> GetStreamAsync(CancellationToken cancellationToken = default)
{
if (_address is not null)
{
Stream stream = await base.GetStreamAsync(cancellationToken);
SslStream sslStream = new SslStream(stream, false);
sslStream.AuthenticateAsClient(_address!.Host);
return new WrapperStream(_webJsInjectData[_address.Host.ToLower()], sslStream);
}
else
{
return await base.GetStreamAsync(cancellationToken);
}
}
}
IReadOnlyDictionary<string, WebJsInjectData> _webJsInjectData;
public MyHttpProxySource(Uri proxy, IReadOnlyDictionary<string, WebJsInjectData> webJsInjectData) : base(proxy)
{
this._webJsInjectData = webJsInjectData ?? throw new ArgumentNullException(nameof(webJsInjectData));
}
public MyHttpProxySource(Uri proxy, HttpProxyAuthentication httpProxyAuthentication, IReadOnlyDictionary<string, WebJsInjectData> webJsInjectData) : base(proxy, httpProxyAuthentication)
{
this._webJsInjectData = webJsInjectData ?? throw new ArgumentNullException(nameof(webJsInjectData));
}
public override IConnectSource GetConnectSource(Guid tunnelId)
{
return new MyConnectTunnel(_webJsInjectData, this, tunnelId);
}
}
}
}
using System.Threading.Tasks;
using System.Threading;
using System;
using TqkLibrary.Proxy.Interfaces;
using TqkLibrary.Linq;
using TqkLibrary.Proxy.ProxySources;
using System.Diagnostics;
using System.IO;
using System.Net.Security;
using System.Linq;
using System.Collections.Generic;
using AutoGamblingSelenium.DataClass;
namespace AutoGamblingSelenium.SeleniumProfiles.Proxies
{
partial class MyHttpProxyServerHandler
{
class MyLocalProxySource : LocalProxySource
{
class MyConnectTunnel : LocalProxySource.ConnectTunnel
{
IReadOnlyDictionary<string, WebJsInjectData> _webJsInjectData;
public MyConnectTunnel(
IReadOnlyDictionary<string, WebJsInjectData> webJsInjectData,
LocalProxySource localProxySource,
Guid tunnelId)
: base(localProxySource, tunnelId)
{
this._webJsInjectData = webJsInjectData ?? throw new ArgumentNullException(nameof(webJsInjectData));
}
Uri? _address;
public override async Task ConnectAsync(Uri address, CancellationToken cancellationToken = default)
{
Debug.WriteLine($"MyConnectTunnel.ConnectAsync: {address}");
if (_webJsInjectData.Keys.Any(x => address.Host.Equals(x)))
{
Uri newAddress = new Uri($"https://{address.Host}{address.PathAndQuery}");
await base.ConnectAsync(newAddress, cancellationToken);
this._address = newAddress;
}
else
{
await base.ConnectAsync(address, cancellationToken);
}
}
public override async Task<Stream> GetStreamAsync(CancellationToken cancellationToken = default)
{
if (_address is not null)
{
Stream stream = await base.GetStreamAsync(cancellationToken);
SslStream sslStream = new SslStream(stream, false);
sslStream.AuthenticateAsClient(_address!.Host);
return new WrapperStream(_webJsInjectData[_address.Host.ToLower()], sslStream);
}
else
{
return await base.GetStreamAsync(cancellationToken);
}
}
}
IReadOnlyDictionary<string, WebJsInjectData> _webJsInjectData;
public MyLocalProxySource(IReadOnlyDictionary<string, WebJsInjectData> webJsInjectData)
{
this._webJsInjectData = webJsInjectData ?? throw new ArgumentNullException(nameof(webJsInjectData));
}
public override IConnectSource GetConnectSource(Guid tunnelId)
{
return new MyConnectTunnel(_webJsInjectData, this, tunnelId);
}
}
}
}
using System.Threading.Tasks;
using System.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Compression;
using System.IO;
using System.Text;
using TqkLibrary.Proxy.Helpers;
using TqkLibrary.Proxy.StreamHeplers;
using System.Linq;
using TqkLibrary.Linq;
using AutoGamblingSelenium.DataClass;
namespace AutoGamblingSelenium.SeleniumProfiles.Proxies
{
partial class MyHttpProxyServerHandler
{
class WrapperStream : Stream
{
readonly MemoryStream _tmpStreamRead = new MemoryStream();
readonly MemoryStream _tmpStreamSend = new MemoryStream();
readonly List<string> _tmpHeadersReceived = new List<string>();
readonly MemoryStream _tmpStreamBodyReceived = new MemoryStream();
readonly Stream _stream;
readonly WebJsInjectData _webJsInjectData;
public WrapperStream(WebJsInjectData webJsInjectData, Stream stream)
{
this._stream = stream ?? throw new ArgumentNullException(nameof(stream));
_webJsInjectData = webJsInjectData;
}
public override bool CanRead => _stream.CanRead;
public override bool CanSeek => false;
public override bool CanWrite => _stream.CanWrite;
public override long Length => throw new NotSupportedException();
public override long Position { get => throw new NotSupportedException(); set => throw new NotSupportedException(); }
public override void Flush() => _stream.Flush();
public override int Read(byte[] buffer, int offset, int count) => throw new NotSupportedException();
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
public override void SetLength(long value) => throw new NotSupportedException();
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
protected override void Dispose(bool disposing)
{
_tmpStreamRead.Dispose();
_tmpStreamSend.Dispose();
_tmpStreamBodyReceived.Dispose();
_stream.Dispose();
base.Dispose(disposing);
}
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
=> _stream.BeginRead(buffer, offset, count, callback, state);
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? callback, object? state)
=> _stream.BeginWrite(buffer, offset, count, callback, state);
async Task ReadAllResponseAsync(CancellationToken cancellationToken = default)
{
string? line;
do
{
line = await _stream.ReadLineAsync(cancellationToken);
if (!string.IsNullOrWhiteSpace(line))
{
_tmpHeadersReceived.Add(line);
}
else
{
break;
}
}
while (true);
HeaderResponseParse headerResponseParse = HeaderResponseParse.ParseResponse(_tmpHeadersReceived);
if (headerResponseParse.ContentLength > 0)
{
int totalRead = 0;
byte[] buffer = new byte[8096];
while (totalRead < headerResponseParse.ContentLength)
{
int byte_read = await _stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken);
await _tmpStreamBodyReceived.WriteAsync(buffer, 0, byte_read);
totalRead += byte_read;
}
}
else if (_tmpHeadersReceived.Any(x =>
x.StartsWith("Transfer-Encoding", StringComparison.OrdinalIgnoreCase) &&
x.Contains("chunked", StringComparison.OrdinalIgnoreCase))
)
{
UInt16 chunkLength = 0;
byte[] buffer = new byte[8096];
do
{
string hexstring = await _stream.ReadLineAsync(cancellationToken);
chunkLength = UInt16.Parse(hexstring, System.Globalization.NumberStyles.HexNumber);
int totalRead = 0;
while (totalRead < chunkLength)
{
int byte_read = await _stream.ReadAsync(buffer, 0, Math.Min(buffer.Length, chunkLength - totalRead), cancellationToken);
await _tmpStreamBodyReceived.WriteAsync(buffer, 0, byte_read);
totalRead += byte_read;
}
await _stream.ReadLineAsync(cancellationToken);//read end of chunk https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Encoded_data
}
while (chunkLength > 0);
}
}
static readonly IEnumerable<string> stringContentType = new List<string>()
{
"application/javascript",
"text/html",
"application/json",
};
static readonly IReadOnlyDictionary<string, string> replaceDict = new Dictionary<string, string>()
{
{ "https://", "http://" },
{ "https%3A", "http%3A" },
{ "wss://", "ws://" },
};
async Task ReplaceDataAsync(CancellationToken cancellationToken = default)
{
string? content_type = _tmpHeadersReceived.FirstOrDefault(x => x.StartsWith("content-type: ", StringComparison.OrdinalIgnoreCase));
string? type = null;
bool isChangeTextBody = false;
if (!string.IsNullOrWhiteSpace(content_type))
{
type = stringContentType.FirstOrDefault(x => content_type.Contains(x, StringComparison.OrdinalIgnoreCase));
switch (type)
{
case "application/javascript":
case "text/html":
case "application/json":
isChangeTextBody = true;
break;
default:
Debug.WriteLine($"{content_type}");
type = null;
break;
}
}
if (isChangeTextBody)
{
string bodyData = await GetBodyAsync(cancellationToken);
foreach (var pair in replaceDict)
{
while (bodyData.Contains(pair.Key))
bodyData = bodyData.Replace(pair.Key, pair.Value);
}
switch (type)
{
case "application/javascript":
{
bodyData = ReplaceJs(bodyData);
break;
}
}
await RemakeBodyAsync(bodyData, cancellationToken);
}
else
{
_tmpStreamBodyReceived.Seek(0, SeekOrigin.Begin);
await RemakeBodyAsync(_tmpStreamBodyReceived, cancellationToken);
}
}
string ReplaceJs(string bodyData)
{
foreach (var replaceRegion in _webJsInjectData.Replaces)
{
int index_MauBinhController = bodyData.IndexOf(replaceRegion.ReplaceJsStart);
int index_MauBinhMessage = bodyData.IndexOf(replaceRegion.ReplaceJsEnd);
if (index_MauBinhController >= 0 && index_MauBinhMessage >= 0)
{
string before = bodyData.Substring(0, index_MauBinhController);
string after = bodyData.Substring(index_MauBinhMessage);
string MauBinhController = bodyData.Substring(index_MauBinhController, index_MauBinhMessage - index_MauBinhController);
foreach (var pair in replaceRegion.ReplaceList)
{
MauBinhController = MauBinhController.Replace(pair.Key, pair.Value);
}
bodyData = before + MauBinhController + after;
}
}
return bodyData;
}
async Task RemakeBodyAsync(string bodyData, CancellationToken cancellationToken = default)
{
using MemoryStream memoryStream = new MemoryStream();
if (_isGzip)
{
using MemoryStream rawStream = new MemoryStream(Encoding.UTF8.GetBytes(bodyData));
using GZipStream gZipStream = new GZipStream(memoryStream, CompressionMode.Compress, true);
await rawStream.CopyToAsync(gZipStream, cancellationToken);
}
else
{
await memoryStream.WriteAsync(Encoding.UTF8.GetBytes(bodyData), cancellationToken);
}
memoryStream.Seek(0, SeekOrigin.Begin);
await RemakeBodyAsync(memoryStream, cancellationToken);
}
async Task RemakeBodyAsync(Stream bodyStream, CancellationToken cancellationToken = default)
{
string? headerContentLength = _tmpHeadersReceived.FirstOrDefault(x => x.StartsWith("content-length", StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrWhiteSpace(headerContentLength))
_tmpHeadersReceived.Remove(headerContentLength);
string? headerTransferEncoding = _tmpHeadersReceived.FirstOrDefault(x => x.StartsWith("Transfer-Encoding", StringComparison.OrdinalIgnoreCase));
if (!string.IsNullOrWhiteSpace(headerTransferEncoding))
_tmpHeadersReceived.Remove(headerTransferEncoding);
_tmpHeadersReceived.Add($"Content-Length: {bodyStream.Length}");
string header = string.Join("\r\n", _tmpHeadersReceived.Select(x => x.Replace("https", "http"))) + "\r\n\r\n";
Debug.WriteLine($"RemakeBodyAsync: {header}");
await _tmpStreamRead.WriteAsync(Encoding.ASCII.GetBytes(header), cancellationToken);
await bodyStream.CopyToAsync(_tmpStreamRead, cancellationToken);
}
bool _isGzip = false;
async Task<string> GetBodyAsync(CancellationToken cancellationToken = default)
{
if (_tmpHeadersReceived.Any(x => x.StartsWith("content-encoding", StringComparison.OrdinalIgnoreCase) && x.Contains("gzip")))
{
_isGzip = true;
_tmpStreamBodyReceived.Seek(0, SeekOrigin.Begin);
using GZipStream gZipStream = new GZipStream(_tmpStreamBodyReceived, CompressionMode.Decompress, true);
using MemoryStream memoryStream = new MemoryStream();
await gZipStream.CopyToAsync(memoryStream, cancellationToken);
memoryStream.Seek(0, SeekOrigin.Begin);
return Encoding.UTF8.GetString(memoryStream.ToArray());
}
else return Encoding.UTF8.GetString(_tmpStreamBodyReceived.ToArray());
}
bool _isProcessed = false;
public override async Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
{
if (!_isProcessed)
{
_isProcessed = true;
await ReadAllResponseAsync(cancellationToken);
Debug.WriteLine($"MyConnectTunnel.WrapperStream.ReadAsync: {string.Join("\r\n", _tmpHeadersReceived)}");
await ReplaceDataAsync(cancellationToken);//change data and write to _tmpStreamRead
_tmpStreamRead.Seek(0, SeekOrigin.Begin);
}
return await _tmpStreamRead.ReadAsync(buffer, offset, count, cancellationToken);
}
public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)
{
//send request to server
await _tmpStreamSend.WriteAsync(buffer, offset, count, cancellationToken);
await _stream.WriteAsync(buffer, offset, count, cancellationToken);
}
}
}
}
using AutoGamblingSelenium.Enums;
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Generic;
namespace AutoGamblingSelenium.DataClass
{
internal class WebJsInjectDataReplaceRegion
{
public string ReplaceJsStart { get; set; } = "MauBinhController:[function(t,e,i)";
public string ReplaceJsEnd { get; set; } = "MauBinhMessage:[function(t,e,i)";
public Dictionary<string, string> ReplaceList { get; set; } = new Dictionary<string, string>();
}
internal class WebJsInjectData
{
public AccountSource AccountSource { get; set; } = AccountSource.May88;
public GameType GameType { get; set; } = GameType.MauBinh;
public Dictionary<GameType, string> GameUrlFormat { get; set; } = new();
public List<WebJsInjectDataReplaceRegion> Replaces { get; set; } = new();
public Dictionary<GameType, Dictionary<string, string>> MethodList { get; set; } = new();
public Dictionary<XocDiaDoor, string> XocDiaDoorMapDict { get; set; } = new();
static KeyValuePair<string, WebJsInjectData> games_gnightfast_net()
{
return new KeyValuePair<string, WebJsInjectData>("games.gnightfast.net", new WebJsInjectData()
{
AccountSource = AccountSource.May88,
GameType = GameType.XocDia | GameType.MauBinh,
GameUrlFormat = new()
{
{ GameType.XocDia, "http://games.gnightfast.net/?brand=lucky&token={token}&gameid=vgcg_9&ru=" },
{ GameType.MauBinh, "http://games.gnightfast.net/?token={token}&gameid=vgcg_4&brand=may88&ru=https://may88.com/games" },
},
Replaces = new List<WebJsInjectDataReplaceRegion>()
{
//xoc dia
new WebJsInjectDataReplaceRegion()
{
ReplaceJsStart = "XocDiaController:[function(t,e,i)",
ReplaceJsEnd = "XocDiaEntryButton:[function(t,e,i)",
ReplaceList = new Dictionary<string, string>()
{
{
"O=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;",
"O=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;window.XocDiaController = e;"
},
},
},
new WebJsInjectDataReplaceRegion()
{
ReplaceJsStart = "XocDiaEntryButton:[function(t,e,i)",
ReplaceJsEnd = "XocDiaMessage:[function(t,e,i)",
ReplaceList = new Dictionary<string, string>()
{
{
"return n(e,t),e.prototype.init=function(t,e){",
@"return n(e,t),e.prototype.init=function(t,e){
if(!window.XocDiaBtn)window.XocDiaBtn = {};
window.XocDiaBtn[this.node._name] = this;"
},
},
},
//mau binh
new WebJsInjectDataReplaceRegion()
{
ReplaceJsStart = "MauBinhController:[function(t,e,i)",
ReplaceJsEnd = "MauBinhMessage:[function(t,e,i)",
ReplaceList = new Dictionary<string, string>()
{
{
"N=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;",
"N=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;window.MauBinhController = e;"
},
{
"return n(e,t),",
@"return n(e,t),
e.prototype.SapBai = function(serverCodes){
for(let i = 0; i < 13; i++)
{
var card = this._thisPlayerView.cards[i];
card.setTextureWithCode(serverCodes[i], l.default.getInstance().gameID),
card.index = i
}
this.updateTextBinh(),
this._khongThaoTac = !1
},"
},
},
},
},
MethodList = new()
{
{
GameType.XocDia,
new()
{
{ "BetToDoor" , "window.XocDiaBtn[arguments[0]].onClickBtn();" },//door name
{ "SellectCoin" , "window.XocDiaController.listBtnChoseMucCuoc[arguments[0]].toggle();" },//index
{ "GetCoinList" , "return window.XocDiaController.listEntryValueData;" },//int64 arr -> pass index to SellectCoin
{ "GetIsBetTime" , @"
return !(
window.XocDiaController.state !== 1 ||
window.XocDiaController._dangKetThuc ||
window.XocDiaController._dangXocDia ||
(window.XocDiaController._ngungNhanCuoc || (window.XocDiaController.countDownActionProgressTo.progressBar.progress < .1 && window.XocDiaController.countDownActionProgressTo.progressBar.progress > 0))
)
" },
}
},
{
GameType.MauBinh,
new()
{
{ "GetIsDealCard", @"
if(window.MauBinhController?.isPlaying)
{
return true;
}
else
{
return false;
}
" },
{ "GetCards", @"let serverCodes = [];
for(let i = 0; i < 13; i++)
serverCodes.push(MauBinhController._thisPlayerView.cards[i].serverCode);
return serverCodes;
" },
{ "SortCard", "MauBinhController.SapBai(arguments[0]);" },
{ "SortDone", "MauBinhController.onClickXepXong();" },
{ "BaoBinh", "MauBinhController.onClickBaoBinh();" },
}
},
},
XocDiaDoorMapDict = new Dictionary<XocDiaDoor, string>()
{
{ XocDiaDoor.Odd, "BtnLe" },
{ XocDiaDoor.Even, "btnChan" },
//{ XocDiaDoor.BonDo, "Btn4Red" },
//{ XocDiaDoor.BonTrang, "Btn4White" },
{ XocDiaDoor.BaDoMotTrang, "Btn3red" },
{ XocDiaDoor.MotDoBaTrang, "Btn3White" },
},
});
}
static KeyValuePair<string, WebJsInjectData> games_prorichvip_com()
{
return new KeyValuePair<string, WebJsInjectData>("games.prorichvip.com", new WebJsInjectData()
{
AccountSource = AccountSource.May88,
GameType = GameType.MauBinh /*| GameType.TaiXiu*/,
GameUrlFormat = new()
{
{ GameType.TaiXiu, "http://games.prorichvip.com/?brand=may88&ru=https%3A%2F%2Fmay88.game%2Fgames%23card&token={token}&gameid=vgmn_101" },
{ GameType.MauBinh, "http://games.prorichvip.com/?brand=may88&ru=https%3A%2F%2Fmay88.game%2Fgames%23card&token={token}&gameid=vgcg_4" },
},
Replaces = new List<WebJsInjectDataReplaceRegion>()
{
//mau binh
new WebJsInjectDataReplaceRegion()
{
ReplaceJsStart = "MauBinhController:[function(t,e,i)",
ReplaceJsEnd = "MauBinhMessage:[function(t,e,i)",
ReplaceList = new Dictionary<string, string>()
{
{
"E=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;",
"E=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;window.MauBinhController = e;"
},
{
"return n(e,t),",
@"return n(e,t),
e.prototype.SapBai = function(serverCodes){
for(let i = 0; i < 13; i++)
{
var card = this._thisPlayerView.cards[i];
card.setTextureWithCode(serverCodes[i], r.default.getInstance().gameID),
card.index = i
}
this.updateTextBinh(),
this._khongThaoTac = !1
},"
}
},
},
//tai xiu
new WebJsInjectDataReplaceRegion()
{
ReplaceJsStart = "TaiXiuMd5Controller:[function(t,e,i)",
ReplaceJsEnd = "TaiXiuMd5RequestHandler:[function(t,e,i)",
ReplaceList = new()
{
{
"E=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;",
"E=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;window.TaiXiuMd5Controller = e;"
},
}
}
},
MethodList = new()
{
{
GameType.MauBinh,
new()
{
{ "GetIsDealCard", @"
if(window.MauBinhController?.isDealCard)
{
return true;
}
else
{
return false;
}
" },
{ "GetCards", @"let serverCodes = [];
for(let i = 0; i < 13; i++)
serverCodes.push(MauBinhController._thisPlayerView.cards[i].serverCode);
return serverCodes;
" },
{ "SortCard", "MauBinhController.SapBai(arguments[0]);" },
{ "SortDone", "MauBinhController.onClickXepXong();" },
{ "BaoBinh", "MauBinhController.onClickBaoBinh();" }
}
},
},
});
}
static KeyValuePair<string, WebJsInjectData> web_hitclub_fun()
{
return new KeyValuePair<string, WebJsInjectData>("web.hitclub.fun", new WebJsInjectData()
{
AccountSource = AccountSource.May88,
GameType = GameType.MauBinh,
GameUrlFormat = new Dictionary<GameType, string>()
{
{ GameType.MauBinh, "" },
},
Replaces = new List<WebJsInjectDataReplaceRegion>()
{
new WebJsInjectDataReplaceRegion()
{
ReplaceJsStart = "MauBinhController:[function(t,e,i)",
ReplaceJsEnd = "MauBinhMessage:[function(t,e,i)",
ReplaceList = new Dictionary<string, string>()
{
{
"N=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;",
"N=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;window.MauBinhController = e;"
},
{
"return n(e,t),",
@"return n(e,t),
e.prototype.SapBai = function(serverCodes){
for(let i = 0; i < 13; i++)
{
var card = this._thisPlayerView.cards[i];
card.setTextureWithCode(serverCodes[i], l.default.getInstance().gameID),
card.index = i
}
this.updateTextBinh(),
this._khongThaoTac = !1
},"
},
},
},
},
MethodList = new Dictionary<GameType, Dictionary<string, string>>()
{
{
GameType.MauBinh,
new()
{
{ "GetIsDealCard", @"
if(window.MauBinhController?.isPlaying)
{
return true;
}
else
{
return false;
}" },
{ "GetCards", @"let serverCodes = [];
for(let i = 0; i < 13; i++)
serverCodes.push(MauBinhController._thisPlayerView.cards[i].serverCode);
return serverCodes;
" },
{ "SortCard", "MauBinhController.SapBai(arguments[0]);" },
{ "SortDone", "MauBinhController.onClickXepXong();" },
{ "BaoBinh", "MauBinhController.onClickBaoBinh();" }
}
}
}
});
}
static KeyValuePair<string, WebJsInjectData> gamebai_b5richkids_net()
{
return new KeyValuePair<string, WebJsInjectData>("gamebai.b5richkids.net", new WebJsInjectData()
{
AccountSource = AccountSource.May88,
GameType = GameType.MauBinh,
GameUrlFormat = new Dictionary<GameType, string>()
{
{ GameType.MauBinh, "http://gamebai.b5richkids.net/?brand=may88&ru=https%3A%2F%2Fmay88.game%2Fgames%23card&token={token}&gameid=vgcg_4" },
},
Replaces = new List<WebJsInjectDataReplaceRegion>()
{
new WebJsInjectDataReplaceRegion()
{
ReplaceJsStart = "MauBinhController:[function(t,e,i)",
ReplaceJsEnd = "MauBinhMessage:[function(t,e,i)",
ReplaceList = new Dictionary<string, string>()
{
{
"I=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;",
"I=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;window.MauBinhController = e;"
},
{
"return n(e,t),",
@"return n(e,t),
e.prototype.SapBai = function(serverCodes){
for(let i = 0; i < 13; i++)
{
var card = this._thisPlayerView.cards[i];
card.setTextureWithCode(serverCodes[i], r.default.getInstance().gameID),
card.index = i
}
this.updateTextBinh(),
this._khongThaoTac = !1
},"
},
},
},
},
MethodList = new()
{
{
GameType.MauBinh,
new()
{
{ "GetIsDealCard", @"
if(window.MauBinhController?.isDealCard)
{
return true;
}
else
{
return false;
}
" },
{ "GetCards", @"let serverCodes = [];
for(let i = 0; i < 13; i++)
serverCodes.push(MauBinhController._thisPlayerView.cards[i].serverCode);
return serverCodes;
" },
{ "SortCard", "MauBinhController.SapBai(arguments[0]);" },
{ "SortDone", "MauBinhController.onClickXepXong();" },
{ "BaoBinh", "MauBinhController.onClickBaoBinh();" }
}
}
},
});
}
static KeyValuePair<string, WebJsInjectData> i_b52_club()
{
return new KeyValuePair<string, WebJsInjectData>("i.b52.club", new WebJsInjectData()
{
AccountSource = AccountSource.May88,
GameType = GameType.MauBinh,
GameUrlFormat = new Dictionary<GameType, string>()
{
{ GameType.MauBinh, "http://i.b52.club/?app_id=B52&token={token}&gameid=vgcg_4" },
},
Replaces = new List<WebJsInjectDataReplaceRegion>()
{
new WebJsInjectDataReplaceRegion()
{
ReplaceJsStart = "MauBinhController:[function(t,e,i)",
ReplaceJsEnd = "MauBinhMessage:[function(t,e,i)",
ReplaceList = new Dictionary<string, string>()
{
{
"I=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;",
"I=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;window.MauBinhController = e;"
},
{
"return n(e,t),",
@"return n(e,t),
e.prototype.SapBai = function(serverCodes){
for(let i = 0; i < 13; i++)
{
var card = this._thisPlayerView.cards[i];
card.setTextureWithCode(serverCodes[i], r.default.getInstance().gameID),
card.index = i
}
this.updateTextBinh(),
this._khongThaoTac = !1
},"
},
},
},
},
MethodList = new()
{
{
GameType.MauBinh,
new()
{
{ "GetIsDealCard", @"
if(window.MauBinhController?.isDealCard)
{
return true;
}
else
{
return false;
}
" },
{ "GetCards", @"let serverCodes = [];
for(let i = 0; i < 13; i++)
serverCodes.push(MauBinhController._thisPlayerView.cards[i].serverCode);
return serverCodes;
" },
{ "SortCard", "MauBinhController.SapBai(arguments[0]);" },
{ "SortDone", "MauBinhController.onClickXepXong();" },
{ "BaoBinh", "MauBinhController.onClickBaoBinh();" }
}
},
},
});
}
static KeyValuePair<string, WebJsInjectData> web_hit_club()
{
return new KeyValuePair<string, WebJsInjectData>("web.hit.club", new WebJsInjectData()
{
AccountSource = AccountSource.May88,
GameType = GameType.MauBinh,
GameUrlFormat = new Dictionary<GameType, string>()
{
{ GameType.MauBinh, "https://web.hit.club/?a=BC114103&app_id=B52&token={token}&gameid=vgcg_4" },
},
Replaces = new List<WebJsInjectDataReplaceRegion>()
{
new WebJsInjectDataReplaceRegion()
{
ReplaceJsStart = "MauBinhController:[function(t,e,i)",
ReplaceJsEnd = "MauBinhMessage:[function(t,e,i)",
ReplaceList = new Dictionary<string, string>()
{
{
"",
""
},
},
},
},
MethodList = new()
{
{
GameType.MauBinh,
new()
{
{ "GetIsDealCard", @"" },
{ "GetCards", @"" },
{ "SortCard", "" },
{ "SortDone", "" },
{ "BaoBinh", "" }
}
},
},
});
}
public static IEnumerable<KeyValuePair<string, WebJsInjectData>> GenerateDefaultSupport()
{
yield return games_gnightfast_net();
yield return games_prorichvip_com();
yield return gamebai_b5richkids_net();
yield return i_b52_club();
}
}
}
@tqk2811
Copy link
Author

tqk2811 commented May 12, 2025

NuGet\Install-Package TqkLibrary.Proxy -Version 1.0.0-build20240727163214

@tqk2811
Copy link
Author

tqk2811 commented May 12, 2025

use

        #region Proxy
        ProxyServer? _proxyServer = null;
        MyHttpProxyServerHandler? _myHttpProxyServerHandler = null;
        protected string WrapperProxy(string? proxy = null)
        {
            _myHttpProxyServerHandler = new MyHttpProxyServerHandler(Singleton.Setting.Data.WebJsInjectDatas, proxy);
            _proxyServer = new ProxyServer(IPEndPoint.Parse("127.0.0.1:0"), _myHttpProxyServerHandler);
            _proxyServer.StartListen();
            return $"127.0.0.1:{_proxyServer.IPEndPoint!.Port}";
        }
        public void SetProxy(string? proxy = null)
        {
            _myHttpProxyServerHandler?.SetProxy(proxy);
            _proxyServer?.ShutdownCurrentConnection();
        }
        void ClearWrapperProxy()
        {
            _myHttpProxyServerHandler = null;
            _proxyServer?.StopListen();
            _proxyServer?.Dispose();
            _proxyServer = null;
        }
        #endregion
            string wrapperProxy = WrapperProxy(proxy);
            arguments.Add($"--proxy-server=http://{wrapperProxy}");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment