All pastes #476505 Raw Edit

show_all.user.js

public javascript v1 · immutable
·published 2007-05-08 03:43 UTC
rendered paste body
// ==UserScript==// @name           show_all// @namespace      http://gnaa.us// @description    shows all pictures// @include        http://thousandbabes.com/// ==/UserScript==GM_log("gogogo");function getimgsrc(doc, rurl, outdoc, lol){    // find the url in the document.  use string processing because    // no way to parse html for DOM.  maybe when firefox 3 comes out?    maindiv = doc.indexOf('<div class="main"');    imgtag = doc.indexOf('<img', maindiv)+10;    imgurl = doc.indexOf('"', imgtag)+1;    endex = doc.indexOf('"', imgurl);    realimgsrc = doc.slice(imgurl, endex);    imgsrc = "spoof"+realimgsrc.slice(4,realimgsrc.length)+";ref"+rurl.slice(4,rurl.length);    // lets make a <p/> to put this <img/> in    newimg = outdoc.createElement("img");    newimg.src = imgsrc;    newp = outdoc.createElement("p");    newp.id = lol;    newp.appendChild(newimg);    // ok, find where in the outdoc's DOM to insert.    // iirc, this is called 'insertion sort'    ps = outdoc.getElementsByTagName("p");    if(ps.length<1){	    outdoc.body.appendChild(newp);    }    else{	bottom = 0;	top = ps.length-1;	while(true){	    if(top-bottom <= 1){		if(ps[bottom].id > lol){		    insertbefore = bottom;		} else if(ps[top].id > lol){		    insertbefore = top;		}		else{		    insertbefore = top+1;		}		break;	    }	    i = Math.round(bottom+(top-bottom)/2);	    if(ps[i].id > lol){		top = i;	    }	    else if(ps[i].id <= lol){		bottom = i;	    }	}	if(insertbefore<ps.length){	    outdoc.body.insertBefore(newp, ps[insertbefore]);	}	else{	    outdoc.body.appendChild(newp);	}    }    //    outdoc.write("<p><img src='"+imgsrc+"'/></p>");    // when firefox 3 comes out    /*    parser = new DOMParser();    domdoc = parser.parseFromString(doc, "application/xml");    divs = domdoc.getElementsByTagName("div");    for(i=0;i<divs.length;i++){	if(divs[i].className=="main"){	    maindiv=i;	    break;	}    }    imgsrc = divs[maindiv].lastChild.getElementsByTagName("img")[0].src;    */}function showallimages(){    divs = document.getElementsByTagName("div");    for(i=0;i<divs.length;i++){	if(divs[i].className=="main"){	    maindiv=i;	    break;	}    }    thediv = divs[maindiv].getElementsByTagName("div")[0]    tables = thediv.getElementsByTagName("table");    for(i=tables.length-1; i>-1; i--){	if(tables[i].parentNode==thediv){	    table = tables[i];	    break;	}    }        links = table.getElementsByTagName("a");    protolink = links[0].href.slice(0,links[0].href.lastIndexOf("/"));    outdoc = open().document;        function currygetimgsrc(r,d,i){	function getimgsrccurry(t){	    setTimeout(getimgsrc(t.responseText,r,d,i), i*30);	}	return getimgsrccurry;    }    for(i=0; i<links.length; i++){	if(links[i].href.slice(0,protolink.length)==protolink){	    GM_xmlhttpRequest({		        method: "GET",			url: links[i].href,			onload: currygetimgsrc(links[i].href,outdoc,i)			});	}    }}GM_registerMenuCommand("show_all",showallimages);