Looking through the code, I found the following methods interacting with archive.is - but there are some direct links available - I would like to know your opinion before I try to reinvent the wheel and create a PR to use the direct links:
Available Links - Documentation
1) Direct Link for Opening a URL
https://${workingHostname}/?run=1&url={url}
vs
https://${workingHostname}/latest/{url}
Benefit:
No need to perform the "is this an archive website"-check and simulate a click on the form:
|
{ |
|
hostname: 'archive', |
|
check: (doc, win) => { |
|
const input = doc.querySelector('#HEADER form input[name="q"]'); |
|
if (!input || !input.value) return false; |
|
|
|
let inputHostname |
|
try { |
|
const url = new URL(input.value) |
|
inputHostname = url.hostname |
|
} catch (err) { |
|
console.warn('Invalid URL in input:', input.value) |
|
return false |
|
} |
|
|
|
return sites.some(site => |
|
site.hostname !== 'archive' && |
|
inputHostname.includes(site.hostname) && |
|
site.check(doc, win) |
|
) |
|
}, |
2) Direct Link for History
https://${workingHostname}/{url}
No need to manually find the history URL — maybe just keep the check to see if multiple versions are available:
|
action: (doc, win) => { |
|
// Redirect to history of this page, if there is also a paywall in this archive |
|
// Only redirect once for this session |
|
const key = doc.location.href |
|
const alreadyRedirected = win.sessionStorage.getItem(key) |
|
const historyLink = Array.from(doc.querySelectorAll('#HEADER form a')) |
|
.find(e => e.textContent.includes('history')) |
|
|
|
if (!alreadyRedirected && historyLink) { |
|
win.sessionStorage.setItem(key, '1') |
|
historyLink.click() |
|
} |
3) Check for Working Hostname
As mentioned in the doc documentation links , the archive.today domain is used as a load balancer and always redirects to a working TLD.
Or is there another reason behind the "check for working hostname" - maybe it is more easy to always use the archive.today domain?
|
let workingHostname = null |
|
for (const hostname of hostnames) { |
|
try { |
|
window.setTimeout(() => showSpinner(hostname), 0) |
|
await checkAvailability(hostname) |
|
workingHostname = hostname |
|
break |
|
} catch (err) { |
|
if (err && 'message' in err && err.message === 'HOST_UNAVAILABLE') { |
|
console.debug(`${hostname} is NOT available`) |
|
} else { |
|
throw err |
|
} |
|
} |
|
} |
|
|
Looking through the code, I found the following methods interacting with archive.is - but there are some direct links available - I would like to know your opinion before I try to reinvent the wheel and create a PR to use the direct links:
Available Links - Documentation
1) Direct Link for Opening a URL
https://${workingHostname}/?run=1&url={url}vs
https://${workingHostname}/latest/{url}Benefit:
No need to perform the "is this an archive website"-check and simulate a click on the form:
Userscripts/others/Paywall redirect to Archive.today.user.js
Lines 296 to 316 in a8a1aac
2) Direct Link for History
https://${workingHostname}/{url}No need to manually find the history URL — maybe just keep the check to see if multiple versions are available:
Userscripts/others/Paywall redirect to Archive.today.user.js
Lines 317 to 328 in a8a1aac
3) Check for Working Hostname
As mentioned in the doc documentation links , the
archive.todaydomain is used as a load balancer and always redirects to a working TLD.Or is there another reason behind the "check for working hostname" - maybe it is more easy to always use the archive.today domain?
Userscripts/others/Paywall redirect to Archive.today.user.js
Lines 160 to 175 in a8a1aac