Last active
April 1, 2024 01:55
-
-
Save Erisa/1ef4c1d5de643f8e13a61a7e69199795 to your computer and use it in GitHub Desktop.
Cloudflare Worker serving https://asi.re modifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener("fetch", event => { | |
event.respondWith(handleRequest(event.request)) | |
}) | |
async function handleRequest(request) { | |
let url = new URL(request.url) | |
let response = await fetch(request) | |
const contentType = response.headers.get('Content-Type'); | |
// if (url.pathname.includes(".css")) { | |
let body = await response.text() | |
body = body.replace("body{", "body{\n transform: rotate3d(0,1,0,180deg);") | |
const res = await fetch(url, request) | |
response = new Response(body, response) | |
if (contentType != null && contentType.startsWith('text/html')) { | |
return rewriter.transform(response); | |
} | |
return response; | |
} | |
class AttributeRewriter { | |
constructor(attributeName) { | |
this.attributeName = attributeName; | |
} | |
element(element) { | |
const attribute = element.getAttribute(this.attributeName); | |
const property = element.getAttribute("property") | |
if (property !== null && !property.includes("image") && attribute) { | |
element.setAttribute(this.attributeName, flipText(attribute)); | |
} else if (this.attributeName == '') { | |
element.setInnerContent(flipText('Erisa!!')) | |
console.log(element.attributes.next()) | |
//element.replace() | |
} | |
} | |
} | |
function flipText(input) { | |
const map = { | |
"a": "ɒ", | |
"b": "d", | |
"c": "ɔ", | |
"d": "b", | |
"e": "ɘ", | |
"f": "ʇ", | |
"g": "ϱ", | |
"h": "ʜ", | |
"i": "i", | |
"j": "į", | |
"k": "ʞ", | |
"m": "m", | |
"n": "n", | |
"p": "q", | |
"q": "p", | |
"r": "ɿ", | |
"t": "Ɉ", | |
"v": "v", | |
"u": "υ", | |
"w": "w", | |
"y": "γ", | |
".": ".", | |
"[": "]", | |
"(": ")", | |
"{": "}", | |
"?": "⸮", | |
"!": "!", | |
"'": "'", | |
"\\": "/", | |
"/": "\\", | |
"<": ">", | |
"_": "_", | |
"‿": "‿", | |
"⁅": "⁆", | |
"∴": "∵" | |
} | |
var newstr = '' | |
input.split('').forEach(function (c) { | |
if (c in map) { | |
newstr += map[c] | |
} else { | |
newstr += c | |
} | |
}) | |
return newstr.split("").reverse().join("") | |
} | |
const rewriter = new HTMLRewriter() | |
.on('meta', new AttributeRewriter('content')) | |
.on('title', new AttributeRewriter('')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment