Created
February 8, 2023 17:19
-
-
Save fforres/04bcf08729aa87a45c61b7e1f777f4c3 to your computer and use it in GitHub Desktop.
Redact all text in a website
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
// This script will inject a specific font from google fonts (this one https://fonts.google.com/specimen/Redacted) and will force all text in a page to use it. | |
// It's a bit easier than changing all the text-nodes from the page into unicode "blocks", and a lot less resource intensive. | |
// In case you want to have a bookmark, you can do | |
// javascript:const injectCSS=()=>{let n=document.createElement("style");return n.type="text/css",n.innerText="\n/* latin-ext */\n@font-face {\n font-family: 'Redacted';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(https://fonts.gstatic.com/s/redacted/v6/Z9XVDmdRShme2O_7aLTX6OymlLGDzCs.woff2) format('woff2');\n unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;\n}\n/* latin */\n@font-face {\n font-family: 'Redacted';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url(https://fonts.gstatic.com/s/redacted/v6/Z9XVDmdRShme2O_7aLTZ6OymlLGD.woff2) format('woff2');\n unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;\n}\n\n* {\n font-family: 'Redacted' !important;\n}\n",document.head.appendChild(n),n};injectCSS(); | |
// | |
// | |
const injectCSS = () => { | |
const css = ` | |
/* latin-ext */ | |
@font-face { | |
font-family: 'Redacted'; | |
font-style: normal; | |
font-weight: 400; | |
font-display: swap; | |
src: url(https://fonts.gstatic.com/s/redacted/v6/Z9XVDmdRShme2O_7aLTX6OymlLGDzCs.woff2) format('woff2'); | |
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; | |
} | |
/* latin */ | |
@font-face { | |
font-family: 'Redacted'; | |
font-style: normal; | |
font-weight: 400; | |
font-display: swap; | |
src: url(https://fonts.gstatic.com/s/redacted/v6/Z9XVDmdRShme2O_7aLTZ6OymlLGD.woff2) format('woff2'); | |
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; | |
} | |
* { | |
font-family: 'Redacted' !important; | |
} | |
` | |
let el = document.createElement('style'); | |
el.type = 'text/css'; | |
el.innerText = css; | |
document.head.appendChild(el); | |
return el; | |
}; | |
injectCSS() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment