mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-11-30 17:15:38 +08:00
...
This commit is contained in:
parent
a3922d7ffb
commit
984cffba82
@ -293,7 +293,8 @@ int GetRandomAvailablePort()
|
|||||||
|
|
||||||
int makehttpgetserverinternal()
|
int makehttpgetserverinternal()
|
||||||
{
|
{
|
||||||
while (1)
|
// 尝试1000次
|
||||||
|
for (int i = 0; i < 1000; i++)
|
||||||
{
|
{
|
||||||
auto port = GetRandomAvailablePort();
|
auto port = GetRandomAvailablePort();
|
||||||
auto [succ, hReqQueue, ssID, urlGroupId] = makeserveronce(port);
|
auto [succ, hReqQueue, ssID, urlGroupId] = makeserveronce(port);
|
||||||
@ -310,6 +311,7 @@ int makehttpgetserverinternal()
|
|||||||
.detach();
|
.detach();
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
// int main()
|
// int main()
|
||||||
// {
|
// {
|
||||||
|
@ -323,6 +323,10 @@ namespace
|
|||||||
};
|
};
|
||||||
hp.filter_fun = [](void *data, size_t *len, HookParam *hp)
|
hp.filter_fun = [](void *data, size_t *len, HookParam *hp)
|
||||||
{
|
{
|
||||||
|
if (strstr((char *)data, R"(http://)") != 0)
|
||||||
|
return false;
|
||||||
|
if (strstr((char *)data, R"(https://)") != 0)
|
||||||
|
return false;
|
||||||
if (strstr((char *)data, R"(\\?\)") != 0)
|
if (strstr((char *)data, R"(\\?\)") != 0)
|
||||||
return false; // 过滤路径
|
return false; // 过滤路径
|
||||||
return true;
|
return true;
|
||||||
|
@ -25,76 +25,57 @@ function splitfonttext(transwithfont) {
|
|||||||
function syncquery(s) {
|
function syncquery(s) {
|
||||||
if (internal_http_port == 0) { throw new Error('') }
|
if (internal_http_port == 0) { throw new Error('') }
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', 'http://127.0.0.1:' + internal_http_port + '/fuck?' + s, false);
|
var url = 'http://127.0.0.1:' + internal_http_port + '/fuck?' + s
|
||||||
|
xhr.open('GET', url, false);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
if (xhr.status === 200) {
|
if (xhr.status === 200) {
|
||||||
return xhr.responseText;
|
return xhr.responseText;//解析这个会导致v8::String::Length的v8StringUtf8Length出现错误,但不影响。
|
||||||
} else {
|
} else {
|
||||||
throw new Error('')
|
throw new Error('')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
function isEmptyString(str) {
|
function makecomplexs(name, s_raw, lpsplit) {
|
||||||
return str === null || str === undefined || str.length == 0;
|
return magicsend + name + '\x03' + lpsplit.toString() + '\x02' + s_raw;
|
||||||
}
|
}
|
||||||
function clipboardsender(name, s_raw, lpsplit) {
|
function cppjsio(s) {
|
||||||
//magic split \x02 text
|
|
||||||
if (isEmptyString(s_raw))
|
|
||||||
return s_raw
|
|
||||||
s = magicsend + name + '\x03' + lpsplit.toString() + '\x02' + s_raw;
|
|
||||||
try {
|
try {
|
||||||
if (!is_useclipboard) { throw new Error('') }
|
return syncquery(s)
|
||||||
const _clipboard = require('nw.gui').Clipboard.get();
|
|
||||||
_clipboard.set(s, 'text');
|
|
||||||
transwithfont = _clipboard.get('text');
|
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
try {
|
try {
|
||||||
if (!is_useclipboard) { throw new Error('') }
|
if (!is_useclipboard) { throw new Error('') }
|
||||||
const clipboard = require('electron').clipboard;
|
const _clipboard = require('nw.gui').Clipboard.get();
|
||||||
clipboard.writeText(s);
|
_clipboard.set(s, 'text');
|
||||||
transwithfont = clipboard.readText();
|
return _clipboard.get('text');
|
||||||
}
|
}
|
||||||
catch (err2) {
|
catch (err2) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!is_useclipboard) { throw new Error('') }
|
||||||
transwithfont = syncquery(s)
|
const clipboard = require('electron').clipboard;
|
||||||
|
clipboard.writeText(s);
|
||||||
|
return clipboard.readText();
|
||||||
}
|
}
|
||||||
catch (err3) {
|
catch (err3) {
|
||||||
return s_raw;
|
return s_raw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
function clipboardsender(name, s_raw, lpsplit) {
|
||||||
|
//magic split \x02 text
|
||||||
|
if (!s_raw)
|
||||||
|
return s_raw
|
||||||
|
transwithfont = cppjsio(makecomplexs(name, s_raw, lpsplit))
|
||||||
if (transwithfont.length == 0) return s_raw;
|
if (transwithfont.length == 0) return s_raw;
|
||||||
return splitfonttext(transwithfont)
|
return splitfonttext(transwithfont)
|
||||||
}
|
}
|
||||||
|
|
||||||
function clipboardsender_only_send(name, s_raw, lpsplit) {
|
function clipboardsender_only_send(name, s_raw, lpsplit) {
|
||||||
//magic split \x02 text
|
//magic split \x02 text
|
||||||
if (isEmptyString(s_raw))
|
if (!s_raw)
|
||||||
return s_raw
|
return s_raw
|
||||||
s = magicsend + name + '\x03' + lpsplit.toString() + '\x02' + s_raw;
|
cppjsio(makecomplexs(name, s_raw, lpsplit))
|
||||||
try {
|
|
||||||
if (!is_useclipboard) { throw new Error('') }
|
|
||||||
const _clipboard = require('nw.gui').Clipboard.get();
|
|
||||||
_clipboard.set(s, 'text');
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
try {
|
|
||||||
if (!is_useclipboard) { throw new Error('') }
|
|
||||||
const clipboard = require('electron').clipboard;
|
|
||||||
clipboard.writeText(s);
|
|
||||||
}
|
|
||||||
catch (err2) {
|
|
||||||
try {
|
|
||||||
syncquery(s)
|
|
||||||
}
|
|
||||||
catch (err3) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function rpgmakerhook() {
|
function rpgmakerhook() {
|
||||||
|
|
||||||
@ -110,7 +91,7 @@ function rpgmakerhook() {
|
|||||||
Bitmap.prototype.origin_makeFontNameText = Bitmap.prototype._makeFontNameText;
|
Bitmap.prototype.origin_makeFontNameText = Bitmap.prototype._makeFontNameText;
|
||||||
}
|
}
|
||||||
Bitmap.prototype._makeFontNameText = function () {
|
Bitmap.prototype._makeFontNameText = function () {
|
||||||
if (fontface == '') return this.origin_makeFontNameText();
|
if (!fontface) return this.origin_makeFontNameText();
|
||||||
return (this.fontItalic ? 'Italic ' : '') +
|
return (this.fontItalic ? 'Italic ' : '') +
|
||||||
this.fontSize + 'px ' + fontface;
|
this.fontSize + 'px ' + fontface;
|
||||||
}
|
}
|
||||||
@ -170,7 +151,7 @@ function tyranohook() {
|
|||||||
tyrano.plugin.kag.tag.text.start = function (pm) {
|
tyrano.plugin.kag.tag.text.start = function (pm) {
|
||||||
if (1 != this.kag.stat.is_script && 1 != this.kag.stat.is_html) {
|
if (1 != this.kag.stat.is_script && 1 != this.kag.stat.is_html) {
|
||||||
pm.val = clipboardsender('tyranoscript', pm.val, 0);
|
pm.val = clipboardsender('tyranoscript', pm.val, 0);
|
||||||
if (fontface != '') {
|
if (fontface) {
|
||||||
this.kag.stat.font.face = fontface
|
this.kag.stat.font.face = fontface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user