Skip to content

Instantly share code, notes, and snippets.

@Illyism
Last active September 23, 2015 20:38
Show Gist options
  • Save Illyism/612153 to your computer and use it in GitHub Desktop.
Save Illyism/612153 to your computer and use it in GitHub Desktop.
if (typeof XMLHttpRequest == "undefined")
XMLHttpRequest = function () {
try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
catch (e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
catch (e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) {}
//Microsoft.XMLHTTP points to Msxml2.XMLHTTP.3.0 and is redundant
throw new Error("This browser does not support XMLHttpRequest.");
};
var xmlHttpReq = XMLHttpRequest();
xmlHttpReq.open("GET", "http://wallbase.cc/toplist?ts=2w", false);
xmlHttpReq.onreadystatechange=function()
{
if (xmlHttpReq.readyState==4 && xmlHttpReq.status==200)
{
var response = xmlHttpReq.responseText;
var re = /<div id="thumb(\d+)" class="thumbnail/;
var result = re.exec(response);
var number = RegExp.$1;
var xmlHttpReq2 = XMLHttpRequest();
xmlHttpReq2.open("GET", "http://wallbase.cc/wallpaper/"+number, false);
xmlHttpReq2.onreadystatechange=function()
{
if (xmlHttpReq2.readyState==4 && xmlHttpReq2.status==200)
{
var thumbresponse = xmlHttpReq2.responseText;
var imgre = /<img src="(.*)" class="wall/;
var iResult = imgre.exec(thumbresponse);
var link = RegExp.$1;
var imageGet = new ActiveXObject("Microsoft.XMLHTTP");
imageGet.open("GET", link, false);
imageGet.send();
var bStrm = new ActiveXObject("Adodb.Stream");
bStrm.type = 1;
bStrm.open();
bStrm.write(imageGet.responseBody);
bStrm.savetofile("C:\\Users\\Administrator\\Desktop\\wallpaper-"+number+".jpg", 2);
var wallpaperSet = new ActiveXObject("Wscript.Shell");
wallpaperSet.RegWrite("HKCU\\Control Panel\\Desktop\\Wallpaper", "C:\\Users\\Administrator\\Desktop\\wallpaper-"+number+".jpg", "REG_SZ");
wallpaperSet.Run("%windir%\\System32\\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, true);
}
}
xmlHttpReq2.send();
}
}
xmlHttpReq.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment