beep
This commit is contained in:
parent
725cae593c
commit
b9b71ebf56
1 changed files with 10 additions and 4 deletions
14
fix.mjs
14
fix.mjs
|
|
@ -2,11 +2,11 @@ import {createServer} from 'node:http';
|
|||
|
||||
const sites = [
|
||||
{
|
||||
pattern: /^(?:https?:\/\/)?(?:www\.)pixiv\.net\/\w+\/artworks\/(\d+)(?:#(\d+))?/i,
|
||||
pattern: /^(?: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)\/(.+)/,
|
||||
pattern: /^(?:www\.)?(?:twitter\.com|x\.com)\/(.+)/,
|
||||
redirect: match => `https://fxtwitter.com/${match[1]}`,
|
||||
},
|
||||
// idk send me more of these
|
||||
|
|
@ -15,8 +15,14 @@ const sites = [
|
|||
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);
|
||||
let input = request.url.slice(1); // leading slash
|
||||
if (input.startsWith('https://')) {
|
||||
input = input.slice(8);
|
||||
} else if (input.startsWith('http://')) {
|
||||
input = input.slice(7);
|
||||
} else if (!input) { // "homepage"
|
||||
return response.writeHead(301).end('https://git.ewin.moe/erin/fix-my-shit');
|
||||
}
|
||||
for (const site of sites) {
|
||||
let match = input.match(site.pattern);
|
||||
if (!match) continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue