Skip to content

Instantly share code, notes, and snippets.

@thomasmb
Created July 1, 2014 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasmb/1fb584da3bd09c61faa0 to your computer and use it in GitHub Desktop.
Save thomasmb/1fb584da3bd09c61faa0 to your computer and use it in GitHub Desktop.
Replacement for the Akismet jQuery code
document.addEventListener("DOMContentLoaded", function(event) {
var ak_js = document.getElementById( 'ak_js' );
if( !ak_js ){
ak_js = document.createElement( 'input' );
ak_js.type = 'hidden';
ak_js.name = ak_js.id = 'ak_js';
}
else {
ak_js.parentNode.removeChild( ak_js );
}
ak_js.value = ( new Date() ).getTime();
var el;
var destinations = [];
if( el = document.getElementById( 'commentform' ) ){
destinations.push( el );
}
if( ( el = document.getElementById( 'replyrow' ) ) && ( el = el.getElementsByTagName('td') ) ){
destinations.push( el.item(0) );
}
for( var i = 0, j = destinations.length; i < j; i++ ){
destinations[i].appendChild( ak_js );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment