| 588 | } |
| 589 | |
| 590 | function classifyScript(script: InternalScript, regexTags: string[]): string { |
| 591 | const replaceStr = script.replaceString || ''; |
| 592 | const findRegex = script.findRegex || ''; |
| 593 | |
| 594 | if (replaceStr.length > 500 && (replaceStr.includes('<div') || replaceStr.includes('<style'))) { |
| 595 | return 'layout'; |
| 596 | } |
| 597 | if (/< \w+>.*\[\^.*\]/.test(findRegex) && replaceStr.includes('<img src=')) { |
| 598 | return 'image-open'; |
| 599 | } |
| 600 | if (/<\/\w+>/.test(findRegex) && replaceStr.includes('style=')) { |
| 601 | return 'image-close'; |
| 602 | } |
| 603 | if ( |
| 604 | regexTags.some((t) => ['ch1', 'ch2', 'um1', 'um2', 'pl1', 'pl2'].includes(t)) && |
| 605 | replaceStr.includes('border-radius') |
| 606 | ) { |
| 607 | return 'chat-bubble'; |
| 608 | } |
| 609 | if (replaceStr.includes('<span') || replaceStr.includes('<br>')) { |
| 610 | return 'formatting'; |
| 611 | } |
| 612 | return 'transform'; |
| 613 | } |
| 614 | |
| 615 | function normalizeScripts( |
| 616 | rawScripts: InternalScript[], |