Skip to content

Instantly share code, notes, and snippets.

@dim0xff
Created October 21, 2014 06:23
Show Gist options
  • Save dim0xff/6a646f5861d3617ff081 to your computer and use it in GitHub Desktop.
Save dim0xff/6a646f5861d3617ff081 to your computer and use it in GitHub Desktop.
javascript:(function () {
var $j, getPage, add_scripts;
getPage = function (num) {
$j.get('http://gaga.aliexpress.com/?page=' + num).done(function (data) {
var $products = $j('#products-wrap');
var $children = $j(data).find('#products-wrap').children();
if ($children.length) {
$children.each(function (idx, el) {
$j(el).appendTo($products);
});
getPage(num + 1);
}
});
};
add_scripts = function (array, callback) {
var loader = function (src, handler) {
var script = document.createElement('script');
script.src = src;
script.onload = script.onreadystatechange = function () {
script.onreadystatechange = script.onload = null;
handler();
};
var head = document.getElementsByTagName('head') [0];
(head || document.body).appendChild(script);
};
(function () {
if (array.length != 0) {
loader(array.shift(), arguments.callee);
}
else {
callback && callback();
}
}) ();
};
add_scripts(['//code.jquery.com/jquery-1.11.0.min.js'], function () {
$j = jQuery.noConflict();
$j('#products-wrap').html('');
getPage(1);
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment