I am unable to download javascript from React without build [closed]

I have created a Pricing Page generator in React using shadcn and framer-motion. In this, There is an edit button and one can click on edit button and edit any text he want in the page, add more plans and features etc. Also there is an Export button to download html, css and javascript code in 3 separate files which can be added to website to display pricing. I can work with getting rendered html and css code from the the page but I could not find a solution for downloading javascript code.
I want to be able to javascript code too that it required for some functionalities like tooltips and switching between monthly and yearly pricing. I want only required javascript code without editing functionality.
You can see the live demo here
https://advanced-pricing-table.vercel.app/

You can see the Github respiratory here.
https://github.com/zahidlatifdev/advanced-pricing-table

Here is my Export Handler code. I haven’t added code for js download because I could figure out how to do it.

import React from 'react';

const exportPricingPage = () => {
    const htmlContent = generateHTML();
    const cssContent = generateCSS();

    downloadFile('pricing-page.html', htmlContent);
    downloadFile('pricing-page.css', cssContent);
};

const downloadFile = (filename, content) => {
    const element = document.createElement('a');
    element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(content));
    element.setAttribute('download', filename);
    element.style.display = 'none';
    document.body.appendChild(element);
    element.click();
    document.body.removeChild(element);
};

// Capture the current HTML code by getting the body content of the rendered page and removing unwanted buttons
const generateHTML = () => {
    const clonedDocument = document.documentElement.cloneNode(true); // Clone the entire document to manipulate it
    const exportSection = clonedDocument.querySelector('#export'); // Assuming #exportButton is the ID for the expor

    // Remove export and edit buttons if they exist
    if (exportSection) exportSection.remove();

    // Return the modified HTML content
    return clonedDocument.outerHTML;
};

// Capture the current CSS styles applied on the page
const generateCSS = () => {
    let css = '';
    const styleSheets = document.styleSheets;

    for (let i = 0; i < styleSheets.length; i++) {
        const sheet = styleSheets[i];
        try {
            const rules = sheet.cssRules || sheet.rules; // Get the CSS rules

            for (let j = 0; j < rules.length; j++) {
                css += rules[j].cssText + 'n'; // Combine all the CSS rules
            }
        } catch (e) {
            console.warn("Couldn't access some CSS rules due to CORS policy");
        }
    }
    return css;
};

export default exportPricingPage;

Apart from this feature, any suggestions about improving the code and page is really appreciated.

I tried getting html and css code and I know I could deal with that but only the javascript part I could not understand.

0

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật