javascript – 有人可以解释一下Google主页JS吗?

前端之家收集整理的这篇文章主要介绍了javascript – 有人可以解释一下Google主页JS吗?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
以下是Google主页上的一些“奇怪”代码段.(google.com/ncr即是)
({"s":{"#":[{"h":"ad","g":["Google","E4hE342CDKOgAFYm15AW","1",1]},{"h":"p","g":["ghead",",0]},"g":["footer","

","g":["body","g":["xjsi","

然后有这个:

<script>if(google.y)google.y.first=[];if(google.y)google.y.first=[];if(!google.xjs){google.dstr=[];google.rein=[];window.setTimeout(function(){var a=document.createElement(\"script\");a.src=\"/extern_js/f/CgJlbiswCjhMQAgsKzAOOAosKzAWOBQsKzAXOAQsKzAYOAQsKzAZOA0sKzAdOBssKzAhOCtAASwrMCU4yYgBLCswJjgILCswJzgCLCswKjgCLCswKzgJLCswPDgCLCswQDgFLCswRDgALCswRTgALA/JqRMsHQD1vo.js\";(document.getElementById(\"xjsd\")||document.body).appendChild(a);if(google.timers&&google.timers.load.t)google.timers.load.t.xjsls=(new Date).getTime();},0);\u000agoogle.xjs=1};google.y.first.push(function(){google.ac.m=1;google.ac.b=true;google.ac.i(document.f,document.f.q,'','OvaKevzR5YKoeJu2mSddyQ');(function(){\u000avar a=window.google.f={};a.f=1;a.s=1;a.a=(new Date).getTime();google.rein.push(function(){a.f=1;a.s=1;a.a=(new Date).getTime()});google.dstr.push(function(){google.fade=null});function m(b,g,e,f){var d,c=[],i=[];for(var h=0,k;k=b[h++];){var l=document.getElementById(k);if(l)c.push(l)}for(var h=0,j;j=g[h++];){var o=n(j[0],j[1]);while(d=o.pop())c.push(d)}while(d=c.pop())i.push([d,\"opacity\",f,\"\"]);return i}function n(b,\u000ag){var e=[];for(var f=document.getElementsByTagName(b),d=0,c=f[d];c=f[d++];)if(c.className==g)e.push(c);return e}google.fade=function(b){b=b||window.event;var g=1;if(b&&b.type==\"mousemove\"){var e=b.clientX,f=b.clientY;g=a.x||a.y?Math.abs(a.x-e)+Math.abs(a.y-f):0;a.x=e;a.y=f}var d=(new Date).getTime(),c=d-a.a;if(google.fx&&g&&c>602)if(a.f){a.f=0;var i=[\"fctr\",\"ghead\",\u000a\"pmocntr\",\"sbl\",\"tba\",\"tbe\"],h=[[\"span\",\"fade\"],[\"div\",\"gbh\"]];google.fx.animate(602,m(i,h,1))}};\u000a})();\u000a});if(google.j&&google.j.en&&google.j.xi){window.setTimeout(google.j.xi,0);google.fade=null;}</script>",{"h":"zz","g":[0,1]}]},"c":{"1":{"cc":[],"co":["ghead","body","footer","xjsi"],"pc":[],"nb":0,"css":"td{line-height:.8em;}.gac_m td{line-height:17px;}form{margin-bottom:20px;}body,td,a,p,.h{font-family:arial,sans-serif}.h{color:#36c;font-size:20px}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}em{font-weight:bold;font-style:normal}.lst{font:17px arial,sans-serif;margin-bottom:.2em;vertical-align:bottom;}input{font-family:inherit}.lsb,.gac_sb{font-size:15px;height:1.85em!important;margin:.2em;}#fctr,#ghead,#pmocntr,#sbl,#tba,#tbe,.fade{opacity:0;}#fctr,.fade{background:#fff;}#gbar{float:left;height:22px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbs,.gbm{background:#fff;left:0;position:absolute;text-align:left;visibility:hidden;z-index:1000}.gbm{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important;text-align:right}#gbar,#guser{font-size:13px;padding-top:1px !important}.gb1,.gb3,.gb3i,.gb3f{zoom:1;margin-right:.5em}.gb2,.gb2i,.gb2f{display:block;padding:.2em .5em}a.gb1,a.gb2,a.gb3,a.gb4{color:#00c !important}.gb2,.gb2f,.gb3f{text-decoration:none}a.gb2:hover{background:#36c;color:#fff !important}","main":"<div id=ghead></div><span id=body></span><span id=footer></span><span id=xjsi></span>"}}})

这是一个非常有趣的:

onload=\"window.lol&amp;&amp;lol()\"

为什么他们逃避一切?

这似乎很自我解释:

onblur=\"google&amp;&amp;google.fade&amp;&amp;google.fade()\"

如果您能解释上述任何一项,请欣赏它.
谢谢!

解决方法

早期的例子基本上只是缩小(删除空格,使用短变量名等),以减小页面的大小.

至于:

onload=\"window.lol&amp;&amp;lol()\"

页面实际上有:

onload="window.lol&amp;&amp;lol()"

它有& amp;因为&必须以这种方式在HTML中表示(除了CDATA块,属性值永远不会).所以它意味着:

window.lol && lol();

意思是:

If the window object has a property called lol,execute that property as a function.

在第一个实例中使用显式窗口对象是为了在没有定义属性时阻止它出错,并且在第二个实例中缺少使用它是为了减小页面的大小(因为在调用函数时隐含了窗口)这不是另一个对象的明确方法).

原文链接:https://www.f2er.com/js/159641.html

猜你在找的JavaScript相关文章