Greasy Fork

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.

目前为 2014-09-12 提交的版本。查看 最新版本

// ==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.1
// @grant       none
// ==/UserScript==

if( window.location.pathname.startsWith('/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 = as[i].href + '/?direct'
	}
	
	// fix "You computer is up-to-date!" message
	var e = document.getElementById('no-updates-message-container')
	e.className = e.className.replace(/\s*hidden/,'')
} else if( window.location.pathname.startsWith('/download') )
{
	// remove text "Download Manager Enabled"
	var e = document.getElementById('program-header-download-link-dm-text')
	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/,'')
}