3 ms·
Show HN: Disabling View Source in Firefox and Edge
- core-questions 9y agoFor the lazy, here's the magic: <script> document.currentScript.remove(); setTimeout(function() { // no rights reserved (BSD0) by Jeremy Banks <_@jeremy.ca> const html = document.documentElement.outerHTML; document.open('text/plain'); document.write('view source disabled'); document.close(); document.documentElement.innerHTML = html; }); </script>
- inceptionnames 9y agoNeat. How do people even discover a hack like this?
- JeremyBanks 9y agoIn this case, I was trying to use `document.open()` to replace the document with some text for debugging, and I noticed some strange side effects. :) The starting point was here: https://stackoverflow.com/questions/39233344/does-javascripts-document-open-support-the-mime-type-parameter https://stackoverflow.com/questions/39233344/does-javascript...
- clouddrover 9y agoAlso doesn't work in Safari 11.0.3.
- clouddrover 9y agoWhen I view source in Firefox I get the URL "view-source:wyciwyg://0/https://no-source.github.io/" https://no-source.github.io/" which gives me the "view source disabled" message. But if I then manually edit that in the location bar to "view-source:https://no-source.github.io/" https://no-source.github.io/" I can view the source as expected.