// ==UserScript== // @name Maknyos AutoIn // @namespace http://userscripts.org/scripts/show/91629 // @version 3.6.2 // @description Auto submit to get link // @homepageURL https://greasyfork.org/scripts/97 // @author Idx // @include /^https?://(.+\.)2shared.com/*/ // @include /^https?://(.+\.)zippyshare.com/v/*/ // @include /^https?://(|www\.)fileswap.com/*/ // @include /^https?://(|www\.)mediafire.com/*/ // @include /^https?://(|www\.)sendspace.com/file/*/ // @include /^https?://(|www\.)firedrive.com/*/ // @include /^https?://(|www\.)uptobox.com/*/ // @include /^https?://(|www\.)howfile.com/file/*/ // @include /^https?://(|www\.)uppit.com/*/ // @include /^https?://(|\w+\.)idup.in/*/ // @include /^https?://(|www\.)imzupload.com/*/ // @include /^https?://(|www\.)jumbofiles.com/*/ // @include /^https?://(|www\.)sendmyway.com/*/ // @include /^https?://(|www\.)tusfiles.net/*/ // @include /^https?://(|www\.)dropbox.com/s/*/ // @include /^https?://(|www\.)solidfiles.com/d/*/ // @include /^https?://(|www\.)yadi.sk/i/*/ // @include /^https?://(|www\.)datafilehost.com/d/*/ // @include /^https?://(|www\.)userscloud.com/*/ // @include /^https?://app.box.com/s/*/ // // @downloadURL none // ==/UserScript== (function() { var gvar=function(){}; gvar.__DEBUG__ = !1; function MaknyosHelper(baseURI){ this.baseURI=baseURI; this.domain=null; this.action=new Actions(); } MaknyosHelper.prototype = { matchDomain: function(){ var domain = this.baseURI.match(/^https?:\/\/([^\/]+)\//); if(domain) this.domain=domain[1]; return this; }, matchAction: function(){ if(this.domain) this.action.find(this.domain); return this; }, invokeAction: function(){ if(this.action.invoked){ this.action.baseCleanUp(); this.action.invoked(); } return this; }, }; function Actions(){ this.invoked=null; } Actions.prototype = { find: function(domain){ this.clog('Actions:find, domain='+domain); var isMatch; var pattern; for(var key in this.patterns){ pattern = this.patterns[key]; this.clog('pattern-check: '+pattern.rule+' vs '+domain); isMatch = typeof pattern.rule === 'string' ? pattern.rule == domain : pattern.rule.test(domain); if(isMatch){ this.invoked = pattern.run; return; } } }, get_href: function(){ return location.href; }, set_href: function(x){ location.href = x; }, // do waitwhat -> thenwhat waitforit: function(waitwhat, thenwhat, delay){ var stoWait, itry = 0, maxtry = 100, thenwhatwrap = function(){ ('function' == typeof thenwhat ) && thenwhat(); }; if( !delay ) delay = 0; if('function' == typeof waitwhat){ var waitwrap = function(){ itry++; if( waitwhat() ){ stoWait && clearTimeout( stoWait ) thenwhatwrap(); } else{ if( itry < maxtry ) waitwrap() } }, stoWait = setTimeout(waitwrap, delay+1000); } else thenwhatwrap(); }, // load url to an iframe frameload: function(url){ var body, cb_fn, idfrm = 'xMNyFrame'; var iframe = document.createElement('iframe'); if( g('#'+idfrm) ) g('#'+idfrm).removeChild() iframe.setAttribute('id', idfrm); iframe.setAttribute('title', "iFrame of "+idfrm+"; src="+url); iframe.setAttribute('style', 'position:absolute; z-index:999999; '+(gvar.__DEBUG__ ? 'border:1px solid #000; width:100%;' : 'border:0; height:0; width:0; left:-9999; bottom:9999')); iframe.setAttribute('src', url); body = g('body'); if( gvar.__DEBUG__ ) body.insertBefore(iframe, body.firstChild); else g('body').appendChild(iframe); if( g('#'+idfrm) ) this.clog("iframe created, src="+url); else this.clog("error while creating iframe"); }, // resize capcay rezCapcay: function(target, dims){ if(!target) return; if(dims.length){ var styleStr=''; dims[0] && (styleStr += 'width:'+dims[0]+'px;'); dims[1] && (styleStr += 'height:'+dims[1]+'px;'); target.setAttribute('style', styleStr); } }, disableWindowOpen: function(){ if(unsafeWindow){ unsafeWindow.open = function(){}; } if(window){ window.open = function(){}; } }, // basic cleanup document from anoying things // eg. iframe, onclick body, etc baseCleanUp: function(){ this.clog("killing frames.."); this.killframes(); this.clog("killing click events."); this.killevents(null, 'click'); }, // brutaly kill frames killframes: function(par){ !par && (par = document); var o = par.getElementsByTagName('iframe'); for(var i=o.length-1;i>=0;i--) o[i].parentNode.removeChild(o[i]); this.clog("killframes done"); }, killevents: function(par, type, handle){ !type && (type = 'click'); !par && (par = document); !handle && (handle = function(){}); var o = par.getElementsByTagName('*'); for(var i=o.length-1;i>=0;i--){ if ( o[i].removeEventListener ) { o[i].removeAttribute("on"+type); //W3C Standard o[i].removeEventListener( type, handle, true ); } } this.clog("killevents done"); }, isVisible: function (ele) { return ele.clientWidth !== 0 && ele.clientHeight !== 0 && ele.style.opacity !== 0 && ele.style.visibility !== 'hidden'; }, show_alert: function(msg, force) { if(arguments.callee.counter) { arguments.callee.counter++ }else { arguments.callee.counter = 1 } if("function" == typeof GM_log) GM_log("(" + arguments.callee.counter + ") " + msg); else console && console.log && console.log(msg); if( force == 0 ) return }, clog: function(x){ if( !gvar.__DEBUG__ ) return x && this.show_alert(["string","number"].indexOf(typeof x) != -1 ? x : JSON.stringify(x)) } }; Actions.prototype.patterns = { sendspace: { rule: /sendspace\.com/, run: function(){ this.clog('inside sendspace'); g('#download_button') && SimulateMouse(g('#download_button'), "click", true); } }, zippyshare: { rule: /zippyshare\.com/, run: function(){ this.clog('inside zippyshare'); var btn = g("[alt*=Download]"); if( btn ) { btn = btn.parentNode; this.waitforit(function(){ return /(?:\.zippyshare\.com)?\/d\/.+/.test( btn.getAttribute("href") ); }, function(){ btn && SimulateMouse(btn, "click", true); }); } } }, mediafire: { rule: /mediafire\.com/, run: function(){ var dcg, selector, that, is_match_path = /mediafire\.com\/(view|download)\b/; that = this; if( !is_match_path.test(that.get_href()) ) return; that.clog('inside mediafire, '+that.get_href()); setTimeout(function(){ that.killframes() }, 123); if( dcg = g("#docControlGroup") ){ selector = './/a[contains(@target,"_blank")]'; selector = xp(selector, dcg, true); selector && that.set_href(selector.getAttribute('href')) } else { that.waitforit(function(){ return g('.download_link a'); }, function(){ SimulateMouse(g('.download_link a'), "click", true); }, 100); } } }, fileswap: { rule: /\.fileswap\.com/, run: function(){ this.clog('inside fileswap'); var tgtBtn = g('[id*="share_index_"][href*="/download/"]'); if( !tgtBtn ) tgtBtn = g('[value="DOWNLOAD ALL"]'); tgtBtn && SimulateMouse(tgtBtn, "click", true); } }, '2shared': { rule: /\b2shared\.com/, run: function(){ this.clog('inside 2shared;'); var style, dlBtn=null, btns = gAll('#dlBtn') ; if( btns.length === 1 ) dlBtn = btns[0]; else{ for(var i=0, iL=btns.length; i maxTry ){ sTryStop && clearInterval( sTryStop ); if("function" == typeof cb_pagestop) cb_pagestop() } }, 10); } }, jumbofiles: { rule: /jumbofiles\.com/, run: function(){ this.clog('inside jumbofiles, method not found'); } }, sendmyway: { rule: /sendmyway\.com/, run: function(){ this.clog('inside sendmyway'); var adcopy = g('#adcopy_response'); var btnDownload = g('#download_link'); if( !adcopy && !btnDownload ){ this.clog('adad adcopy'); g(".down-link") && SimulateMouse(g(".down-link"), "click", true); } else{ if( !btnDownload ){ adcopy.focus(); } else{ var dd = g('#direct_download'); btnDownload = g('#download_link', dd); this.frameload(btnDownload.getAttribute('href')) } } } }, box: { rule: /app\.box\.com/, run: function(){ var that = this; this.waitforit(function(){ return xp('//button[contains(@data-type, "download-btn")]', null, true); }, function(){ btnDownload = xp('//button[contains(@data-type, "download-btn")]', null, true); btnDownload && SimulateMouse(btnDownload, "click", true); }, 100); } }, dropbox: { rule: /dropbox\.com/, run: function(){ var btnDownload; if( btnDownload = g('*[id*=download_button]') ) setTimeout(function(){ SimulateMouse(btnDownload, "click", true); }, 123); else this.clog('dropbox: missing download button, page may changed'); } }, solidfiles: { rule: /solidfiles\.com/, run: function(){ var href, that, btnDownload; that = this; that.clog('inside solidfiles, '+that.get_href()); setTimeout(function(){ that.killframes() }, 123); // pick selector dat relevant and exist on several browsers //if( btnDownload = g('a[class*=direct-download]') ) if( btnDownload = g('[id=ddl-btn]') ) setTimeout(function(){ SimulateMouse(btnDownload, "click", true) }, 125); else this.clog('solidfiles: missing download button, page may changed'); } }, yadi: { rule: /yadi\.sk/, run: function(){ var btnDownload, that = this; that.clog('inside yadi, '+that.get_href()); if( btnDownload = g('*[data-click-action="resource.download"]') ){ var triggered = !1; // proper content ready is required, since button used some ajax on it. document.addEventListener('DOMContentLoaded', function() { if( !triggered ) setTimeout(function(){ SimulateMouse(btnDownload, "click", true) }, 125); }, false); SimulateMouse(btnDownload, "click", true); triggered = 1; } else this.clog('yadi: missing download button, page may changed'); } }, datafilehost: { rule: /datafilehost\.com/, run: function(){ var that, btnDownload; that = this; that.clog('inside datafilehost, '+that.get_href()); setTimeout(function(){ that.killframes() }, 123); if( btnDownload = g('a[href*="/get.php?"]') ) setTimeout(function(){ SimulateMouse(btnDownload, "click", true) }, 125); else this.clog('datafilehost: missing download button, page may changed'); } }, userscloud: { rule: /userscloud\.com/, run: function(){ var that=this, FORM; that.clog('inside userscloud, '+that.get_href()); setTimeout(function(){ that.killframes() }, 123); this.waitforit(function(){ return xp('//button[contains(@id, "ownlo") and not(contains(@disabled,"disabled"))]', null, true); }, function(){ if( FORM = xp('//form[@name="F1"]', null, true) ) setTimeout(function(){ FORM.submit() }, 345); }, 100); } }, }; // end of patterns var MNy = new MaknyosHelper(document.baseURI); MNy.matchDomain().matchAction().invokeAction(); // lil-helpers function isDefined(x) { return!(x == null && x !== null) } function isUndefined(x) { return x == null && x !== null } function SimulateMouse(elem, event, preventDef) { if(typeof elem != "object") return; // is it an a element? try with iframe loader var is_error = null, href = (elem && elem.getAttribute ? elem.getAttribute("href") : null); // make sure it's link, not some sumthin like: "javascript:;" if( href && /^((?:(?:ht|f)tp(?:s?)\:\/\/){1}\S+)/.test(href) ){ try{ MNy.action.clog("SimulateMouse trying href"); MNy.action.frameload(href); is_error = false; }catch(e){ is_error = true } } // failover, just click dat button if( is_error || is_error === null ){ MNy.action.clog("SimulateMouse-click with MouseEvents"); var evObj = document.createEvent("MouseEvents"); preventDef = isDefined(preventDef) && preventDef ? true : false; evObj.initEvent(event, preventDef, true); try { elem.dispatchEvent(evObj) }catch(e) {} } } function getParameterByName(name, the_url) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); if( isUndefined(the_url) ) the_url = location.search; var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(the_url); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } function g(x, par){ !par && (par = document); return ('string' == typeof x ? par.querySelector(x) : x); } function gAll(x, par){ !par && (par = document); return ('string' == typeof x ? par.querySelectorAll(x) : x); } function xp(q, root, single) { if(root && typeof root == "string") { root = $D(root, null, true); if(!root) { return null } } if(!q) { return false } if(typeof q == "object") { return q } root = root || document; if(q[0] == "#") { return root.getElementById(q.substr(1)); }else { if(q[0] == "/" || q[0] == "." && q[1] == "/") { if(single) { return document.evaluate(q, root, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue } return document.evaluate(q, root, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) }else { if(q[0] == ".") { return root.getElementsByClassName(q.substr(1)) } } } return root.getElementsByTagName(q) }; })(); /* eof. */