├── README.md ├── fuckit-min.js ├── fuckit.coffee ├── fuckit.js ├── test.html └── test.js /README.md: -------------------------------------------------------------------------------- 1 | FuckItJS 2 | ======== 3 | ### Javascript Error Steamroller 4 | 5 | FuckItJS uses state-of-the-art technology to make sure your javascript code runs whether your compiler likes it or not. 6 | 7 | Technology 8 | ---------- 9 | 10 | Through a process known as *Eval-Rinse-Reload-And-Repeat*, FuckItJS repeatedly compiles your code, detecting errors and slicing those lines out of the script. 11 | To survive such a violent process, FuckItJS reloads itself after each iteration, allowing the onerror handler to catch every single error in your terribly written code. 12 | 13 | Installation 14 | ------------ 15 | 16 | 1. Include jQuery, because everything requires jQuery 17 | 2. Include "fuckit.js" 18 | 3. The End 19 | 20 | API 21 | --- 22 | 23 | **FuckIt**(*path_to_your_shitty_script_file*) 24 | 25 | This will keep evaluating your code until all errors have been sliced off like mold on a piece of perfectly good bread. 26 | Whether or not the remaining code is even worth executing, we don't know. We also don't particularly care. 27 | 28 | FuckIt returns a promise that will be resolved once your godforsaken code actually makes it to the finish line. You can use this callback to chain additional FuckIt calls, since we all know calling it once won't do enough damage to the Internet. 29 | 30 | **FuckIt.noConflict**() 31 | 32 | Are you using two different FuckIt libraries? Fuck it, use FuckIt.NoConflict. 33 | Of course, this won't really help since FuckItJS reloads itself multiple times and will continually overwrite the global FuckIt variable, but hey... at least you can feel like you're doing something smart. 34 | 35 | **FuckIt.moreConflict**() 36 | 37 | Are you tired of running from conflict? Are you ready to overwrite every single property on the global `window` object even if it crashes your browser? Then this method is for you. 38 | 39 | Browser Compatibility 40 | --------------------- 41 | 42 | Really? *Really?* 43 | 44 | FAQ 45 | ------- 46 | 47 | **1) Is this a good idea?** 48 | 49 | Of course not. This is quite possibly the worst javascript plugin ever written. 50 | 51 | **2) Isn't "eval" evil?** 52 | 53 | See Question #1. 54 | 55 | **3) Help! I have way too much money and desperately need to give a sizeable portion of it to you!** 56 | 57 | Have no fear: I am now accepting donations via GitTip! https://www.gittip.com/mattdiamond/ 58 | 59 | Support 60 | ------- 61 | 62 | For technical issues: [@mattdiamond](http://twitter.com/mattdiamond) on Twitter, or e-mail me at [mdiamond@jhu.edu](mailto:mdiamond@jhu.edu) 63 | 64 | For personal issues: Take a deep breath, it's going to be okay. 65 | 66 | LICENSE 67 | ------- 68 | 69 | Copyright (C) 2012, Matt Diamond 70 | 71 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, pulverize, distribute, synergize, compost, defenestrate, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 72 | 73 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 74 | 75 | If the Author of the Software (the "Author") needs a place to crash and you have a sofa available, you should maybe give the Author a break and let him sleep on your couch. 76 | 77 | If you are caught in a dire situation wherein you only have enough time to save one person out of a group, and the Author is a member of that group, you must save the Author. 78 | 79 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO BLAH BLAH BLAH ISN'T IT FUNNY HOW UPPER-CASE MAKES IT SOUND LIKE THE LICENSE IS ANGRY AND SHOUTING AT YOU. 80 | -------------------------------------------------------------------------------- /fuckit-min.js: -------------------------------------------------------------------------------- 1 | /* 2 | FuckItJS v2.0.0-alpha 3 | Copyright 2012, Matt Diamond 4 | 5 | Note: This is ALPHA software and may result in irreversible brain damage. 6 | */ 7 | 8 | (function($){$.ajaxSetup({cache:true});var _FuckIt=window.FuckIt;var FuckIt=function(script){var req=$.ajax({url:script,dataType:"text"});req.then(function(result){window.fuckedScript=result;eval(window.fuckedScript);},function(){throw new Error("Could not load script: "+script);});};window.onerror=function(error,url,line){if(!window.fuckedScript)return;var parsed=window.fuckedScript.split("\n");parsed.splice(line-1,1);window.fuckedScript=parsed.join("\n");$.getScript("fuckit.js",function(){eval(window.fuckedScript);});return true;};FuckIt.noConflict=function(){window.FuckIt=_FuckIt;return FuckIt;};window.FuckIt=FuckIt;})(jQuery); -------------------------------------------------------------------------------- /fuckit.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | FuckItJS v2.0.0-alpha 3 | 4 | Note: this is ALPHA software and may result in 5 | irreversible brain damage 6 | ### 7 | 8 | $ -> 9 | 10 | $.ajaxSetup { cache: true } 11 | 12 | _FuckIt = window.FuckIt; 13 | 14 | FuckIt = (script) -> 15 | req = $.ajax { 16 | url: script, 17 | dataType: 'text' 18 | } 19 | 20 | success = (result) -> 21 | window.fuckedScript = result 22 | eval window.fuckedScript 23 | 24 | error = -> 25 | throw new Error "Could not load script: #{script}" 26 | 27 | req.then success, error 28 | 29 | window.onError = (error, url, line) -> 30 | if not window.fuckedScript then return 31 | 32 | parsed = window.fuckedScript.split "\n" 33 | parsed.splice line - 1, 1 34 | 35 | window.fuckedScript = parsed.join "\n" 36 | 37 | $.getScript 'FuckIt.js', () -> 38 | eval window.fuckedScript 39 | 40 | return true 41 | 42 | FuckIt.noConflict = () -> 43 | window.FuckIt = _FuckIt 44 | FuckIt 45 | 46 | FuckIt.moreConflict = () -> 47 | window[prop] = FuckIt for prop in window when prop isnt 'location' 48 | 49 | window.FuckIt = FuckIt; 50 | -------------------------------------------------------------------------------- /fuckit.js: -------------------------------------------------------------------------------- 1 | /* 2 | FuckItJS v2.0.0-alpha 3 | Copyright 2012, Matt Diamond 4 | 5 | Note: This is ALPHA software and may result in irreversible brain damage. 6 | */ 7 | 8 | //@TODO: give a shit 9 | 10 | (function($){ 11 | 12 | $.ajaxSetup({ cache: true }); 13 | 14 | var _FuckIt = window.FuckIt; 15 | 16 | var FuckIt = function(script){ 17 | window.fuckingDeferred = $.Deferred(); 18 | $.ajax({ 19 | url: script, 20 | dataType: "text" 21 | }).then(function(result){ 22 | window.fuckedScript = result; 23 | eval(window.fuckedScript); 24 | window.fuckingDeferred.resolve(); 25 | }, function(){ 26 | throw new Error("Could not load script: "+script); 27 | }); 28 | return window.fuckingDeferred.promise(); 29 | } 30 | 31 | window.onerror = function(error, url, line){ 32 | if (!window.fuckedScript) return; 33 | var parsed = window.fuckedScript.split("\n"); 34 | parsed.splice(line - 1, 1); 35 | window.fuckedScript = parsed.join("\n"); 36 | $.getScript("fuckit.js", function(){ 37 | eval(window.fuckedScript); 38 | window.fuckingDeferred.resolve(); 39 | }); 40 | return true; 41 | } 42 | 43 | //this will not actually do anything remotely useful 44 | FuckIt.noConflict = function(){ 45 | window.FuckIt = _FuckIt; 46 | return FuckIt; 47 | } 48 | 49 | FuckIt.moreConflict = function(){ 50 | for (var prop in window){ 51 | if (prop === "location"){ 52 | //you're not getting away that easy. 53 | continue; 54 | } 55 | window[prop] = FuckIt; 56 | } 57 | } 58 | 59 | window.FuckIt = FuckIt; 60 | 61 | })(jQuery); -------------------------------------------------------------------------------- /test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 44 | 45 | 46 | 47 |