-
Notifications
You must be signed in to change notification settings - Fork 91
/
fuckit.js
61 lines (50 loc) · 1.36 KB
/
fuckit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
FuckItJS v2.0.0-alpha
Copyright 2012, Matt Diamond
Note: This is ALPHA software and may result in irreversible brain damage.
*/
//@TODO: give a shit
(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);