Created
December 20, 2022 01:54
-
-
Save 1000heads-luke/9d3f2170c5f0a326e570783603c9fdd2 to your computer and use it in GitHub Desktop.
This file contains 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
javascript: (function() { | |
function callback() { | |
function l() { | |
$("strong.headings_detector").remove(); | |
if( !$('style#headings_detector') ){ | |
$('head').append( | |
'<style id="headings_detector">'+ | |
'.headings_detector {'+ | |
'color:#FFF;font-weight:bold;font-size:small;background:yellow;'+ | |
'}'+ | |
'</style>' | |
); | |
} | |
var count = 0; | |
for( var i = 1 ; i<7 ; i++ ){ | |
count += $('h'+i) | |
.prepend('<i class="headings_detector--before"><h'+i+'></i>') | |
.append('<i class="headings_detector--after"></h'+i+'></i>') | |
.length; | |
count += $('[role=heading][aria-level='+i+']') | |
.prepend('<i class="headings_detector--before"><[role=heading][aria-level='+i+']></i>') | |
.append('<i class="headings_detector--after"></[role=heading][aria-level='+i+']></i>') | |
.length; | |
} | |
if( !count ) { | |
$('body').prepend('<strong style="color:black;font-weight:bold;font-family:sans-serif;font-size:small;background-color:yellow;margin:0 2px; padding:2px;" id="failure" role="status"></strong>'); | |
$('#failure').html('No Headings Found on Page: ' + document.title); | |
setTimeout(function(){ $('#failure').remove(); }, 6000); | |
} else { | |
$('body').append('<div id="success" role="alert" style="position:absolute; width:0; height:0; clip: rect(0,0,0,0);"></div>'); | |
$('#success').html('Success! Headings Found on Page: ' + document.title); | |
setTimeout(function(){ $('#success').remove(); }, 3000); | |
} | |
$("script[src$='headings.js']").remove(); | |
s.remove(); | |
} | |
l() | |
} | |
var s = document.createElement("script"); | |
s.addEventListener ? s.addEventListener("load", callback, !1) : s.readyState && (s.onreadystatechange = callback), s.src = "https://code.jquery.com/jquery-3.6.2.slim.min.js", document.body.appendChild(s); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment