A page can detect scripts accessing *javascript* variables or
functions defined in the page:
window.__defineGetter__('foo', trap);
function trap() { /*do something*/ }
This is unlikely to happen with generic scripts, which usually only
manipulate the *DOM* and do not mess with the javascript of the page.
In other terms, if a script explicitly takes an action directly
accessing a global variable or function in the page, chances are high
that there is some 'criminal energy' spent in the attempt, and the
page owner may choose to deny the service on finding this.
--Tom
Of course.
I just suggested a pragmatic (euphemism for "error prone") approach
for detecting client side tampering with the page. The original
question was how could a site tell 'innocuous' scripts from 'bad'
ones. My guess was:
1) a general purpose script, that is, one which runs in multiple sites
and should not be blocked, is *likely* to be of the kind of those
which hide some ads, insert search fields or toggle the display of
some page sections, etc., in short DOM manipulations.
2) a script which deliberately attempts to trick a single site,
specifically a game site or one which makes heavy use of javascript,
would *most probably* mess directly with functions and global
variables in the page
These assumptions are purely heuristic/speculative. You are absolutely
right in that DOM manipulations can be detected by the page owner, but
a change in the DOM does not necessarily mean a violation of the game
conditions.