Greasy Fork is available in English.

T411 - Direct download

Provide a direct download link to torrent in the search results

// ==UserScript==
// @name        T411 - Direct download
// @description Provide a direct download link to torrent in the search results
// @namespace   t411-ddl
// @include     http*://*t411.*/*
// @version     0.3
// @grant       none
// @require     https://code.jquery.com/jquery-1.7.0.min.js
// ==/UserScript==

var TAG = 'T411-DDL';
var BASE_LINK = '/torrents/download/?id=';

this.jQuery = jQuery.noConflict(true);

jQuery(document).ready(function() {
  jQuery("<style type='text/css'> .download-link{display:block;width:16px;height:16px;margin:0 auto;background:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAALVWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNC4yLjItYzA2MyA1My4zNTI2MjQsIDIwMDgvMDcvMzAtMTg6MTI6MTggICAgICAgICI+CiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogIDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiCiAgICB4bWxuczpwaG90b3Nob3A9Imh0dHA6Ly9ucy5hZG9iZS5jb20vcGhvdG9zaG9wLzEuMC8iCiAgICB4bWxuczpJcHRjNHhtcENvcmU9Imh0dHA6Ly9pcHRjLm9yZy9zdGQvSXB0YzR4bXBDb3JlLzEuMC94bWxucy8iCiAgICB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iCiAgICB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIKICAgIHhtbG5zOnN0RXZ0PSJodHRwOi8vbnMuYWRvYmUuY29tL3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iC/+IOuoS7A11aXUm7A/Ff0CIIft0q4p/mnlP6DNFa6MBwYDwzOTEJJRKEYbiFUop6mqZU1BRZADSexnEkImX4ITOYM3w9gMpE3/cZpfQs6pxzJ8/zVhrgeR4nH6IoCnrfwjRNMaywX2uGCWOsm5vQtm1mWVYJQb8QRJYIiKuqSl4CEF3XZaZpLoagua7r5ObZiKP1fZ/pul5CsywkbpomWbVH13UjIH9iNNts2zZDijpjLAIesM55qGEYeObl9Zx3wzBk76YDTwCe4/0tXO+6Az/vqGlasGTG79iH/ei7XCRVVQNYHROdD+7RGabYPZ6logTAPyBfQey7TPovwAAyhMDC6QcrsAAAAABJRU5ErkJggg==') no-repeat 0 0} </style>").appendTo("head");

  jQuery("th:contains('NFO')").each(function () {
    jQuery(this).before('<th width="45px">DL</th>');
  });
  
  jQuery('a[href*="/torrents/nfo/"]').each(function () {
    try {
      var newNode = jQuery(this).parent().clone();
      var newLink = newNode.find('a');
      var id = jQuery(this).attr('href').split('=') [1];

      newLink.attr('href', BASE_LINK + id)
        .removeClass("ajax").removeClass("nfo")
        .addClass("download-link")
        .off("click");

      jQuery(this).parent().before(newNode);
    } catch(e) {
      console.error(TAG + ': error: ' + e);
    }
  });
});