23 lines
840 B
JavaScript
23 lines
840 B
JavaScript
const fs = require('fs');
|
|
const path = 'm:/OFICIAIS E FUNCIONANDO/STEELBASE/js/sections/perfis-catalog.js';
|
|
let c = fs.readFileSync(path, 'utf8');
|
|
|
|
// Unescape some mangled ones
|
|
c = c.replace(/\\`/g, '`');
|
|
|
|
// Match <script> tags inside functions and Extract them out of the return ` ... `
|
|
// but after the function.
|
|
|
|
// 1. Find 'return ` ... <script> ... </script> ... `;'
|
|
// 2. Replace with 'return ` ... ... `; <script logic> ...'
|
|
|
|
// But a simpler way: just REMOVE the <script> and </script> tags ONLY if they are inside return ` ... `;
|
|
// and keep the content.
|
|
|
|
c = c.replace(/return\s+`([\s\S]*?)<script>([\s\S]*?)<\/script>([\s\S]*?)`;/gs, (match, before, script, after) => {
|
|
return 'return `' + before + after + '`; \n\n' + script + '\n\n';
|
|
});
|
|
|
|
fs.writeFileSync(path, c);
|
|
console.log('Unwrapped scripts in perfis-catalog.js');
|