mirror of
https://github.com/QuiteAFancyEmerald/Holy-Unblocker.git
synced 2025-05-13 12:00:02 -04:00
Added Corrosion Fix for Heroku
Credits: https://github.com/BinBashBanana/Corrosion-Heroku (very epic person)
This commit is contained in:
parent
8d88daf1c2
commit
b0c48df26c
25 changed files with 13 additions and 10 deletions
|
@ -1,36 +0,0 @@
|
|||
const route = [
|
||||
{
|
||||
types: ['text/html'],
|
||||
handler: 'html',
|
||||
},
|
||||
{
|
||||
types: ['text/css'],
|
||||
handler: 'css',
|
||||
},
|
||||
{
|
||||
types: ['application/javascript', 'application/x-javascript', 'text/javascript', 'text/x-javascript'],
|
||||
handler: 'js',
|
||||
},
|
||||
]
|
||||
function rewriteBody(ctx) {
|
||||
if (!ctx.body || !ctx.remoteResponse || ctx.flags.includes('xhr')) return;
|
||||
const meta = {
|
||||
base: ctx.url,
|
||||
origin: ctx.origin,
|
||||
};
|
||||
const data = route.find(entry => ctx.flags == entry.handler) || route.find(entry => entry.types.includes((ctx.headers['content-type'] || '').split(';')[0])) || {};
|
||||
|
||||
switch(data.handler) {
|
||||
case 'html':
|
||||
ctx.body = ctx.rewrite.html.process(ctx.body.toString(), { ...meta, document: true });
|
||||
break;
|
||||
case 'css':
|
||||
ctx.body = ctx.rewrite.css.process(ctx.body.toString(), meta);
|
||||
break;
|
||||
case 'js':
|
||||
ctx.body = ctx.rewrite.js.process(ctx.body.toString(), ctx.url);
|
||||
break;
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = rewriteBody;
|
Loading…
Add table
Add a link
Reference in a new issue