前段时间在一个论坛上浏览图片,觉得相当不错,于是想把它们保存下来,后来就写了一个Maxthon插件来自动化这一个过程,本插件调用迅雷来下载图片文件:
plugin.ini
[General]
Name=MaxthonGetImg
Author=Maxthon
Version=1.0
ModuleType=SCRIPT
FileName=getimg.htm
Comments=Get Images
Type=M2Plugin_BUTTON
HotIcon=hot.ico
Icon=cold.ico
getimg.htm
<mscript language="javascript">
var window=external.get_tab(%max_security_id, external.cur_sel);
var document = window.document;
var imgs = document.getElementsByTagName("img");
var title = document.title;
if(title==null || title==undefined || title=='')
{
title="File"+new Date().getTime();
}
title=title.replace(/[?\\/:"<>\|\*\s]/g,"");
var ThunderAgent = new ActiveXObject("ThunderAgent.Agent.1");
var folder="D:\\下载的图片\\"+title;
var file="D:\\下载的图片\\"+title+"\\stat.htm";
var jpegFileCount = 0;
var fso, tf;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (!fso.FolderExists(folder))
{
fso.CreateFolder(folder);
}
if (fso.FileExists(file))
{
fso.DeleteFile(file, true);
}
tf = fso.CreateTextFile(file, true);
for(img in imgs)
{
var imgsrc=imgs[img].src;
if(imgsrc!=null &&
imgsrc!=undefined && (imgsrc.indexOf('.jpg')!=-1 || imgsrc.indexOf('.jpeg')!=-1 ))
{
jpegFileCount++;
tf.WriteLine("* "+"<a href='"+imgsrc+"'" +">"+imgsrc+"</a><br />");
ThunderAgent.AddTask(imgsrc, imgsrc, folder, imgsrc, window.location.href, -1, 0, -1);
ThunderAgent.CommitTasks2(1);
}
else
{
if(imgsrc!=undefined)
{
tf.WriteLine(" "+imgsrc+"<br />");
}
}
}
tf.WriteBlankLines(2);
tf.WriteLine("Total image file count:"+imgs.length+"<br />");
tf.WriteLine("JPEG file count:"+jpegFileCount+"<br />");
tf.Close();
//ThunderAgent.CommitTasks2(1);
window.status='Finished';
</mscript>
迅雷也要设置一下:工具->配置->高级->操作提示,显示提示,全部取消
这样添加任务的时候就不会有确认操作了
plugin.ini
[General]
Name=MaxthonGetImg
Author=Maxthon
Version=1.0
ModuleType=SCRIPT
FileName=getimg.htm
Comments=Get Images
Type=M2Plugin_BUTTON
HotIcon=hot.ico
Icon=cold.ico
getimg.htm
<mscript language="javascript">
var window=external.get_tab(%max_security_id, external.cur_sel);
var document = window.document;
var imgs = document.getElementsByTagName("img");
var title = document.title;
if(title==null || title==undefined || title=='')
{
title="File"+new Date().getTime();
}
title=title.replace(/[?\\/:"<>\|\*\s]/g,"");
var ThunderAgent = new ActiveXObject("ThunderAgent.Agent.1");
var folder="D:\\下载的图片\\"+title;
var file="D:\\下载的图片\\"+title+"\\stat.htm";
var jpegFileCount = 0;
var fso, tf;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (!fso.FolderExists(folder))
{
fso.CreateFolder(folder);
}
if (fso.FileExists(file))
{
fso.DeleteFile(file, true);
}
tf = fso.CreateTextFile(file, true);
for(img in imgs)
{
var imgsrc=imgs[img].src;
if(imgsrc!=null &&
imgsrc!=undefined && (imgsrc.indexOf('.jpg')!=-1 || imgsrc.indexOf('.jpeg')!=-1 ))
{
jpegFileCount++;
tf.WriteLine("* "+"<a href='"+imgsrc+"'" +">"+imgsrc+"</a><br />");
ThunderAgent.AddTask(imgsrc, imgsrc, folder, imgsrc, window.location.href, -1, 0, -1);
ThunderAgent.CommitTasks2(1);
}
else
{
if(imgsrc!=undefined)
{
tf.WriteLine(" "+imgsrc+"<br />");
}
}
}
tf.WriteBlankLines(2);
tf.WriteLine("Total image file count:"+imgs.length+"<br />");
tf.WriteLine("JPEG file count:"+jpegFileCount+"<br />");
tf.Close();
//ThunderAgent.CommitTasks2(1);
window.status='Finished';
</mscript>
迅雷也要设置一下:工具->配置->高级->操作提示,显示提示,全部取消
这样添加任务的时候就不会有确认操作了
浙公网安备 33010602011771号