-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpen in Archive.js
39 lines (33 loc) · 1.24 KB
/
Open in Archive.js
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
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-blue; icon-glyph: archive;
// share-sheet-inputs: plain-text, url;
// @ts-ignore
// eslint-disable-next-line
try { require; } catch(e) { require = importModule; }
const { getInput, string, open, paste } = require('./lib/lib.js');
const main = async () => {
const input = await getInput({
name: 'Open in Archive',
help: 'Opens a page on an internet archive service.',
inScriptable: true,
args: [{
name: 'url',
shortName: 'u',
type: 'string',
share: true,
help: 'A URL to open on an internet archive.'
}]
});
if (!input) { return; }
const date = new Date();
const dateStr = date.getFullYear() + '.' +
(date.getMonth() + 1).toString().padStart(2, '0') + '.' +
date.getDate().toString().padStart(2, '0') + '-' +
date.getHours().toString().padStart(2, '0') + ':' +
date.getMinutes().toString().padStart(2, '0') + ':' +
date.getSeconds().toString().padStart(2, '0');
const url = string(input.url) || paste();
open(`https://archive.is/${dateStr}/${encodeURIComponent(url)}`);
};
main();