Skip to content

Instantly share code, notes, and snippets.

@dwsmart
Created January 18, 2021 20:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dwsmart/a05e00e8348b129abd3fbf6c2a5cb71b to your computer and use it in GitHub Desktop.
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