Skip to content

Instantly share code, notes, and snippets.

@tomorrowkey
Created November 9, 2012 08:16
Show Gist options
  • Save tomorrowkey/4044398 to your computer and use it in GitHub Desktop.
Save tomorrowkey/4044398 to your computer and use it in GitHub Desktop.
expand all tree on google site's sitemap
javascript:(function(){var t=document.getElementsByClassName('goog-tree-expand-icon-tplus');var e=document.createEvent('MouseEvents');e.initMouseEvent('mousedown',true,true,window,0,0,0,0,0,false,false,false,false,0,null);while(t.length>0){t[0].dispatchEvent(e);}})()
var t=document.getElementsByClassName('goog-tree-expand-icon-tplus');
var e=document.createEvent('MouseEvents');
e.initMouseEvent('mousedown',true,true,window,0,0,0,0,0,false,false,false,false,0,null);
while(t.length > 0){
t[0].dispatchEvent(e);
}
@sys1yagi
Copy link

sys1yagi commented Nov 9, 2012

(function(){
var t = 1000;
var r = 3;
var s = function(k){
return document.getElementsByClassName('goog-tree-expand-icon-'+k);
};
var d = function(p){
var e=document.createEvent('MouseEvents');
e.initMouseEvent('mousedown',true,true,window,0,0,0,0,0,false,false,false,false,0,null);
while(p.length>0){
p[0].dispatchEvent(e);
}
};
var c = function(){
var p=s("tplus");
var ps = p.length;
d(p);
var l=s("lplus");
var ls = l.length;
d(l);
if(r>0){
if(ps + ls == 0){
console.log("retry");
r--;
}
setTimeout(function(){
c();
}, t);
}
};
c();
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment