Cloudflare Worker
使用 Cloudfalre worker 隐藏 gitbook 的 power by
addEventListener('fetch', event => {
event.passThroughOnException()
event.respondWith(handleRequest(event.request))
})
/**
* Fetch and log a given request object
* @param {Request} request
*/
async function handleRequest(request) {
const response = await fetch(request)
var html = await response.text()
// Inject scripts
const customScripts = `<style type="text/css">
a[role='presentation'] {
display: none;
}
</style></body>`
html = html.replace( /<\/body>/ , customScripts)
// return modified response
return new Response(html, {
headers: response.headers
})
}最后更新于