-
Notifications
You must be signed in to change notification settings - Fork 0
/
replay.html
69 lines (69 loc) · 1.92 KB
/
replay.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<script type="text/javascript" src="extra.js"></script>
<script type="text/javascript">
let xtra;
let proxyUrl=new URL("http://127.0.0.1:8080/");
let target, frame, framePath;
let cookies={};
const tunnel=(url)=>
{
if (!url) return "";
if (url.includes(proxyUrl.href)) url=url.substring(proxyUrl.href.length);
let targetUrl;
try
{
targetUrl=new URL(url);
}
catch(error)
{
targetUrl=new URL(url, framePath.origin);
}
return proxyUrl.href+targetUrl.href;
}
const loadTarget=(url)=>
{
if (url)
{
url=tunnel(url);
let destination=url.includes(proxyUrl.href)?url.substring(proxyUrl.href.length):url;
target.value=destination;
}
else url=tunnel(target.value);
document.cookie=`proxyTargetHref=${target.value}; path=/`;
frame.src=url;
}
window.addEventListener("load", (event)=>
{
target=document.getElementById("targetHref");
frame=document.getElementById("frame");
frame.addEventListener("load", (event)=>
{
if (!frame.contentDocument) return null;
console.log(`loaded ${frame.contentDocument.location.href}`);
framePath=new URL(frame.contentWindow.location.href.substring(proxyUrl.href.length));
frame.contentDocument.addEventListener("click", (event)=>
{
let link=event.target.closest("a");
let form=event.target.closest("form");
if (link && link.href) link.href=tunnel(link.href);
if (form) form.action=tunnel(form.getAttribute("action"));
});
var oldAjaxOpen = frame.contentWindow.XMLHttpRequest.prototype.open;
frame.contentWindow.XMLHttpRequest.prototype.open = function()
{
if (arguments[1]) arguments[1]=tunnel(arguments[1]);
return oldAjaxOpen.apply(this, arguments);
};
});
});
</script>
</head>
<body>
<input type="text" id="targetHref" placeholder="website url" value="https://emag.ro">
<button type="button" onclick="loadTarget()">Change Content</button>
<div>
<iframe id="frame" style="width: 100vw; height: 90vh;"></iframe>
</div>
</body>
</html>