Porządki
This commit is contained in:
24
scripts/extract.js
Normal file
24
scripts/extract.js
Normal file
@@ -0,0 +1,24 @@
|
||||
const fs = require('fs');
|
||||
const html = fs.readFileSync('public/stolik2_api.html', 'utf8');
|
||||
|
||||
// Match first style and script tags
|
||||
const cssMatch = html.match(/<style>([\s\S]*?)<\/style>/);
|
||||
const jsMatch = html.match(/<script>([\s\S]*?)<\/script>/);
|
||||
|
||||
if(cssMatch) {
|
||||
fs.writeFileSync('public/assets/css/stolik2_api.css', cssMatch[1].trim());
|
||||
}
|
||||
if(jsMatch) {
|
||||
fs.writeFileSync('public/assets/js/stolik2_api.js', jsMatch[1].trim());
|
||||
}
|
||||
|
||||
let newHtml = html;
|
||||
if(cssMatch) {
|
||||
newHtml = newHtml.replace(/<style>[\s\S]*?<\/style>/, '<link rel="stylesheet" href="assets/css/stolik2_api.css">');
|
||||
}
|
||||
if(jsMatch) {
|
||||
newHtml = newHtml.replace(/<script>[\s\S]*?<\/script>/, '<script src="assets/js/stolik2_api.js"></script>');
|
||||
}
|
||||
|
||||
fs.writeFileSync('public/stolik2_api.html', newHtml);
|
||||
console.log("Extraction complete.");
|
||||
Reference in New Issue
Block a user