Name: Anonymous 2009-05-10 6:24
Why doesn't my script work?
// @description Creates a large Thumbnail collection from a given Google Image Search
// @include http://images.google.*/*;
// ==/UserScript==
//var Knoten = window.document.images[0];
//window.document.images[0].parentNode.removeChild(Knoten);
function CreateImageObject(ThumbUrl, ImageUrl){
nimghnd = document.createElement('img');
nimghnd.width=96;
nimghnd.height=96;
nimghnd.border=0;
nimghnd.src=ThumbUrl;
nlnkhnd=document.createElement('a');
nlnkhnd.href= ImageUrl.match( /\/imgres\?imgurl\=(.*?)\&imgrefurl\=/ )[1];
nlnkhnd.appendChild(nimghnd);
ntblhnd=document.createElement('table');
ntblhnd.setAttribute('style', 'display:inline;');
ntblhnd.width=140;
ntblhnd.height=140;
ntblhnd.border=0;
ntblhnd.cellPadding=0;
ntblhnd.cellSpacing=0;
ntr1hnd=document.createElement('tr');ntr1hnd.height=22;ntr1hnd.width=140;
ntr2hnd=document.createElement('tr');ntr2hnd.height=96;ntr2hnd.width=140;
ntr3hnd=document.createElement('tr');ntr3hnd.height=22;ntr3hnd.width=140;
ntd11hnd=document.createElement('td');ntd11hnd.width=22;ntd11hnd.height=22;
ntd12hnd=document.createElement('td');ntd12hnd.width=96;ntd12hnd.height=22;
ntd13hnd=document.createElement('td');ntd13hnd.width=22;ntd13hnd.height=22;
ntd21hnd=document.createElement('td');ntd21hnd.width=22;ntd21hnd.height=96;
ntd22hnd=document.createElement('td');ntd22hnd.width=96;ntd22hnd.height=96;
ntd23hnd=document.createElement('td');ntd23hnd.width=22;ntd23hnd.height=96;
ntd31hnd=document.createElement('td');ntd31hnd.width=22;ntd31hnd.height=22;
ntd32hnd=document.createElement('td');ntd32hnd.width=96;ntd32hnd.height=22;
ntd33hnd=document.createElement('td');ntd33hnd.width=22;ntd33hnd.height=22;
ntd11hnd.setAttribute('background', 'http://hansschmucker.free.fr/frame/01.png');
ntd12hnd.setAttribute('background', 'http://hansschmucker.free.fr/frame/02.png');
ntd13hnd.setAttribute('background', 'http://hansschmucker.free.fr/frame/03.png');
ntd21hnd.setAttribute('background', 'http://hansschmucker.free.fr/frame/04.png');
ntd23hnd.setAttribute('background', 'http://hansschmucker.free.fr/frame/06.png');
ntd31hnd.setAttribute('background', 'http://hansschmucker.free.fr/frame/07.png');
ntd32hnd.setAttribute('background', 'http://hansschmucker.free.fr/frame/08.png');
ntd33hnd.setAttribute('background', 'http://hansschmucker.free.fr/frame/09.png');
ntr1hnd.appendChild(ntd11hnd);
ntr1hnd.appendChild(ntd12hnd);
ntr1hnd.appendChild(ntd13hnd);
ntr2hnd.appendChild(ntd21hnd);
ntr2hnd.appendChild(ntd22hnd);
ntr2hnd.appendChild(ntd23hnd);
ntr3hnd.appendChild(ntd31hnd);
ntr3hnd.appendChild(ntd32hnd);
ntr3hnd.appendChild(ntd33hnd);
ntblhnd.appendChild(ntr1hnd);
ntblhnd.appendChild(ntr2hnd);
ntblhnd.appendChild(ntr3hnd);
ntd22hnd.appendChild(nlnkhnd);
return ntblhnd;
}
function Simplify(Source,Target){
var tblnum=8;
var tblhnd=Source.getElementsByTagName("table")[tblnum];
var imgnum=1;
for (var n = 0; n < 5; n++){
var tblhnd=Source.getElementsByTagName("table")[tblnum];
var lnkhnd=Source.getElementsByTagName("a")[tblnum];
for (var i = 0; i < 4; i++){
var imghnd= tblhnd.getElementsByTagName( "img")[ i];
var lnkhnd= tblhnd.getElementsByTagName( "a")[ i];
if (imghnd) {
ntblhnd=CreateImageObject(imghnd.src,lnkhnd.href);
Target.appendChild(ntblhnd);
}
}
if(tblhnd){
Source.getElementsByTagName("table")[tblnum].parentNode.removeChild(tblhnd);
}
}
}
prev=top.document.getElementsByTagName("body")[0];
if(top.location.href==self.location.href){
var lnbrk=document.createElement('p');
prev.appendChild(lnbrk);
var page1=document.createElement('iframe');
page1.src=self.location.href+"&theresadifference=intheurl";
page1.width=1;
page1.height=1;
page1.border=0;
page1.id="page1";
lnbrk.appendChild(page1);
for(i=1;i<12;i++){
srchref= top.document.getElementsByTagName("div")[0].getElementsByTagName("a")[i].href;
if((!srchref.match( /.*prev.*/ )) && (!srchref.match( /.*next.*/ )) && srchref.match( /.*images\.google.*/ )){
var page1=document.createElement('iframe');
page1.src=srchref;
page1.width=1;
page1.height=1;
page1.border=0;
page1.id="page1";
lnbrk.appendChild(page1);
}
}
}else{
prev=top.document.getElementsByTagName("body")[0];
Simplify(document,prev);
self.close;
}