funny bit
This commit is contained in:
commit
725cae593c
3 changed files with 29 additions and 0 deletions
1
.nvmrc
Normal file
1
.nvmrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
lts/*
|
||||||
1
README.md
Normal file
1
README.md
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
terrible terrible terrible do not use this
|
||||||
27
fix.mjs
Normal file
27
fix.mjs
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import {createServer} from 'node:http';
|
||||||
|
|
||||||
|
const sites = [
|
||||||
|
{
|
||||||
|
pattern: /^(?:https?:\/\/)?(?:www\.)pixiv\.net\/\w+\/artworks\/(\d+)(?:#(\d+))?/i,
|
||||||
|
redirect: match => `https://pixiv.kmn5.li/${match[1]}${match[2] ? `_${parseInt(match[2], 10) - 1}` : ''}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern: /^(?:https?:\/\/)?(?:www\.)?(?:twitter\.com|x\.com)\/(.+)/,
|
||||||
|
redirect: match => `https://fxtwitter.com/${match[1]}`,
|
||||||
|
},
|
||||||
|
// idk send me more of these
|
||||||
|
];
|
||||||
|
|
||||||
|
createServer(async (request, response) => {
|
||||||
|
const error = () => response.writeHead(400).end('whar');
|
||||||
|
if (request.method !== 'GET') return error();
|
||||||
|
const input = request.url.slice(1);
|
||||||
|
console.log(input);
|
||||||
|
for (const site of sites) {
|
||||||
|
let match = input.match(site.pattern);
|
||||||
|
if (!match) continue;
|
||||||
|
response.writeHead(302, {'Location': site.redirect(match)}).end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return error();
|
||||||
|
}).listen(process.env.PORT || 80);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue