You, of course, are not the first. Unfortunately, many wireless providers have used this rude and undesirable compression approach. It comes from Bytemobile .
What it does is proxy recompress all the images you have selected by default (which significantly degrades the image quality). Then it roughly injects a script into your document, which adds the ability to load the correct image for each re-compressed image. Unfortunately, since the script is a horribly written JS style in the style of the 1990s, it holds the entire space of your namespace, captures your event handlers, and is very likely to ruin your own scripts.
I do not know how to stop the injection itself without using HTTPS. But what you can do is detect or sabotage the script. For example, if you added a script near the end of the document (between the inclusion of 1.2.3.4 script and the script's built-in trigger) to associate it with the loader:
<script type="text/javascript"> bmi_SafeAddOnload= function() {}; </script>
then the script will not run, so your events and the DOM will be left alone. On the other hand, the original script would still leave your namespace garbage, and all the markup problems that it causes would still be present. In addition, the user will be stuck with re-compressed images, unable to receive originals.
You can try just telling the user:
<script type="text/javascript"> if ('bmi_SafeAddOnload' in window) { var el= document.createElement('div'); el.style.border= 'dashed red 2px'; el.appendChild(document.createTextNode( 'Warning. Your wireless ISP is using an image recompression system '+ 'that will make pictures look worse and which may stop this site '+ 'from working. There may be a way for you to disable this feature. '+ 'Please see your internet provider account settings, or try '+ 'using the HTTPS version of this site.' )); document.body.insertBefore(el, document.body.firstChild); } </script>
bobince Nov 06 2018-10-06 14:32
source share