// ==UserScript==
// @name        Anti-Identifying Code Download Helper
// @namespace   this@this.cn
// @description 下载助手，移除验证码，优化下载（支持华军、华为、YunFile、千军万马网盘、SongTaste、RayFile、共享盘、4399小游戏）。
// @include     http://dl.vmall.com/*
// @include     http://*.yunfile.com/file/*
// @include     http://*.qjwm.com/download*
// @include     http://www.songtaste.com/song/*/
// @include     http://www.rayfile.com/*/files/*/*/
// @include     http://www.gxp.cc/file-*.html
// @include     http://www.4399.com/down/*.htm
// @version     1.0.0.6
// @updateURL     https://j.mozest.com/userscript/script/91.meta.js
// ==/UserScript==

(function(){


window.addEventListener(
	"DOMContentLoaded",
	function() {
		
		if(!window.jQuery)	return;
		
		
		var $ = window.jQuery;
		var dhost=location.hostname.replace(/\w+\./,'');
		
		
		switch (dhost) {
		
		case "vmall.com":				// 华为网盘
			$('#filelist_marker').height('0');
			var vmallLink = $('a[nspurl]');
			var vmallNum = vmallLink.size();
			for(var i = 0; i < vmallNum; i++)
				vmallLink.get(i).setAttribute('onclick', 'adsShow=false;dbank.securelink.download_dbankcommon(this, 2, 0);return false;');
			break;
		
		//case "onlinedown.net":			// 华军软件站
			// 过滤弹出广告请在ADP中添加规则    ||onlinedown.net/js/cover.js
			
				
		
		case "yunfile.com":				// YunFile
			// 下载页面
			var down = document.getElementById('down_from');

			if(down){
				$('#opacity_a').parent().remove();
				down.removeAttribute('onsubmit');
			}

			// 信息页面
			var slow_button = document.getElementById('slow_button');
			if(slow_button){
				var downpage_link = document.getElementById('downpage_link');
				window.location=downpage_link.href;
			}
			break;
		
		case "qjwm.com":			// 千军万马网盘
			$('#inputyzm').remove();
			$('#my_yzm').parent().remove();
			document.getElementById('downtc').innerHTML= downurl;
			break;
			
			
		case "songtaste.com":		//
			
			// 禁止弹出登录、注册框，请在ADP中添加规则   ||songtaste.com/plugin/fancybox/*
			window.getSongURL = function(){
				var song_id = /\d+/.exec(window.location.href)[0];
				var a_obj = $("a");
				var url_reg = /javascript:playmedia1.+/;
				var url_pos = 0;
				for(var i = 0 ; i < a_obj.length ; i++){
					if(url_reg.test(a_obj[i].href)){
						url_pos = i;
						break;
					}
				}
				var _strURL  = $("a")[url_pos].href.split(',')[2].substr(4);
				var strURL = _strURL.substring(0, _strURL.length - 1);
				
				$.ajax({url:'/time.php',
						data:'str='+strURL+'&sid='+song_id+'&t='+"0",
						type:'POST',
						success:function(url){
							$('#custom_1').attr('href', url)
							
						}
				});
			}
			getSongURL();
			break;
			
		case "rayfile.com":				// 飞速网
			if(filesize > 20000000)	location.href='javascript:filesize = 10;showDownload();';
			break;
			
		case "gxp.cc":					// 共享盘，点击“进入下载页面”按钮直接弹出下载
			// 隐藏左侧广告，请在ADP中添加规则   gxp.cc##.downLeft.left
			$.post(location.href.replace(/file-/i, 'down-'), function(data){
				var flag = /\$\("#file_link_a"\)\.attr\("href","(.*)"\)/gi.test(data);
				if(flag) {
					var link = RegExp.$1;
					$('#down_a').removeAttr('onmouseover').attr("href",link);
				}
			}, 'text');
			break;
		
		case "4399.com":		// 4399 小游戏
			//移除 “下载游戏盒子”
			$('.box_tit').remove();
			$('.box_con').remove();
			$('.no_box').remove();
			
			let gname = $('.in_box').find('a')
						.html('右键“另存为”——下载游戏')
						.attr('href', strGameUrl)
						.removeAttr('onclick')
						.attr('title').substring(4);
			$('.in_box').find('p').html('此处下载——' + gname);
			break;
				
		default:
			break;
		
		};
	
	
	
	
	
	}, false);









})();


