movie-easy-download

在豆瓣电影页面添加电影和字幕的下载链接

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @namespace         https://www.github.com/fytriht/

// @name              movie-easy-download

// @description       在豆瓣电影页面添加电影和字幕的下载链接

// @homepageURL       https://github.com/fytriht/movie-easy-download
// @supportURL        https://github.com/fytriht/movie-easy-download/issues/

// @author            fytriht
// @version           0.0.1
// @license           MIT


// @match             https://movie.douban.com/subject/*
// @grant             none
// ==/UserScript==

(function () {

  var sites = [
    {
      text: 'rargb',
      api: 'https://rarbg.to/torrents.php?search='
    },
    {
      text: 'torrentz',
      api: 'https://torrentz2.eu/search?f=',
    },
    {
      text: 'addic7ed',
      api: 'http://www.addic7ed.com/search.php?Submit=Search&search='
    },
    {
      text: 'openst',
      api: 'https://www.opensubtitles.org/en/search2/sublanguageid-eng/moviename-'
    }
  ];

  function createEl (querystring) {
    return function (text, api) {
      var el  = document.createElement('span');
      el.innerText = text;
      el.style.margin = '0 5px';
      el.style.color = '#f0f3f5';
      el.addEventListener('click', () => window.open(api + querystring));
      return el;
    };
  }

  function appendTo (cont) {
    return function (el) {
      cont.appendChild(el);
    };
  }

  try {
    var title = document.querySelector('[property="v:itemreviewed"]').innerText;
    var qs = title.match(/[a-z0-9]+/gi).join('%20');

    if (qs === null) return;

    var cont = document.querySelector('#content > h1');

    var appendToCont = appendTo(cont);
    var fn = createEl(qs);

    sites
      .map(site => fn(site.text, site.api))
      .forEach(el => appendToCont(el));
  }
  catch (_) {/* fail silently */}

})();