Initial commit, added license, added readme, added wcagToMarkdownChecklist script

This commit is contained in:
2025-11-24 21:04:29 +01:00
commit d97d78c5af
3 changed files with 78 additions and 0 deletions

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 LD-Reborn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

4
README.md Normal file
View File

@@ -0,0 +1,4 @@
# Snippets
Feel free to explore and dig for copper.
Something's broken or you want to contribute a missing piece? Feel free to open an issue or start a discussion.

View File

@@ -0,0 +1,53 @@
/*
Extracts the table of contents from [see supported pages] into your clipboard as a markdown checklist
Supported pages:
- https://www.w3.org/TR/WCAG21/
- https://www.w3.org/TR/WCAG22/
- https://www.w3.org/TR/wcag-3.0/
How to use:
1. Open the page
2. Copy the script below
3. Open the developer console (usually with "F12" and by then navigating to "Console" in the developer settings)
4. Paste the script and press enter to confirm
5. A red button appears on the page. Click it.
6. The checklist is now in your clipboard. Paste it whereever you need.
*/
let indentation = "\t"; // Choose your indentation
const copyButton = document.createElement('button');
copyButton.textContent = 'Copy TOC to Clipboard';
copyButton.style.position = 'fixed';
copyButton.style.top = '20px';
copyButton.style.right = '90px';
copyButton.style.zIndex = '1000';
copyButton.style.backgroundColor = 'red';
copyButton.style.color = 'white';
copyButton.style.scale = '2';
copyButton.addEventListener('click', function() {
let elements = document.querySelectorAll(".toc .tocline .tocxref:has(bdi)");
let text = "";
elements.forEach(element => {
let text1 = element.childNodes[0].textContent;
let text2 = element.childNodes[1].textContent;
let segmentCount = text1.replace(". ", "").split(".").length;
text += indentation.repeat(segmentCount - 1) + "- [ ] " + text1 + text2 + "\n";
});
navigator.clipboard.writeText(text)
.then(() => {
console.log("Copied to clipboard successfully!");
this.textContent = "Copied!";
setTimeout(() => {
this.textContent = "Copy TOC to Clipboard";
}, 2000);
})
.catch(err => {
console.error("Failed to copy: ", err);
alert("Failed to copy to clipboard. Please try again or copy manually.");
});
});
document.body.appendChild(copyButton);