Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* a cloudflare worker to remove the script tag they inject into the head if you have a cloudflare app installed.
* WARNING: some apps may not work if you remove this script tag!!! But things like logflare that add no js of
* their own should be fine.
addEventListener('fetch', event => {
const request = event.request
async function handleRequest(request) {
const url = new URL(request.url);
let oldResponse = await fetch(url.toString(), request)
let newResponse = new HTMLRewriter()
.on("script[src*='/cdn-cgi/apps/head/']", new removeScript())
return newResponse
class removeScript {
element(element) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment