Initial commit

This commit is contained in:
s4luorth
2026-02-07 13:04:04 +01:00
commit 5e0fceab15
82 changed files with 30348 additions and 0 deletions

View File

@@ -0,0 +1,198 @@
/**
* Scriptalizer Separator Test
* Tests which separator character survives Scriptalizer API processing
*/
const https = require('https');
const { parseStringPromise } = require('xml2js');
const LICENSE_KEY = 'f9918b40-d11c-11f0-b558-0800200c9a66';
// Test different separators
const SEPARATORS = [
{ name: 'Triple Pipe', value: '|||' },
{ name: 'Triple Tilde', value: '~~~' },
{ name: 'Triple Hash', value: '###' },
{ name: 'Paragraph Signs', value: '§§§' },
{ name: 'Double Pipe', value: '||' },
{ name: 'Custom Marker', value: '___SKRIFT___' },
{ name: 'Newline + Dashes', value: '\n---\n' },
];
async function callScriptalizer(inputText) {
return new Promise((resolve, reject) => {
// Use x-www-form-urlencoded format
const params = new URLSearchParams();
params.append('LicenseKey', LICENSE_KEY);
params.append('FontName', 'PremiumUltra79');
params.append('ErrFrequency', '10');
params.append('InputText', inputText);
const body = params.toString();
const options = {
hostname: 'www.scriptalizer.co.uk',
port: 443,
path: '/QuantumScriptalize.asmx/Scriptalize',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
'Content-Length': Buffer.byteLength(body)
}
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', async () => {
try {
const result = await parseStringPromise(data, { explicitArray: false });
const response = result.ScriptalizerResponse;
if (!response || response.Status !== 'OK') {
reject(new Error(response?.Status || 'UNKNOWN_STATUS'));
return;
}
resolve({ status: 'OK', outputText: response.OutputText });
} catch (err) {
reject(err);
}
});
});
req.on('error', (err) => {
reject(err);
});
req.write(body);
req.end();
});
}
async function testSeparator(separator) {
console.log(`\n${'='.repeat(60)}`);
console.log(`Testing: ${separator.name} (${JSON.stringify(separator.value)})`);
console.log('='.repeat(60));
// Create test input with 3 short texts separated by the separator
const texts = [
'Hallo Max Mustermann aus Berlin',
'Liebe Anna Schmidt aus München',
'Sehr geehrter Tom Weber aus Hamburg'
];
const inputText = texts.join(separator.value);
console.log('\nInput:');
console.log(inputText.substring(0, 150));
console.log(`\nSeparator appears: ${(inputText.match(new RegExp(separator.value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g')) || []).length} times`);
try {
const result = await callScriptalizer(inputText);
console.log('\nOutput (first 200 chars):');
console.log(result.outputText.substring(0, 200) + '...');
// Check if separator survived
const separatorRegex = new RegExp(separator.value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g');
const separatorCount = (result.outputText.match(separatorRegex) || []).length;
console.log(`\nSeparator found in output: ${separatorCount} times`);
if (separatorCount === 2) {
console.log('✅ SUCCESS: Separator survived!');
// Try to split
const split = result.outputText.split(separator.value);
console.log(`\nSplit result: ${split.length} parts`);
if (split.length === 3) {
console.log('✅ PERFECT: Can split into 3 parts!');
console.log('\nPart 1 (first 50 chars):', split[0].substring(0, 50) + '...');
console.log('Part 2 (first 50 chars):', split[1].substring(0, 50) + '...');
console.log('Part 3 (first 50 chars):', split[2].substring(0, 50) + '...');
return { separator: separator.name, value: separator.value, success: true, split: true };
} else {
console.log('⚠️ WARNING: Split count mismatch');
return { separator: separator.name, value: separator.value, success: true, split: false };
}
} else {
console.log('❌ FAILED: Separator was modified or not found');
return { separator: separator.name, value: separator.value, success: false, found: separatorCount };
}
} catch (err) {
console.log(`\n❌ ERROR: ${err.message}`);
return { separator: separator.name, value: separator.value, success: false, error: err.message };
}
}
async function runTests() {
console.log('╔════════════════════════════════════════════════════════════╗');
console.log('║ Scriptalizer Separator Test Suite ║');
console.log('║ Testing which separator survives API processing ║');
console.log('╚════════════════════════════════════════════════════════════╝');
const results = [];
for (const separator of SEPARATORS) {
const result = await testSeparator(separator);
results.push(result);
// Wait 2 seconds between tests to avoid rate limiting
if (separator !== SEPARATORS[SEPARATORS.length - 1]) {
console.log('\nWaiting 2 seconds before next test...');
await new Promise(resolve => setTimeout(resolve, 2000));
}
}
// Summary
console.log('\n\n' + '═'.repeat(60));
console.log('SUMMARY');
console.log('═'.repeat(60));
const successful = results.filter(r => r.success && r.split);
const partial = results.filter(r => r.success && !r.split);
const failed = results.filter(r => !r.success);
console.log('\n✅ Fully Working Separators (can split):');
if (successful.length === 0) {
console.log(' None');
} else {
successful.forEach(r => console.log(` - ${r.separator} (${JSON.stringify(r.value)})`));
}
console.log('\n⚠ Partially Working Separators (found but cannot split):');
if (partial.length === 0) {
console.log(' None');
} else {
partial.forEach(r => console.log(` - ${r.separator}`));
}
console.log('\n❌ Failed Separators:');
if (failed.length === 0) {
console.log(' None');
} else {
failed.forEach(r => console.log(` - ${r.separator} (${r.error || 'modified by API'})`));
}
console.log('\n' + '═'.repeat(60));
if (successful.length > 0) {
console.log(`\n🎉 RECOMMENDATION: Use "${successful[0].separator}" as separator`);
console.log(` Separator value: ${JSON.stringify(successful[0].value)}`);
} else if (partial.length > 0) {
console.log(`\n⚠️ RECOMMENDATION: Use "${partial[0].separator}" but verify split logic`);
} else {
console.log('\n❌ No separator worked - need to use individual API calls');
}
}
// Run tests
runTests().catch(console.error);