Skip to content

Instantly share code, notes, and snippets.

@dwsmart
Created January 18, 2021 20:37
Embed
What would you like to do?
const currURL = `${window.location.protocol}//${window.location.host}${window.location.pathname}${window.location.search}`
let outputString = ''
for (var idx in document.links) {
const ancString = `${document.links[idx]}`
if (ancString.includes('#')) {
const anchParts = ancString.split('#')
if (anchParts[0] === currURL) {
if (!document.getElementById(anchParts[1])) {
outputString += `${document.links[idx]}\n`
}
}
}
}
if (outputString !== '') {
const thisComment = document.createComment(`\n+-- Missing Anchors: [\n"${outputString}"] ---+\n`);
document.head.insertBefore(thisComment, document.head.firstChild);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment