Created
September 26, 2013 03:07
-
-
Save th507/6709373 to your computer and use it in GitHub Desktop.
Web Inspector prank
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* run it inside Web Inspector, as long as the tab is not closed, | |
* victim's pasteboard is sabotaged. | |
* some some other fun stuff as well :) | |
*/ | |
(function() { | |
var hiddenConsole = (console._commandLineAPI || console._inspectorCommandLineAPI || {}); | |
// randomly fill the paste board | |
var mockPasteboard = function () { | |
try { | |
var rdm = btoa(Math.random().toFixed(7)).toLowerCase().substring(2); | |
hiddenConsole.copy(rdm); | |
} catch (e) {} | |
}; | |
// hide origin of code | |
Error.prototype.toString = function() { | |
if (Error.constructor.mess) { | |
return; | |
} | |
Error.constructor.mess = true; | |
setInterval(mockPasteboard, 600); | |
// mess up with internal constuctors | |
var o = Object, | |
_console = {}, | |
_jsonString = '', | |
methods = ["log", "warn", "error", "dir"], | |
newt = { | |
obj: new Object(), | |
arr: new Array(), | |
num: new Number(), | |
str: new String(), | |
dat: new Date(), | |
err: new Error(), | |
img: new Image(), | |
txt: new Text() | |
}; | |
Array = function() { return o.create(newt.obj); }; | |
Object = function() { return o.create(newt.arr); }; | |
Number = function() { return o.create(newt.str); }; | |
String = function() { return o.create(newt.num); }; | |
Date = function() { return o.create(newt.err); }; | |
Image = function() { return o.create(newt.txt); }; | |
Text = function() { return o.create(newt.img); }; | |
JSON.parse = function(str) { | |
_jsonString = str; | |
return []; | |
}; | |
// return previously stored str | |
JSON.stringify = function() { | |
return _jsonString; | |
}; | |
// discourage user from finding out what goes wrong | |
methods.forEach(function(method) { | |
_console[method] = console[method]; | |
console[method] = function(a) { | |
if (({}).toString.call(a).match(/\s(\w+)]$/)[1] === "Object") { | |
_console[method].call(console, [a]); | |
return; | |
} | |
if (({}).toString.call(a).match(/\s(\w+)]$/)[1] === "Array") { | |
_console[method].call(console, a.reverse()); | |
return; | |
} | |
if (({}).toString.call(a).match(/\s(\w+)]$/)[1] === "String") { | |
_console[method].call(console, a.slice(1,-1)); | |
return; | |
} | |
if (({}).toString.call(a).match(/\s(\w+)]$/)[1] === "Number") { | |
_console[method].call(console, a + 1); | |
return; | |
} | |
}; | |
}); | |
}; | |
// make it rain | |
throw new Error(); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment