-
Notifications
You must be signed in to change notification settings - Fork 3
/
nyan.js
4 lines (4 loc) · 2.29 KB
/
nyan.js
1
2
3
4
/**
* Created by Raka on 2/21/17.
*/
!function(a){"use strict";console.info("Loaded"),a.nyangrab=function(b,c){function f(b,c){var d={result:[]};return"[object Array]"===Object.prototype.toString.call(b)&&a.each(b,function(b,e){if(e.loop)a.each(a(c).find(e.selector),function(b){var c=a(this),f={};a.each(e.result,function(a,d){var e=c.find(d.find),g="";if("text"==d.grab.by?g=e.text():"html"==d.grab.by?g=e.html():"val"==d.grab.by?g=e.val():"attr"==d.grab.by&&(g=e.attr(d.grab.value)),void 0!=d.format){var h;h=d.format.replace("{{index:num}}",b+1),h=h.replace("{{data}}",g),g=h}if(void 0!=d.grab.custom){"function"==typeof d.grab.custom&&(g=d.grab.custom(g))}f[d.name]=g}),d.result.push(f)});else{var f=a(c).find(e.selector+":eq(0)"),g={};a.each(e.result,function(b,c){var d=f.find(c.find),e="",h=[];if(c.loop?a.each(d,function(b){var d=a(this);if("text"==c.grab.by?e=d.text():"html"==c.grab.by?e=d.html():"val"==c.grab.by?e=qw.val():"attr"==c.grab.by&&(e=d.attr(c.grab.value)),void 0!=c.format){var f;f=f.replace("{{data}}",e),f=c.format.replace("{{index:num}}",indexnum+1),e=f}if(void 0!=c.grab.custom){var g={};c.grab.custom&&"[object Function]"===g.toString.call(c.grab.custom)&&(e=c.grab.custom(e))}h.push(e),e=h}):"text"==c.grab.by?e=d.text():"val"==c.grab.by?e=qw.val():"html"==c.grab.by?e=d.html():"attr"==c.grab.by&&(e=d.attr(c.grab.value)),null==c.replace&&void 0==c.replace||(e=e.replace(c.replace[0],c.replace[1])),void 0!=c.format){var i;i=i.replace("{{data}}",e),i=c.format.replace("{{index:num}}",indexnum+1),e=i}if(void 0!=c.grab.custom){var j={};c.grab.custom&&"[object Function]"===j.toString.call(c.grab.custom)&&(e=c.grab.custom(e))}g[c.name]=e}),d.result.push(g)}}),h("Preparing Output"),d}function g(b){h("Cleaning Response");var c=a("<div>"+b+"</div>");return c.find("style").remove(),c.find("script").remove(),c.find("iframe").remove(),c.find("embed").remove(),c.html()}function h(a){e.isDebug&&console.info(Date()+" - "+a)}var e={isDebug:!1};h("Getting Content"),a.each(b,function(d,e){var i="";a.ajax({url:"https://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent('select content from data.headers where url="'+e.url+'"')+"&format=xml&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys",async:!0}).done(function(d){h("Prosessing Response");var e=a(d).find("content").text();i=g(e),c(f(b,i))})})}}(jQuery);