* Sends HTML file * @param {string} text * @param {string} id
(text, id)
| 383 | * @param {string} id |
| 384 | */ |
| 385 | function sendHTML(text, id) { |
| 386 | const js = `<!-- Injected code, this is not present in original code --><meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 387 | <script class="${uuid}" src="/${CONSOLE_SCRIPT}" crossorigin="anonymous"></script> |
| 388 | <script class="${uuid}"> |
| 389 | if(window.eruda){ |
| 390 | eruda.init({ |
| 391 | theme: 'dark' |
| 392 | }); |
| 393 | |
| 394 | ${ |
| 395 | target === "inapp" |
| 396 | ? "eruda._shadowRoot.querySelector('.eruda-entry-btn').style.display = 'none';" |
| 397 | : "" |
| 398 | } |
| 399 | |
| 400 | sessionStorage.setItem('__console_available', true); |
| 401 | document.addEventListener('showconsole', function () {eruda.show()}); |
| 402 | document.addEventListener('hideconsole', function () {eruda.hide()}); |
| 403 | }else if(document.querySelector('c-toggler')){ |
| 404 | ${ |
| 405 | target === "inapp" || |
| 406 | (target !== "inapp" && !appSettings.value.showConsoleToggler) |
| 407 | ? "document.querySelector('c-toggler').style.display = 'none';" |
| 408 | : "" |
| 409 | } |
| 410 | } |
| 411 | setTimeout(function(){ |
| 412 | var scripts = document.querySelectorAll('.${uuid}'); |
| 413 | scripts.forEach(function(el){document.head.removeChild(el)}); |
| 414 | }, 0); |
| 415 | </script><!-- Injected code, this is not present in original code -->`; |
| 416 | text = text.replace(/><\/script>/g, ' crossorigin="anonymous"></script>'); |
| 417 | const part = text.split("<head>"); |
| 418 | if (part.length === 2) { |
| 419 | text = `${part[0]}<head>${js}${part[1]}`; |
| 420 | } else if (/<html>/i.test(text)) { |
| 421 | text = text.replace("<html>", `<html><head>${js}</head>`); |
| 422 | } else { |
| 423 | text = `<head>${js}</head>` + text; |
| 424 | } |
| 425 | sendText(text, id); |
| 426 | } |
| 427 | |
| 428 | /** |
| 429 | * Sends file |
no test coverage detected