Created
January 21, 2026 17:58
-
-
Save nine1one/59a47388d6075058a912daac276e1c8f to your computer and use it in GitHub Desktop.
A bookmarklet to extract model descriptions and technical metadata tables from Civitai model pages into a sanitized .txt file named after the page title.
This file contains hidden or 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
| /* | |
| ```markdown | |
| README.md | |
| Civitai Metadata Extractor Bookmarklet | |
| This bookmarklet allows you to quickly download model information (description and technical details) from model pages using the Mantine UI framework (commonly used on sites like Civitai). It generates a .txt file named after the model's page title. | |
| How it Works | |
| The script targets specific DOM elements within the page structure to gather data: | |
| 1. Filename Generation (document.title) | |
| The script retrieves the current browser tab title via document.title. It then applies a regex filter—/[\\/:"*?<>|]/g—to remove characters that are illegal in Windows or macOS filenames, ensuring the download trigger doesn't fail. | |
| 2. Description Extraction (.mantine-Spoiler-content) | |
| The script looks for the model description stored within the Mantine "Spoiler" component. | |
| - It targets the class .mantine-Spoiler-content. | |
| - It uses .innerText to capture the text while ignoring HTML tags (like <span> or <div>), preserving the readable formatting of the user's description. | |
| 3. Metadata Table Extraction (.mantine-Table-table) | |
| The script searches for technical details (like Base Model, Type, and Stats) by locating a table element. | |
| - It prioritizes the class .mantine-Table-table or a generic <table> tag. | |
| - It iterates through every row (<tr>) and cell (<td>). | |
| - It joins the label and the value with a colon (:) and cleans up extra whitespace or line breaks for a clean text file layout. | |
| 4. Data URI Download | |
| Instead of sending data to a server, the script creates a temporary "Blob" link in your browser memory: | |
| - It encodes the collected text into a data:text/plain URI. | |
| - It programmatically clicks a hidden download link to save the file directly to your computer. | |
| Installation | |
| 1. Create a new bookmark in your browser. | |
| 2. In the URL or Location field, paste the entire code from the .js file in this Gist (starting with javascript:). | |
| 3. Name it "Download Model Info". | |
| 4. Navigate to a model page, ensure the "Details" section is visible, and click the bookmark. | |
| ``` | |
| */ | |
| javascript:(function(){ | |
| /* 1. Get and Sanitize Filename from Page Title */ | |
| let rawTitle = document.title || 'table_data'; | |
| /* Removes characters illegal in filenames and trims extra whitespace */ | |
| let safeTitle = rawTitle.replace(/[\\/:"*?<>|]/g, '').replace(/\s+/g, ' ').trim(); | |
| let fileName = safeTitle + '.txt'; | |
| let output = ""; | |
| /* 2. Extract Description Text (Mantine Spoiler Section) */ | |
| const descriptionSection = document.querySelector('.mantine-Spoiler-content'); | |
| if (descriptionSection) { | |
| output += "DESCRIPTION:\n" + descriptionSection.innerText.trim() + "\n\n"; | |
| } | |
| /* 3. Find and Extract Table Data */ | |
| const table = document.querySelector('.mantine-Table-table') || document.querySelector('table'); | |
| if (table) { | |
| output += "DETAILS:\n"; | |
| table.querySelectorAll('tr').forEach(row => { | |
| const cells = Array.from(row.querySelectorAll('td')).map(td => td.innerText.replace(/\s+/g, ' ').trim()); | |
| if (cells.length > 0) output += cells.join(" : ") + "\n"; | |
| }); | |
| } | |
| if (!output) { alert('No content found! Ensure the sections are visible.'); return; } | |
| /* 4. Trigger Download */ | |
| const link = document.createElement('a'); | |
| link.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(output)); | |
| link.setAttribute('download', fileName); | |
| link.style.display = 'none'; | |
| document.body.appendChild(link); | |
| link.click(); | |
| document.body.removeChild(link); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment