If you have looked at the javscript source code of Google, you may have noticed that code is not intitutive, like this below code:
1. Prettify
Now the first step is to Prettify the source code. This is what it looks like after using the Prettify tool.
Most modern browser support this feature in Developer Tools. Please read here for How to use Prettify Tool.
2. Javascript Debugger: Apply breakpoints and find HTML events to insert breakpoint.
3. Find the Function Definition
01
02
03
04
05
06
07
08
09
10
| ( function (){google.lc=[];google.li=0;google.getEI= function (a){ for ( var b;a&&(!a.getAttribute||!(b=a.getAttribute( "eid" )));)a=a.parentNode; return b||google.kEI}; google.getLEI= function (a){ for ( var b= null ;a&&(!a.getAttribute||!(b=a.getAttribute( "leid" )));)a=a.parentNode; return b}; google.https= function (){ return "https:" ==window.location.protocol};google.ml= function (){}; google.time= function (){ return ( new Date).getTime()};google.log= function (a,b,e,f,l){ var d= new Image,h=google.lc,g=google.li,c= "" ,m=google.ls|| "" ; d.onerror=d.onload=d.onabort= function (){ delete h[g]};h[g]=d; if (!e&&-1==b.search( "&ei=" )){ var k=google.getEI(f),c= "&ei=" +k; -1==b.search( "&lei=" )&&((f=google.getLEI(f))?c+= "&lei=" +f:k!=google.kEI&&(c+= "&lei=" +google.kEI))} a=e|| "/" +(l|| "gen_204" )+ "?atyp=i&ct=" +a+ "&cad=" +b+c+m+ "&zx=" +google.time();/^http:/i.test(a)&&google.https()?(google.ml(Error( "a" ),!1,{src:a,glmm:1}), delete h[g]):(window.google&&window.google.vel&&window.google.vel.lu&&window.google.vel.lu(a), d.src=a,google.li=g+1)};google.y={};google.x= function (a,b){google.y[a.id]=[a,b]; return !1};google.load= function (a,b,e){google.x({id:a+n++}, function (){google.load(a,b,e)})}; var n=0;})();google.kCSI={}; |
(function(){google.lc=[];google.li=0;google.getEI=function(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||google.kEI}; google.getLEI=function(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b}; google.https=function(){return"https:"==window.location.protocol};google.ml=function(){}; google.time=function(){return(new Date).getTime()};google.log=function(a,b,e,f,l){var d=new Image,h=google.lc,g=google.li,c="",m=google.ls||""; d.onerror=d.onload=d.onabort=function(){delete h[g]};h[g]=d;if(!e&&-1==b.search("&ei=")){var k=google.getEI(f),c="&ei="+k; -1==b.search("&lei=")&&((f=google.getLEI(f))?c+="&lei="+f:k!=google.kEI&&(c+="&lei="+google.kEI))} a=e||"/"+(l||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+c+m+"&zx="+google.time();/^http:/i.test(a)&&google.https()?(google.ml(Error("a"),!1,{src:a,glmm:1}), delete h[g]):(window.google&&window.google.vel&&window.google.vel.lu&&window.google.vel.lu(a), d.src=a,google.li=g+1)};google.y={};google.x=function(a,b){google.y[a.id]=[a,b];return!1};google.load=function(a,b,e){google.x({id:a+n++}, function(){google.load(a,b,e)})};var n=0;})();google.kCSI={};
(function(){google.lc=[];google.li=0;google.getEI=function(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||google.kEI};google.getLEI=function(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b};google.https=function(){return"https:"==window.location.protocol};google.ml=function(){};google.time=function(){return(new Date).getTime()};google.log=function(a,b,e,f,l){var d=new Image,h=google.lc,g=google.li,c="",m=google.ls||"";d.onerror=d.onload=d.onabort=function(){delete h[g]};h[g]=d;if(!e&&-1==b.search("&ei=")){var k=google.getEI(f),c="&ei="+k;-1==b.search("&lei=")&&((f=google.getLEI(f))?c+="&lei="+f:k!=google.kEI&&(c+="&lei="+google.kEI))}a=e||"/"+(l||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+c+m+"&zx="+google.time();/^http:/i.test(a)&&google.https()?(google.ml(Error("a"),!1,{src:a,glmm:1}),delete h[g]):(window.google&&window.google.vel&& window.google.vel.lu&&window.google.vel.lu(a),d.src=a,google.li=g+1)};google.y={};google.x=function(a,b){google.y[a.id]=[a,b];return!1};google.load=function(a,b,e){google.x({id:a+n++},function(){google.load(a,b,e)})};var n=0;})();google.kCSI={};
1. Prettify
Now the first step is to Prettify the source code. This is what it looks like after using the Prettify tool.
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| ( function () { google.lc = [ ]; google.li = 0; google.getEI = function (a) { for ( var b; a && (!a.getAttribute || !(b = a.getAttribute( 'eid' ))); ) a = a.parentNode; return b || google.kEI }; In = function (a, b, c) { a.ma = c ? Kn(b, !0) : b; }; Jn = function (a, b, c) { b instanceof Ln ? (a.$ = b, gra(a.$, a.ga)) : (c || (b = Mn(b, hra)), a.$ = new Ln(b, 0, a.ga)); return a; }; Nn = function (a) { return a.$; }; var n = 0; }) (); google.kCSI = { }; |
(function () { google.lc = [ ]; google.li = 0; google.getEI = function (a) { for (var b; a && (!a.getAttribute || !(b = a.getAttribute('eid'))); ) a = a.parentNode; return b || google.kEI }; In = function (a, b, c) { a.ma = c ? Kn(b, !0) : b; }; Jn = function (a, b, c) { b instanceof Ln ? (a.$ = b, gra(a.$, a.ga)) : (c || (b = Mn(b, hra)), a.$ = new Ln(b, 0, a.ga)); return a; }; Nn = function (a) { return a.$; }; var n = 0; }) (); google.kCSI = { };
Most modern browser support this feature in Developer Tools. Please read here for How to use Prettify Tool.
2. Javascript Debugger: Apply breakpoints and find HTML events to insert breakpoint.
3. Find the Function Definition
- Copy the code to Notepad++ IDE.
- Open the Find tool, Ctrl+ F
- Set the 'Match case', 'Wrap around'
- Set the Search Mode to 'Regular expression' and set the '. matches newline'
- Insert the below snippet in the 'Find what:'
1
| ^\s*funcName\s*=\s* function |
^\s*funcName\s*=\s*function
6. Replace the funcName with the name of the function you want to search.
Note: Escape the character with '\' backslash for special characters like .,_-*+ etc
No comments:
Post a Comment