Greasy Fork

File Hosting Download Manager Disabler

Remove file hosting download manager option and replace with direct download link

目前为 2014-08-22 提交的版本。查看 最新版本

// ==UserScript==
// @name       File Hosting Download Manager Disabler
// @namespace   813878cf6d21d80383c65d70567952bd
// @version    1.0.0
// @author     mac9erd
// @description  Remove file hosting download manager option and replace with direct download link
// ===================================================
// Supported Sites:
// @match      *://*.datafilehost.com/*
// @match      *://*.filehippo.com/*
// ===================================================
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

$(document).ready(function(){ 
    if(window.location.href.indexOf("datafilehost") > -1) dataFileHost();
    else if(window.location.href.indexOf("filehippo") > -1) fileHippo();
    else alert("Site not supported!");
    
    function dataFileHost() {
        var page = String(location).split('/')[3];
    	var fileId = String(location).split('/')[4]; 
    	if ( page == "d") $('form').remove();
    	function viewDownloadLink() { 
       	 document.getElementById("dl").innerHTML = ('<a href="http://www.datafilehost.com/get.php?file=' + fileId + '"><img src="http://commondatastorage.googleapis.com/datafilehost%2Fdownload.png" alt="Download"></a></br></br></br>');
        };
    	viewDownloadLink();
    }
    
    function fileHippo() {
        $('#ad-slot-1').remove();
        $('#sidebar').remove();
        $('#sidebar-left').remove();
        $('#sidebar-right').remove();
        $('.techbeat-widget-wide-container.related-software-news').remove();
        $('.techbeat-widget-wide-container.trending-news').remove();
        $('.techbeat-widget-wide-container.trending-news').remove();
        $('.download-confirmation-text-additional').remove();
        $('.techbeat-widget-wide-container.download-page').remove(); 
        GM_addStyle ("\
        #category-header{padding-top: 20px;border-bottom: none;}\
        .program-header-download-link.long.download-manager-enabled {line-height: 1;text-align: right;height: 30px;display: none;}\
        #direct-download-link-container {background: #2baf2b;color:#fff;font-size:13px;padding: 18px;width: 240px;border-radius: 5px;}\
        #direct-download-link-container a {font-weight: bold;color: #fff;text-decoration: none;}\
        #direct-download-link-container a:hover {font-weight: bold;color: #fff;text-decoration: none;}\
        ");
        function getFileSize() {
            var fileSize = document.getElementsByClassName('normal')[0].innerHTML;
            $('#direct-download-link-container a').append('<span class="normal">' + fileSize + '</span>');
        }
        function setCustomText() {
            var searchTerm = 'Direct Download',
            replaceWith = 'Download Latest Version ';
            $("#direct-download-link-container a:contains('" + searchTerm + "')").each(function(){
            	this.innerHTML = this.innerHTML.replace(searchTerm, replaceWith);
            });
        }
        setCustomText();
        getFileSize();
    }
});