notify: escapeHtml for titles
This commit is contained in:
parent
f8932af2a1
commit
72a61458fc
4 changed files with 12 additions and 11 deletions
|
|
@ -2,7 +2,7 @@ import { firefox } from 'playwright'; // stealth plugin needs no outdated playwr
|
||||||
import { authenticator } from 'otplib';
|
import { authenticator } from 'otplib';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { existsSync, writeFileSync } from 'fs';
|
import { existsSync, writeFileSync } from 'fs';
|
||||||
import { dirs, jsonDb, datetime, stealth, filenamify, notify } from './util.js';
|
import { dirs, jsonDb, datetime, stealth, filenamify, notify, html_game_list } from './util.js';
|
||||||
import { cfg } from './config.js';
|
import { cfg } from './config.js';
|
||||||
|
|
||||||
import prompts from 'prompts'; // alternatives: enquirer, inquirer
|
import prompts from 'prompts'; // alternatives: enquirer, inquirer
|
||||||
|
|
@ -199,8 +199,7 @@ try {
|
||||||
} finally {
|
} finally {
|
||||||
await db.write(); // write out json db
|
await db.write(); // write out json db
|
||||||
if (notify_games.filter(g => g.status != 'existed').length) { // don't notify if all were already claimed; TODO don't notify if killed?
|
if (notify_games.filter(g => g.status != 'existed').length) { // don't notify if all were already claimed; TODO don't notify if killed?
|
||||||
const list = notify_games.map(g => `- <a href="${g.url}">${g.title}</a> (${g.status})`).join('<br>');
|
notify(`epic-games:<br>${html_game_list(notify_games)}`);
|
||||||
notify(`epic-games:<br>${list}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await writeFileSync(path.resolve(dirs.browser, 'cookies.json'), JSON.stringify(await context.cookies()));
|
await writeFileSync(path.resolve(dirs.browser, 'cookies.json'), JSON.stringify(await context.cookies()));
|
||||||
|
|
|
||||||
5
gog.js
5
gog.js
|
|
@ -1,6 +1,6 @@
|
||||||
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
|
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { dirs, jsonDb, datetime, filenamify, notify } from './util.js';
|
import { dirs, jsonDb, datetime, filenamify, notify, html_game_list } from './util.js';
|
||||||
import { cfg } from './config.js';
|
import { cfg } from './config.js';
|
||||||
|
|
||||||
import prompts from 'prompts'; // alternatives: enquirer, inquirer
|
import prompts from 'prompts'; // alternatives: enquirer, inquirer
|
||||||
|
|
@ -127,8 +127,7 @@ try {
|
||||||
} finally {
|
} finally {
|
||||||
await db.write(); // write out json db
|
await db.write(); // write out json db
|
||||||
if (notify_games.filter(g => g.status != 'existed').length) { // don't notify if all were already claimed; TODO don't notify if killed?
|
if (notify_games.filter(g => g.status != 'existed').length) { // don't notify if all were already claimed; TODO don't notify if killed?
|
||||||
const list = notify_games.map(g => `- <a href="${g.url}">${g.title}</a> (${g.status})`).join('<br>');
|
notify(`gog:<br>${html_game_list(notify_games)}`);
|
||||||
notify(`gog:<br>${list}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await context.close();
|
await context.close();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
|
import { firefox } from 'playwright'; // stealth plugin needs no outdated playwright-extra
|
||||||
import { authenticator } from 'otplib';
|
import { authenticator } from 'otplib';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { dirs, jsonDb, datetime, stealth, filenamify, notify } from './util.js';
|
import { dirs, jsonDb, datetime, stealth, filenamify, notify, html_game_list } from './util.js';
|
||||||
import { cfg } from './config.js';
|
import { cfg } from './config.js';
|
||||||
|
|
||||||
import prompts from 'prompts'; // alternatives: enquirer, inquirer
|
import prompts from 'prompts'; // alternatives: enquirer, inquirer
|
||||||
|
|
@ -182,8 +182,7 @@ try {
|
||||||
} finally {
|
} finally {
|
||||||
await db.write(); // write out json db
|
await db.write(); // write out json db
|
||||||
if (notify_games.length) { // list should only include claimed games
|
if (notify_games.length) { // list should only include claimed games
|
||||||
const list = notify_games.map(g => `- <a href="${g.url}">${g.title}</a> (${g.status})`).join('<br>');
|
notify(`prime-gaming:<br>${html_game_list(notify_games)}`);
|
||||||
notify(`prime-gaming:<br>${list}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await context.close();
|
await context.close();
|
||||||
|
|
|
||||||
4
util.js
4
util.js
|
|
@ -95,3 +95,7 @@ export const notify = (html) => {
|
||||||
if (stdout) console.log(`stdout: ${stdout}`);
|
if (stdout) console.log(`stdout: ${stdout}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const escapeHtml = (unsafe) => unsafe.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>').replaceAll('"', '"').replaceAll("'", ''');
|
||||||
|
|
||||||
|
export const html_game_list = games => games.map(g => `- <a href="${g.url}">${escapeHtml(g.title)}</a> (${g.status})`).join('<br>');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue