diff --git a/templates/assets/js/curl.js b/templates/assets/js/curl.js index 026151e..d013e91 100644 --- a/templates/assets/js/curl.js +++ b/templates/assets/js/curl.js @@ -69,6 +69,9 @@ document.addEventListener('DOMContentLoaded', function () {

Result for ${escapeHtml(url)}

+ @@ -84,6 +87,7 @@ document.addEventListener('DOMContentLoaded', function () { // Get reference to the iframe and buttons const iframe = document.getElementById('result-iframe'); const viewSourceButton = document.getElementById('view-source'); + const newTabButton = document.getElementById('new-tab'); const cleanedHtml = removeScripts(data.result); @@ -93,6 +97,7 @@ document.addEventListener('DOMContentLoaded', function () { // Set the iframe src to the blob URL iframe.src = blobUrl; + // Add event listener to view source button viewSourceButton.addEventListener('click', function () { @@ -113,6 +118,15 @@ document.addEventListener('DOMContentLoaded', function () { sourceWindow.document.close(); }); + // Add event listener to new tab button + newTabButton.addEventListener('click', function () { + // Get URL from window.location + const proxyurl = `${window.location.protocol}//${window.location.host}/proxy/${url}`; + + // Open host/proxy/url in new tab + window.open(proxyurl, '_blank'); + }); + // Set up cleanup when iframe is no longer needed window.addEventListener('beforeunload', function () { URL.revokeObjectURL(blobUrl); diff --git a/tools.py b/tools.py index 16882bf..1e97fe3 100644 --- a/tools.py +++ b/tools.py @@ -208,6 +208,13 @@ def proxy(url: str) -> requests.Response: def cleanProxyContent(htmlContent: str,url:str, proxyHost: str): + # Set proxy host to https if not 127.0.0.1 or localhost + if ":5000" not in proxyHost: + proxyHost = proxyHost.replace("http","https") + + + + # Find all instances of the url in the html hostUrl = f"{urlparse(url).scheme}://{urlparse(url).netloc}" proxyUrl = f"{proxyHost}proxy/{hostUrl}"