我猜这是个毫无用处的问题,但了解 facebook 如何在不引用脚本的情况下打印到浏览器控制台真的很有趣。打开 facebook.com 的控制台,您将看到文本,但看不到对 javascript 的引用...
最佳答案
好吧,我 friend 的 friend 找到了答案。
对于没有引用的console.log,我们应该使用setTimout和bind
setTimeout(console.log.bind(console, 'test'));
这是整个 Facebook 片段:
var i = "Stop!",
j = "This is a browser feature intended for developers. If someone told you to copy-paste something here to enable a Facebook feature or \"hack\" someone's account, it is a scam and will give them access to your Facebook account.";
if ((window.chrome || window.safari)) {
var l = 'font-family:helvetica; font-size:20px; ';
[
[i, l + 'font-size:50px; font-weight:bold; ' + 'color:red; -webkit-text-stroke:1px black;'],
[j, l],
['', '']
].map(function(r) {
setTimeout(console.log.bind(console, '\n%c' + r[0], r[1]));
});
}
关于javascript - 未引用脚本的 Console.log,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25587201/