View Full Version : Did you know that ...
Vladdy
03-08-2003, 04:18 PM
you can find out if your javascript function has been altered using the following code:
function somefunction()
{ a=b+1;
c=a-b;
}
somefunctionLength = (new String(window.somefunction)).length
So now you can mess with someone who decides to modify your code without asking you first by doing things like:
if(somefunctionLength!=123) document.body.innerHTML='mua-ha-ha';
:thumbsup:
brothercake
03-08-2003, 04:43 PM
Originally posted by Vladdy
document.body.innerHTML='mua-ha-ha';
:thumbsup:
:D lol
joh6nn
03-09-2003, 06:26 PM
i always thought an interesting function, somewhat related, would be a bookmarklet that did something like this:
for (i in self) {
if (typeof self[i] == "function") {
if ((self[i].indexOf('status') >=0) || (self[i].indexOf('setTimeout') >=0)) {
if (confirm(self[i]+"\n\nEnd this function?") {self[i] = null;}
}
}
}
checks to see if a function uses setTimeout or modifies the status-bar (status bar scroller), displays its contents, and asks if you want to allow it to continue. i've never tested it, just an idea i've had for a while. assuming it works, it could conceivably be modified to take out all kinds of annoying things, like mouse trails, etc.
brothercake
03-09-2003, 07:21 PM
Originally posted by joh6nn
assuming it works, it could conceivably be modified to take out all kinds of annoying things
What I'd like to know is a way of nullifying selective bits of javascript through void commands in the address bar ...
Want to link to a page you like but irritated by its pop-ups? No worries - just void the window code as part of the URI ;)
Possible? Don't know.
joh6nn
03-09-2003, 11:51 PM
don't think it's doable. i spent a couple of minutes trying to come up with something, but there doesn't seem to be any good way to do it
Borgtex
03-09-2003, 11:58 PM
Originally posted by Vladdy
So now you can mess with someone who decides to modify your code without asking you first by doing things like:
if(somefunctionLength!=123) document.body.innerHTML='mua-ha-ha';
:thumbsup:
well..., that someone only needs to modify another line ;)
//if(somefunctionLength!=123) document.body.innerHTML='mua-ha-ha';
but it's interesting :)
Vladdy
03-10-2003, 12:10 AM
Those who can read and understand someone elses scripts are few and far in between and in most cases they do not have to rip scripts - they can write better themselves.
The majority of cut-n-pasters can not figure out why the two scripts do not work together when a reason as simple as repeating variable. This is the type you can have the most fun with <evil grin />
cg9com
03-10-2003, 07:01 AM
Originally posted by Vladdy
The majority of cut-n-pasters can not figure out why the two scripts do not work together when a reason as simple as repeating variable. This is the type you can have the most fun with <evil grin />
your bad, and so right.
Jerome
03-10-2003, 12:49 PM
I am always very interested in the functions, ideas and solutions the forum people produce.
This one is most interesting as well, however, after implementing it I have a question:
a=b+1
c=a-b
Then: c=a-b gives:
c=a-b => -a=-c-b => a=c+b
together with: a=b+1 gives:
c+b=b+1 => c=b-b+1 => c=1
Then: a=b+1 gives:
a is always one more then b
Asigning a,b,c with a=b+1 and c=a-b can give:
a=3, b=2, c= always 1
3=2+1 and 1=3-2
However, also:
a=1000, b=999, c= always 1
1000=999+1 and 1=1000-999
Please correct me if I am wrong!!!
Or was this check a regular check if the forum readers understand it, LOL
Jerome
joh6nn
03-10-2003, 01:20 PM
i think Vladdy was just filling the function with arbitrary nonsense code, to help demonstrate his point about examining the length of a function.
Jerome
03-10-2003, 02:23 PM
My mistake!!
I was in a rather serious mood...
But agree with the point: do something - unexpected - in or around your code.
Jerome
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.