Skip to content
Browse files

More cleanup

  • Loading branch information...
1 parent 4438dae commit e66e1c28f7bc1187ebc89ea655132aa3021d39c0 @dcramer committed Jan 2, 2012
Showing with 9 additions and 4 deletions.
  1. +1 −1 bookmarklet.js
  2. +8 −3 source.js
View
2 bookmarklet.js
@@ -1 +1 @@
-javascript:var%20awesome%20=%20function()%20{var%20domId%20=%20$(%27a[style*=left\\:\\%20370px]%27)[0].id;if%20(!domId)%20return;if%20(console)%20{console.log(%27Auto%20awesoming!%20(domId=%27%20+%20domId%20+%20%27)%27);}var%20elem%20=%20$(%27#%27%20+%20domId);var%20evt%20=%20document.createEvent(%22MouseEvents%22);evt.initMouseEvent(%22click%22,%20true,%20true,%20window,1,%200,%200,%20elem.offset().left,%20elem.offset().top,%20false,%20false,%20false,%20false,%200,%20null);document.getElementById(domId).dispatchEvent(evt);};setInterval(%27awesome()%27,%2045000);awesome(awesome.domId);window.alert(%22I%20don%27t%20always%20awesome,%20but%20when%20I%20do,%20I%20do%20it%20automatically.%22);
+javascript:var%20awesome%20=%20function()%20{var%20domId%20=%20$(%27a[style*=left\\:\\%20370px]%27)[0].id;if%20(!domId)%20return;if%20(console)%20{console.log(%27Auto%20awesoming!%20(domId=%27%20+%20domId%20+%20%27)%27);}var%20elem%20=%20$(%27#%27%20+%20domId);if%20(!elem)%20{if%20(console)%20{console.error(%27Unable%20to%20find%20element!%20(domId=%27%20+%20domId%20+%20%27)%27);}return;}var%20evt%20=%20document.createEvent(%22MouseEvents%22);evt.initMouseEvent(%22click%22,%20true,%20true,%20window,%201,%200,%200,%20elem.offset().left,%20elem.offset().top,%20false,%20false,%20false,%20false,%200,%20null);document.getElementById(domId).dispatchEvent(evt);};setInterval(awesome,%2045000);window.alert(%22I%20don%27t%20always%20awesome,%20but%20when%20I%20do,%20I%20do%20it%20automatically.%22);
View
11 source.js
@@ -5,11 +5,16 @@ var awesome = function() {
console.log('Auto awesoming! (domId=' + domId + ')');
}
var elem = $('#' + domId);
+ if (!elem) {
+ if (console) {
+ console.error('Unable to find element! (domId=' + domId + ')');
+ }
+ return;
+ }
var evt = document.createEvent("MouseEvents");
- evt.initMouseEvent("click", true, true, window,1, 0, 0, elem.offset().left, elem.offset().top, false, false, false, false, 0, null);
+ evt.initMouseEvent("click", true, true, window, 1, 0, 0, elem.offset().left, elem.offset().top, false, false, false, false, 0, null);
document.getElementById(domId).dispatchEvent(evt);
};
-setInterval('awesome()', 45000);
-awesome(awesome.domId);
+setInterval(awesome, 45000);
window.alert("I don't always awesome, but when I do, I do it automatically.");

0 comments on commit e66e1c2

Please sign in to comment.
Something went wrong with that request. Please try again.