Zimuku2pianyuan

在字幕库(www.zimuku.la)的网页中增加片源网和Rarbg的搜索按钮,并直接显示字幕下载地址。

目前為 2019-08-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Zimuku2pianyuan
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  在字幕库(www.zimuku.la)的网页中增加片源网和Rarbg的搜索按钮,并直接显示字幕下载地址。
// @author       Johnxon
// @match        www.zimuku.la/detail/*
// @grant        GM_addStyle
// ==/UserScript==

(function () {

    function addButton() {
        'use strict';
        GM_addStyle("span.py{background:#20A4FF;padding:16px 20px !important;height:50px;font-size:18px;color:#fff !important} span.rarbg{background:#505599;padding:16px 20px !important;height:50px;font-size:18px;color:#fff !important}");
        let keywords = $("meta[name='keywords']").attr("content");
        let [title, en_title, ...rest] = keywords.split(',');
        let pianyuanBtn = `<a href="http://pianyuan.la/search?q=${title}" target="_blank"><span class="py">片源</span></a>`;
        let rarbgBtn = `<a href="https://rarbgprx.org/torrents.php?search=${en_title}" target="_blank"><span class="rarbg">RARBG</span></a>`;
        let btnDownload = $('.dl').parent();
        btnDownload.after(pianyuanBtn);
        btnDownload.after(rarbgBtn);
    }

    async function fetchDLinks() {
        GM_addStyle(`
            .down{margin:20px 0;}
            .down ul {
                -webkit-column-count: 3;
                -moz-column-count: 3;
                column-count: 3;
                }
            .down li{padding:10px}
        `);
        let link = $('#down1').attr("href");
        let html = await fetch(link)
            .then(response => response.text())
            .then(response => response);
        let downLinks = $($.parseHTML(html)).find('.down');
        downLinks.find('a').removeClass('btn');
        $('.subinfo').after(downLinks);
    }
    addButton();
    fetchDLinks();
})();