This website (www.samy.pl) uses some technique so that no one can inspect the code
(Ctrl+Shift+I) or view source (Ctrl+U). It can detect if you have opened the console or inspector the code automatically changes.
How this is possible?
This website (www.samy.pl) uses some technique so that no one can inspect the code
(Ctrl+Shift+I) or view source (Ctrl+U). It can detect if you have opened the console or inspector the code automatically changes.
How this is possible?
Share Improve this question edited Apr 13, 2017 at 4:57 MarianD 14.1k12 gold badges48 silver badges59 bronze badges asked Apr 12, 2017 at 23:21 TPS kisanTPS kisan 1291 silver badge5 bronze badges 13- 1 Possible duplicate of How to hide html source & disable right click and text copy? – Adam Commented Apr 12, 2017 at 23:27
- @Adam No, it's not the same as that site. – Barmar Commented Apr 12, 2017 at 23:28
- Press F12 to open your console. Use IE11 to fool their script. – yezzz Commented Apr 12, 2017 at 23:28
- what about if i goto More Tools>Developers Tools or (ctrl+shift+i) option on chrome this website redirect to another page so that no one can see the code of homepage. How to do it then? – TPS kisan Commented Apr 12, 2017 at 23:32
- The site somehow detects when you open the console, and the source changes. – Barmar Commented Apr 12, 2017 at 23:32
10 Answers
Reset to default 4You could always save the website. In chrome open the menu -> more tools -> Save page as..
You should be able to run the html file in chrome, and use Dev Tools without it blocking you.
There is a console
"clearing" API that is mentioned in this answer.
Here's what I think is happening:
First, I think Google Chrome DevTools emits an event when it is open/launched. The page author listens for this 'launch' event with the following handler logic:
- Run a
chrome.devtools.inspectedWindow.eval
DevTools inspection API - Set
document.body.innerHTML
to the winky-face div - Also, a
setInterval
that executes aconsole.clear()
before theconsole.log()
of "no source for you".
I also inspected the EventListeners tab of Chrome DevTools while reading the "no source for you"-page.
Unfortunately, the two event listeners you can view don't seem to do anything useful:
- one returns
false
- the other wires together forms and their associated submit actions.
Hope this helped
hahaha, this is a good one, you should not expect less from samy!
Now I see why people think it is the wrong answer (the source get replaced if you do otherwise)
1.Navigate to site with inspector open there you end up with "No source for you! You found easter egg #7."
2.and then check the source to find Easter egg #2:
view-source:https://samy.pl
you will see:
/*
No source for you! Easter egg #2
*// AFTER SOME LONG WHITE SPACES HERE /.source.replace(/.{7}/g,function(w){document.write(String.fromCharCode(parseInt(w.replace(/ /g,'0').replace(/ /g,'1'),2)))});
This is the way he loads the site(by injecting js), by replacing two type of white spaces for 1 and 0 and parsing that to char code by some regex and then that to string of course :D
https://de.wikipedia.org/wiki/Whitespace_(Programmiersprache)
If you paste that part to a js console, you will get the tags that loads the page.
ps. to see the rendered source, just load the page normaly and hit F12 after disabling javascript.
Have fun!
Create an index.html
somewhere, containing an <iframe src='https://samy.pl/'>
. Load it in your browser and then open devtools. You will see the source inside the iframe.
Update: Go to view-source:http://samy.pl which is the link of what the view source right click brings you to. It only works on Chrome I think.
If you are using chrome, go to the menu at the top right. Then go to more tools, and click developer tools.
After a lot of tinkering and speculating together, my roommate succeeded in the end with quite a naïve approach.
Simply open the Chrome devtools and copy out the source before it gets replaced. Giving Chrome processes low priority and doing some heavy-lifting with your CPU (compilation or other) helps.
Chop, chop.
Ah! I have found an extremely easy way to do it.
1. Open Firefox (Chrome only shows you part of it).
2. In the URL bar, type in javascript:alert(document.documentElement.outerHTML);
3. Press Enter.
4. Voilà!
New Way to find the source code! But its complicated!
Open a new tab.
Open Devtools (Inspect Tab)
Click On Toggle Device toolbar (the mobile like icon)
Click on "No Throttling" to slow down the page loading time
Select "Low - Tier Mobile"
Open the page! When you see the icons appear on the page, you can now see the source code! :)
sorry very late but i think i have the answer
He used this node package to which he has contributed and forked too
the package docs say that it wont work if the devtools are undocked
You can simply use the developer tools in almost all the browsers. Just Press F12 and the developer tools section will be there.
Thanks