refactor(invidious/nitter): combine commands. fix(config): spelling error

This commit is contained in:
vulet 2020-11-06 19:21:01 +08:00
parent 5ed4b932d5
commit f201637677
2 changed files with 12 additions and 2 deletions

View file

@ -18,8 +18,8 @@ module.exports = {
nitter: {
domain: 'nitter.net',
userAgent: 'Mozilla/4.0 (compatible; Beep Boop)',
domains: [ 'nitter.net', 'www.nitter.net', 'twitter.com', 'wwww.twitter.com' ],
check: '(✓)'
domains: [ 'nitter.net', 'www.nitter.net', 'twitter.com', 'www.twitter.com' ],
check: '()'
},
invidious: {
domain: 'invidious.fdn.fr',

10
main.js
View file

@ -72,6 +72,16 @@ let CreateClient = (token, user_id) => {
});
command = 'media';
break;
case 'proxy':
try {
const url = new URL(userInput);
command = registrar.config.invidious.domains.includes(url.hostname)
? 'invidious'
: registrar.config.nitter.domains.includes(url.hostname)
? 'nitter'
: 'proxy';
} catch(e) {}
//fallthrough
default:
args.push(matrixClient, room, userInput, registrar);
}