47 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <!doctype html>
 | |
| <html lang="en">
 | |
|   <head>
 | |
|     <meta charset="UTF-8" />
 | |
|     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 | |
|     <title>MRC Scuba</title>
 | |
|   </head>
 | |
|   <body>
 | |
|     <div id="root"></div>
 | |
|     <script type="module" src="./src/main.jsx"></script>
 | |
|   </body>
 | |
|     <script> 
 | |
|     // dont judge me
 | |
| 
 | |
|     function isTableJSON(jsonString) {
 | |
|         try {
 | |
|             const parsed = JSON.parse(jsonString);                   
 | |
|             return parsed;
 | |
|         } catch (e) {
 | |
|             return false;
 | |
|         }
 | |
|     }
 | |
|     const copyToClipboard = (str) => {
 | |
|     const el = document.createElement("textarea");
 | |
|     el.value = str;
 | |
|     document.body.appendChild(el);
 | |
|       el.select();
 | |
|       document.execCommand("copy");
 | |
|       document.body.removeChild(el);
 | |
|     };
 | |
| 
 | |
|     window.addEventListener("message", (event) => {
 | |
|         if (event?.data?.type === "copytoclipboard") {
 | |
|             var str = event.data.text;
 | |
|             // str = JSON.parse(str);
 | |
|             console.log("copying to clipboard", isTableJSON(str));
 | |
|             if (isTableJSON(str)) {
 | |
|                 str = str.replace(/\[/g, '{');
 | |
|                 str = str.replace(/\]/g, '}');
 | |
|                 str = str.replace(/:/g, '=');
 | |
|                 str = str.replace(/"([^"]+)"=/g, '$1=');
 | |
|             }
 | |
|             copyToClipboard(str);
 | |
|         }        
 | |
|     });
 | |
|   </script>
 | |
| </html>
 | 
