Is it legal to read and edit on the fly JavaScript code with a browser?
<p>If I go on a website, can I read the source code of the JavaScript files?</p>

<p>Even if the code is obfuscated? I precise, not for compression reason, but obfuscated in order to transform the code less readable.</p>

<p>Next, can I modify on the fly the code with my browser (like Chrome for example)? Is this also legal to create a patch for a website? With GreaseMonkey for example?</p>

<p>Now, in this virtual situation, </p>

<ol>
<li>Take a random free game.</li>
<li>This is an online game (with websocket technology for example).</li>
<li>And this game is totally free but contains adverts. So we can deduce
author of the game intends to make money with their creation.</li>
<li>Their code are obfuscated, not with a minifier easily indentable
(which is more a compressor than a real obfuscator), but with a
"real" obfuscator that transform the original code in something less
readable for humain.</li>
<li>The authors of the website explicitely said that they do not want
that other people read and modify 'on the fly' their code.</li>
</ol>

<p>So in this precise situation:</p>

<ul>
<li>Do I have the right to modify on the fly (and also create a patch) in
order to correct a bug?</li>
<li>Do I have the right to explain to others people how this code works?</li>
<li>Do I have the right to modify on the fly the code in order to cheat in this game and explain to other for educational purpose (and free)? </li>
</ul>

<p>An example for the last point: I modify part of the code that said "my life is 50/100" and I send another message to the server: "my life is 100/100". By using their function to send data about our own life points.</p>

<p>Original code (deobscated) of the developper of this random game:</p>

<pre><code>var send_my_life = function (my_life) { socket.emit (my_life); }
</code></pre>

<p>Transformed function (on the fly or in the patch):</p>

<pre><code>var send_my_life = function (my_life) { socket.emit (100); }
</code></pre>

<p>I create this example in order to determinate if their exists any borders to the law. I mean, behind this border I can probably do my modifications (for example the game is not online). And accross this borders (for example player can make money with this game) = I probably should not modify the game.</p>

<p>In general, Yes, it is legal to read and edit your web browser code on-the-fly.  That is why such tools exist; and by processing code client-side, the authors submit to that possibility.  If there is something which a website wishes to make absolutely sure you won't mess with, they will process this information server-side, as per – Bálint's comment.</p>

<p>Now as you pointed out, in the example you brought up, the code is compressed but not obfuscated to make it harder for a human to read.  This is usually the norm.  Because things that obfuscate the code, they make it take longer for a human to figure out how to manipulate it; however, they don't actually prevent a human from doing it; also, once a human has figured it out, he can explain it to others without legal repercussions -- whether it is to correct a bug, or to cheat.  And any author who makes his code available as JavaScript, has to bear full acknowledgement of the fact that his code can be manipulated.</p>

<p>Now, there is one exception.  You say:</p>

<blockquote>
  <p>The authors of the website explicitely said that they does not want that other people read and modify 'on the fly' their code.</p>
</blockquote>

<p>If this is something that you had to click "I agree" to, then it is legally binding.  Therefore, if you must check to box agreeing not to modify the JavaScript code <em>before</em> you can download it, then it is protected by law.  Otherwise, the author will have to prove that you were aware of his requirements, before he can legally prosecute you.  (For example, if he can find a log that shows you read the ToS, and he can reasonably prove that it was you, e.g. by IP address, then he can prosecute you; however, in practice, such things are usually very hard to prove.)  See "browserwrap" vs. "clickwrap" for more details about this.</p>

<p>Yes, as long as you don't circumvent measures (such as cracking a paid software you need to pay for) and you don't distribute it (unless the copyright owner says so).</p>

<p>If you are trying to hack a compter, then stop right now.</p>

internet software website