forked from Public-Mirror/Textractor
using new api
This commit is contained in:
parent
e826801c87
commit
146afdc926
@ -116,7 +116,7 @@ std::wstring Translate(const std::wstring& text, std::wstring translateFrom, std
|
|||||||
|
|
||||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||||
{
|
{
|
||||||
if (sentenceInfo["hook address"] == -1) return false;
|
if (sentenceInfo["text number"] == 0) return false;
|
||||||
|
|
||||||
static RateLimiter rateLimiter(30, 60 * 1000);
|
static RateLimiter rateLimiter(30, 60 * 1000);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ struct SentenceInfo
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static InfoForExtension DUMMY[2] = { { "hook address", 0 } };
|
inline static InfoForExtension DUMMY[2] = { { "text number", 1 } };
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SKIP {};
|
struct SKIP {};
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||||
{
|
{
|
||||||
if (sentenceInfo["hook address"] == -1) return false;
|
if (sentenceInfo["text number"] == 0) return false;
|
||||||
sentence += L"\n";
|
sentence += L"\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ std::wstring GetTranslationUri(const std::wstring& text, unsigned TKK)
|
|||||||
|
|
||||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||||
{
|
{
|
||||||
if (sentenceInfo["hook address"] == -1) return false;
|
if (sentenceInfo["text number"] == 0) return false;
|
||||||
|
|
||||||
static std::atomic<HINTERNET> internet = NULL;
|
static std::atomic<HINTERNET> internet = NULL;
|
||||||
if (!internet) internet = WinHttpOpen(L"Mozilla/5.0 Textractor", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, NULL, NULL, 0);
|
if (!internet) internet = WinHttpOpen(L"Mozilla/5.0 Textractor", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, NULL, NULL, 0);
|
||||||
|
@ -64,7 +64,7 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
|
|||||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||||
{
|
{
|
||||||
std::shared_lock l(m);
|
std::shared_lock l(m);
|
||||||
if (window == nullptr || sentenceInfo["hook address"] == -1) return false;
|
if (window == nullptr || sentenceInfo["text number"] == 0) return false;
|
||||||
sentence = std::regex_replace(sentence, regex, L"");
|
sentence = std::regex_replace(sentence, regex, L"");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ remove:
|
|||||||
|
|
||||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||||
{
|
{
|
||||||
if (sentenceInfo["hook address"] == -1) return false;
|
if (sentenceInfo["text number"] == 0) return false;
|
||||||
RemoveRepeatedChars(sentence);
|
RemoveRepeatedChars(sentence);
|
||||||
RemoveCyclicRepeats(sentence);
|
RemoveCyclicRepeats(sentence);
|
||||||
return true;
|
return true;
|
||||||
|
@ -15,9 +15,9 @@ public:
|
|||||||
void Put(std::wstring original, std::wstring replacement)
|
void Put(std::wstring original, std::wstring replacement)
|
||||||
{
|
{
|
||||||
Node* current = &root;
|
Node* current = &root;
|
||||||
for (auto c : original)
|
for (auto ch : original)
|
||||||
if (Ignore(c));
|
if (Ignore(ch));
|
||||||
else if (auto& next = current->next[c]) current = next.get();
|
else if (auto& next = current->next[ch]) current = next.get();
|
||||||
else current = (next = std::make_unique<Node>()).get();
|
else current = (next = std::make_unique<Node>()).get();
|
||||||
if (current != &root) current->value = replacement;
|
if (current != &root) current->value = replacement;
|
||||||
}
|
}
|
||||||
@ -26,17 +26,17 @@ public:
|
|||||||
{
|
{
|
||||||
int length = 0;
|
int length = 0;
|
||||||
Node* current = &root;
|
Node* current = &root;
|
||||||
for (auto c : text)
|
for (auto ch : text)
|
||||||
if (Ignore(c)) ++length;
|
if (Ignore(ch)) ++length;
|
||||||
else if (auto& next = current->next[c]) ++length, current = next.get();
|
else if (auto& next = current->next[ch]) ++length, current = next.get();
|
||||||
else break;
|
else break;
|
||||||
return { length, current->value };
|
return { length, current->value };
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool Ignore(wchar_t c)
|
static bool Ignore(wchar_t ch)
|
||||||
{
|
{
|
||||||
return c <= 0x20 || std::iswspace(c);
|
return ch <= 0x20 || std::iswspace(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Node
|
struct Node
|
||||||
|
Loading…
x
Reference in New Issue
Block a user