JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<!-- tidy essentials from https://archive.ph/2015.11.14-044109/http://www.example.org/ -->
<head>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td rowspan="6">
<div>archive.today</div>
<div>webpage capture</div>
</td>
<td>Saved from</td>
<td>
<form action="https://archive.fo/search/" method="get">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><input name="q" type="text" value="http://web.archive.org/web/20151114044109/http://www.example.org/" /><input name="t" type="hidden" value="1447631011200" /><input name="id" type="hidden" value="5iVVH" /></td>
<td><input tabindex="-1" type="submit" value="search" /></td>
</tr>
</tbody>
</table> <textarea name=""></textarea>
</form>
</td>
<td rowspan="2"><time datetime="2015-11-15T23:43:31Z">15 Nov 2015 23:43:31 UTC</time></td>
</tr>
<tr>
<td>Redirected from</td>
<td>
<div><input readonly="readonly" type="text" value="http://web.archive.org/web/2/example.org" /></div>
</td>
</tr>
<tr>
<td>Via</td>
<td>
<div><input readonly="readonly" type="text" value="http://www.example.org/" /></div>
</td>
<td><time datetime="2015-11-14T04:41:09Z">14 Nov 2015 04:41:09 UTC</time></td>
</tr>
<tr>
<td>Original</td>
<td>
<div><input readonly="readonly" type="text" value="http://example.org/" /></div>
</td>
<td><time datetime="2015-11-14T04:41:09Z">14 Nov 2015 04:41:09 UTC</time></td>
</tr>
</tbody>
</table>
</body>
</html>
JavaScript
// based on:
// - https://codereview.stackexchange.com/questions/167571/evaluating-an-xpath-with-document-evaluate-to-get-an-array-of-nodes
// - https://stackoverflow.com/questions/10596417/is-there-a-way-to-get-element-by-xpath-using-javascript-in-selenium-webdriver
// - https://developer.mozilla.org/en-US/docs/Web/XPath/Introduction_to_using_XPath_in_JavaScript
// - https://developer.mozilla.org/en-US/docs/Web/API/Document/evaluate#result_types
// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_OR
function getElementsByXPath(xpath, parent) { // use when expecting zero or more results; default value for parent is document
result = document.evaluate(xpath, parent || document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
nodes = []
while (node = result.iterateNext())
nodes.push(node);
return nodes;
}
function getElementByXPath(xpath, parent) { // use when expecting zero or one result; default value for parent is document
result = document.evaluate(xpath, parent || document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
return result.singleNodeValue;
}
function getArchiveIsInputValue(tdText) {
input = getElementByXPath(`/html/body//td[text()="${tdText}"]/following-sibling::td/div/input`);
return input?.value;
}
function getSavedFromValue() {
return document.getElementsByName("q")[0]?.value;
}
function getRedirectedFromValue() {
return getArchiveIsInputValue("Redirected from");
}
function getViaValue() {
return getArchiveIsInputValue("Via");
}
function getOriginalValue() {
return getArchiveIsInputValue("Original");
}
console.log("Saved from: "+getSavedFromValue());
console.log("Redirected from "+getRedirectedFromValue());
console.log("Via: "+getViaValue());
console.log("Original: "+getOriginalValue());