Zimuku2pianyuan

增加片源网的搜索按钮,并直接显示字幕下载地址。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Zimuku2pianyuan
// @namespace    http://tampermonkey.net/
// @version      1.0.5
// @description  增加片源网的搜索按钮,并直接显示字幕下载地址。
// @author       Johnxon
// @include      *://zmk.pw/detail/*
// @include      *://zimuku.org/detail/*
// @include      *://zimuku.pw/detail/*
// @include      *://srtku.com/detail/*
// @grant        GM_addStyle
// ==/UserScript==

(function () {

    function addButton() {
        GM_addStyle("span.py{background:#20A4FF;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.org/search?q=${encodeURIComponent(title)}" target="_blank"><span class="py">片源</span></a>`;
        let btnDownload = $('.dl').parent();
        btnDownload.after(pianyuanBtn);
    }
    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 = document.getElementById('down1');
        link.hostname = location.hostname;
        link.protocol = location.protocol;
        let html = await fetch(link.href)
            .then(response => response.text());
        let downLinks = $($.parseHTML(html)).find('.down');
        downLinks.find('a').removeClass('btn');
        downLinks.find(".btn-warning").parent().remove();
        downLinks.find(".btn-success").parent().remove();
        $('.subinfo').after(downLinks);
    }
    addButton();
    fetchDLinks();
})();