r/shittyprogramming • u/Booty_Bumping • Mar 05 '20
State of the art javascript Error Steamroller - requires jQuery!
fuckit.js
(function($){
$.ajaxSetup({ cache: true });
var _FuckIt = window.FuckIt;
var FuckIt = function(script){
window.fuckingDeferred = $.Deferred();
$.ajax({
url: script,
dataType: "text"
}).then(function(result){
window.fuckedScript = result;
eval(window.fuckedScript);
window.fuckingDeferred.resolve();
}, function(){
throw new Error("Could not load script: "+script);
});
return window.fuckingDeferred.promise();
}
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);
window.fuckingDeferred.resolve();
});
return true;
}
//this will not actually do anything remotely useful
FuckIt.noConflict = function(){
window.FuckIt = _FuckIt;
return FuckIt;
}
FuckIt.moreConflict = function(){
for (var prop in window){
if (prop === "location"){
//you're not getting away that easy.
continue;
}
window[prop] = FuckIt;
}
}
window.FuckIt = FuckIt;
})(jQuery);Found here https://github.com/mattdiamond/fuckitjs
37
Upvotes
4
u/encrypter8 Mar 05 '20
It's an 8 year old project. jQuery is exactly what would have been used to make this back then
4
u/[deleted] Mar 05 '20
What's wrong with jquery? It's stable, tons of nice functions, and fairly fast. It's built in promise stuff is nice and works well and I've yet to find a better way to do ajax. You can build jQuery light as well.