 <p>You could try this:</p> <pre><code>function($){ $.dw_inactive = function( options ){ var settings = $.extend({ backgroundColor: "#000", interval: 1000, startTime: 1000, }, options ); var dw_inactive_counter = 0; setTimeout("dw_inactive_check", settings.startTime); $.fn.dw_inactive_check = function(settings){ if(!$("body").has("div."+settings.className)) { $("body").add("div").attr("class",settings.className).css({"background-color":settings.backgroundColor}); } setInterval("dw_inactive_check", settings.interval); } } } </code></pre>