Filehippo - Replace Download Manager with Direct Links

Replaces download manager links on filehippo.com with direct download links. Works on download pages and update checker results page.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Filehippo - Replace Download Manager with Direct Links
// @namespace   filehippo-directlinks
// @author      conquerist
// @description Replaces download manager links on filehippo.com with direct download links. Works on download pages and update checker results page.
// @include     /^https?://update\.filehippo\.com/update/check/.*$/
// @include     /^https?://filehippo\.com/download.*$/
// @version     1.3
// @grant       none
// ==/UserScript==
// 1.3 - 20140914 - Improved Chrome / Tampermonkey compatibility
// 1.2 - 20140914 - Improved Chrome / Tampermonkey compatibility
// 1.1 - 20140913 - Fix for formatting of "Your computer is up-to-date!" message
// 1.0 - 20140913 - Initial version 

if( window.location.pathname.match(/^\/update\/check/) ) {
	// point links on update checker results to direct download
	var as = document.querySelectorAll('a.update-download-link');
	for(var i = 0; i < as.length; i++) {
		as[i].href += '/?direct';
	}
	
	// fix "Your computer is up-to-date!" message
	var e = document.querySelector('#no-updates-message-container');
	e.className = e.className.replace(/\s*hidden/,'');
}
else if( window.location.pathname.match(/^\/download/) ) {
	var e = document.querySelector('#program-header-download-link-dm-text');
	if(e) {
		// remove text "Download Manager Enabled"
		e.parentNode.removeChild(e);

		// remove additional direct download link
		e = document.getElementById('direct-download-link-container');
		a = e.querySelector('a');
		var direct_onclick = a.getAttribute('onclick');
		var direct_href = a.getAttribute('href');
		e.parentNode.removeChild(e);

		// modify regular download links
		var div = document.querySelector('div.program-header-download-link-container');
		as = div.querySelectorAll('a');
		as[0].setAttribute('href', direct_href);
		as[0].setAttribute('onclick', direct_onclick);
		as[1].setAttribute('href', direct_href);
		as[1].setAttribute('onclick', direct_onclick);
		div.className = div.className.replace(/\s+download-manager-enabled/,'');
		as[0].className = as[0].className.replace(/\s+download-manager-enabled/,'');
	}
}