edit javascript on the fly
I was curious how I might go about editing a variable on t开发者_开发知识库he fly, since whenever I try nothing happens. Take http://nyan.cat for example. I tried to edit the seconds variable, but nothing happened - why?
i used (in the JS console) seconds = 9001; RET
and nothing happens....
That's because in http://nyan.cat/ the seconds
variable is being set by the script repeatedly, based on the startTime
Date object. In the specific case of http://nyan.cat/, to 'hack' the time, change the startTime
.
Example: to increase your seconds
by 1234567 seconds:
startTime = new Date(((+startTime/1000)-1234567)*1000);
What JS console are you using?In the firebug?
Here I tested it.
var seconds = 9001;
alert(seconds);
精彩评论