forked from mattdiamond/fuckitjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuckit.js
58 lines (47 loc) · 1.22 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
/*
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){
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;
}
//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);