-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
filter-for-unsaved.js
executable file
·41 lines (32 loc) · 1.15 KB
/
filter-for-unsaved.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
40
41
#!/usr/bin/env node
// TODO: Save these scripts somewhere useful:
// BUILDHASH='TODO'; ./scripts/buildmanifest-to-json.js "$BUILDHASH" --extract-urls | ./filter-for-unsaved.js | pbcopy
// pbpaste | ./filter-for-unsaved.js | pbcopy
const fs = require('fs');
const path = require('path');
const readline = require('readline');
const basePath = path.join(__dirname, '..', 'orig');
// Define URL prefix
const oldUrlPrefix = 'https://chat.openai.com/';
const urlPrefix = 'https://cdn.oaistatic.com/';
// Define a set to store all output URLs
let outputUrls = new Set();
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', function(rawInputPath) {
const filePath = rawInputPath.trim().replace(oldUrlPrefix, '').replace(urlPrefix, '');
const fullPath = path.join(basePath, filePath);
const outputUrl = `${urlPrefix}${filePath}`;
// Check if the URL has already been output
if (!outputUrls.has(outputUrl)) {
// check if file does not exist
if (!fs.existsSync(fullPath)) {
console.log(outputUrl);
// Add the URL to the set
outputUrls.add(outputUrl);
}
}
});