Usefull Scripts
A usfull set of scripts for your projects
Element outline script
Simply set the document.querySelectorAll
to the outermost element and everything inside of it will be outlined
Script for use inline in HTML
<script>
window.addEventListener("DOMContentLoaded", () => {
const colors = [
"red",
"blue",
"green",
"orange",
"purple",
"cyan",
"magenta",
];
document.querySelectorAll("#whyFrontSection *").forEach((el, i) => {
el.style.outline = `1px solid ${colors[i % colors.length]}`;
});
});
</script>
Script for use in the browser console
(() => {
const colors = [
"red",
"blue",
"green",
"orange",
"purple",
"cyan",
"magenta",
];
document.querySelectorAll(".panel-grid.panel-has-style *").forEach((el, i) => {
el.style.outline = `1px solid ${colors[i % colors.length]}`;
});
})();
π Link Extractor & Highlighter Script for Web Cloning
This script is designed to highlight and extract all <a>
tag links from a webpage. It's ideal when you're duplicating or analyzing a page that includes linked images, inline text links, and heading links, and you need a fast way to audit or copy all URLs.
β What It Does:
- Highlights every
<a>
tag on the page with a red outline. - Adds a
data-link-index
attribute for easier tracking. - Extracts each linkβs:
- Index number
- Destination URL (
href
) - Type (
Image Link
orText Link
) - Display text or image
alt
(fallbacks to[image]
if missing) - Outputs everything in a clean console table.
π§ͺ How to Use It:
- Open the page you want to analyze in Google Chrome.
- Right-click anywhere on the page and choose Inspect.
- In the Console tab, paste the script below and hit Enter:
// Add visual index badge and outline each link
document.querySelectorAll('a').forEach((el, i) => {
el.style.outline = '2px solid blue';
el.setAttribute('data-link-index', i + 1);
// Create badge element
const badge = document.createElement('div');
badge.textContent = i + 1;
badge.style.position = 'absolute';
badge.style.background = 'yellow';
badge.style.color = 'black';
badge.style.fontSize = '10px';
badge.style.padding = '2px 4px';
badge.style.border = '1px solid black';
badge.style.borderRadius = '3px';
badge.style.zIndex = '9999';
badge.style.transform = 'translate(-50%, -50%)';
// Position badge
const rect = el.getBoundingClientRect();
badge.style.left = `${rect.left + window.scrollX}px`;
badge.style.top = `${rect.top + window.scrollY}px`;
badge.style.position = 'absolute';
document.body.appendChild(badge);
});
// Extract and log link data
const links = Array.from(document.querySelectorAll('a')).map((a, i) => {
const text = a.textContent.trim();
const img = a.querySelector('img');
return {
index: i + 1,
href: a.href,
type: img ? 'Image Link' : 'Text Link',
content: img ? (img.alt || '[image]') : text
};
});
console.table(links);
- Copy the table from the console (right-click β Copy table) and paste it into a spreadsheet or Markdown file.
π‘ Tip:
Use this when replicating legacy or unstructured pages where link tracking and structure arenβt obvious from the visual layout alone.