Podnapisi.net Download Buttons

Adds download buttons to subtitles list (in search).

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name	Podnapisi.net Download Buttons
// @author	NuJumala <[email protected]>
// @namespace	www.podnapisi.net
// @grant       none
// @include	http://*.podnapisi.net/*/search*
// @description	Adds download buttons to subtitles list (in search).
// @version	1.7.0
// ==/UserScript==

$ = unsafeWindow.jQuery;
if ($ == null) {
  return;
}
$('#ppodnapisiFps').parent().before('<th class="posts">DL</th>');
$('.list_div2 a').each(function(index, element) {
  href = $(element).attr('href');
  matches = href.match(/.*-p(.*)/);
  if(matches) {
    id = 'dl-'+matches[1];
    button = '<td id="'+id+'" align="center"><a rel="'+href+'"><img vspace="5" hspace="5" alt="Podnapisi" src="http://static2.podnapisi.net/images/nextgen/podnapisi/download.gif" class = "slikevvrsti"></a></td>';
    $(element).parents().eq(1).children().eq(0).hide();
    $(element).parents().eq(2).children().eq(0).after(button);
    $('#'+id).click(function() {
      $.ajax({
	url: $('a', this).attr('rel'),
	beforeSend: function(xhr) { xhr.setRequestHeader('X-Requested-With', {toString: function(){ return ''; }}); },
	dataFilter: function(data) { return data; }
      }).done(function(data) {
	$.ajax({
	  url: $('.#subtitle .footer a', data).attr('href'),
	  beforeSend: function(xhr) { xhr.setRequestHeader('X-Requested-With', {toString: function(){ return ''; }}); },
	  dataFilter: function(data) { return data; }
	}).done(function(data) {
	  matches = data.match(/(\/hr\/ppodnapisi\/download.*?)'/m);
	  window.location.href = matches[1];
	});
      });
    });
  }
});

// EOF