Skip to content

Instantly share code, notes, and snippets.

@szepeviktor
Created January 17, 2023 07:55
Show Gist options
  • Save szepeviktor/69d88d8fdcbe7ed0e21432c160dd7493 to your computer and use it in GitHub Desktop.
Save szepeviktor/69d88d8fdcbe7ed0e21432c160dd7493 to your computer and use it in GitHub Desktop.
Disable CSS: remove all styles from a web page
document.querySelectorAll("link[rel=stylesheet], style").forEach(element => element.remove());
document.querySelectorAll("[style]").forEach(element => element.removeAttribute("style"));
@szepeviktor
Copy link
Author

Adding Normalize.css

var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "https://cdn.jsdelivr.net/npm/normalize.css@latest/normalize.min.css";
document.head.appendChild(link);

@szepeviktor
Copy link
Author

szepeviktor commented May 11, 2023

Replace images with alt attributes and remove script elements, tag headings.

document.querySelectorAll("script").forEach(element => element.remove());
document.querySelectorAll("img").forEach(function (element) {element.loading="eager"; element.src=""; element.srcset=""; element.alt="[🎨"+element.alt+"]";});
document.querySelectorAll("h1,h2,h3,h4,h5,h6").forEach(function (element) {element.innerHTML=element.tagName+">"+element.innerHTML;});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment