(function(){chrome.runtime.onMessage.addListener(function(a){switch(a.cmd){case "g_links":a=function(b,h,k){if(b&&h)for(var d=0,l=b.length;d<l;++d){var f=b[d][h];g.test(f)&&c[f]==void 0&&(e.push({url:f,desc:b[d].download||"",text:k?b[d][k]||"":"",title:b[d].title||"",referer:""}),c[f]=1)}};const e=[],g=RegExp("^(((ftp|https?)://)|(data:)).+$","i"),c={};a(document.links,"href","text");a(document.images,"src","alt");a(document.getElementsByTagName("audio"),"src");a(document.getElementsByTagName("video"),"src");
a(document.getElementsByTagName("source"),"src");a(document.getElementsByTagName("script"),"src");a(document.getElementsByTagName("link"),"href");e.length>0&&chrome.runtime.sendMessage({cmd:"add_links",data:e})}});
document.addEventListener("mousedown",function(a){function e(b){for(;b&&b.tagName;){if(b.tagName.toLowerCase()=="a")return b;b=b.parentNode}return null}function g(b){for(;b;){if(b.src)return b;b=b.parentNode}return null}if(a.button>=0&&a.button<=2){var c=e(a.target);c&&c.href&&c.href[0]!="j"&&c.href.length<2048&&chrome.runtime.sendMessage({cmd:"url_desc",url:c.href,download:(c.download||"").trim(),text:(c.text||"").trim(),title:(c.title||"").trim()});(a=g(a.target))&&a.src&&a.src.length<2048&&chrome.runtime.sendMessage({cmd:"url_desc",
url:a.src,download:(a.download||"").trim(),text:(a.alt||"").trim(),title:(a.title||"").trim()})}},!0);}).call(this);
