Skip to content

Instantly share code, notes, and snippets.

@easrng
Last active November 16, 2022 23:01
Show Gist options
  • Save easrng/5c0ddb90401a50b8cee7071cb73bc324 to your computer and use it in GitHub Desktop.
Save easrng/5c0ddb90401a50b8cee7071cb73bc324 to your computer and use it in GitHub Desktop.

cssfetch

PropellerAds offers a free CORS-bypassing proxy. Their ad code uses it, and so can you. It's not blocked by adblockers yet, but it should be. Blocked now :)

Usage

Just like fetch, but only with a URL.

Example usage of cssfetch.

async function cssfetch(url){
const frame = await new Promise(cb=>
document.body.appendChild(
Object.assign(
document.createElement("iframe"),
{
srcdoc: "<div class=widget-col-10-sp></div><link rel=stylesheet href=\"https://cosatoos.com/lol.css?"+btoa(new URL(url, location.href).href)+"\">",
onload(){cb(this)},
sandbox: "allow-same-origin",
width: 0,
height: 0,
frameBorder: 0
}
)
)
)
response = getComputedStyle(frame.contentWindow.document.body.children[0], ':before').getPropertyValue('content').replace(/['"\(\)\s]/g, "")
if(response == "none") return new Response("Error", {status: 500})
response = await fetch("data:application/octect-stream;base64,"+response)
return response
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment