Skip to content

Instantly share code, notes, and snippets.

View nickali's full-sized avatar

Nick Ali nickali

View GitHub Profile
@nickali
nickali / cf-function-blocker.js
Last active June 28, 2024 06:07
Block AI and SEO bots, scrapers, spiders, and crawlers with Cloudflare Pages Functions
/*
Cloudflare provides the ability to block some AI crawlers and
scrapers. They also maintain a list of bots approved to scan
sites: https://radar.cloudflare.com/traffic/verified-bots.
There are plenty of sites on the verified list I would like to block,
plus other SEO crawlers.
local gpgGroup = vim.api.nvim_create_augroup("customGpg", { clear = true })
vim.api.nvim_create_autocmd({ "BufReadPre", "FileReadPre" }, {
pattern = "*.gpg",
group = gpgGroup,
callback = function()
-- Make sure nothing is written to shada file while editing an encrypted file.
vim.opt_local.shada = nil
-- We don't want a swap file, as it writes unencrypted data to disk
vim.opt_local.swapfile = false