从豆瓣电影直接跳转茶杯狐搜索资源

茶杯狐是一个影视资源聚合搜索引擎。安装脚本后豆瓣电影标题旁会显示茶杯狐的logo,点击就可以搜索影视资源了。

// ==UserScript==
// @name         从豆瓣电影直接跳转茶杯狐搜索资源
// @namespace    https://cupfox.app/
// @version      0.0.6
// @author       Cupfox
// @match        *://movie.douban.com/subject/*
// @description 茶杯狐是一个影视资源聚合搜索引擎。安装脚本后豆瓣电影标题旁会显示茶杯狐的logo,点击就可以搜索影视资源了。
// ==/UserScript==

(function () {
    var host = location.hostname;
    if (host === 'movie.douban.com') {
        const title = encodeURIComponent(document.querySelector('title').innerText.replace(/(^\s*)|(\s*$)/g, '').replace(' (豆瓣)', ''));
        const subjectwrap = document.querySelector('h1');
        const subject = document.querySelector('.year');
        if (!subjectwrap || !subject) {
            return;
        }
        const sectl = document.createElement('span');
        subjectwrap.insertBefore(sectl, subject.nextSibling);
        sectl.insertAdjacentHTML('beforebegin',
            `<style>.cupfox{vertical-align: middle;}.cupfox:hover{background: #fff!important;}</style>
            <a href="https://cupfox.app/s/${title}" class="cupfox" target="_blank">
            <?xml version="1.0" encoding="UTF-8" standalone="no"?>
            <svg width="32px" height="23px" viewBox="0 0 600 468" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                <defs>
                    <linearGradient x1="21.1782278%" y1="82.8285131%" x2="37.8576227%" y2="60.1283873%" id="linearGradient-1">
                        <stop stop-color="#C74B1E" offset="0%"></stop>
                        <stop stop-color="#B84528" offset="100%"></stop>
                    </linearGradient>
                </defs>
                <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                    <g id="Group">
                        <path d="M405.967444,210.50526 C394.037565,219.253035 383.12336,215.368213 378.283978,213.73458 C373.444596,212.100946 362.906081,204.171248 355.021872,192.216023 C347.137663,180.260798 342.627341,168.670681 337.926445,156.567005 C328.438238,132.137155 325.079615,111.782956 323.419853,106.903084 C321.760092,102.023212 321.053089,99.893369 317.715028,99.893369 C314.376968,99.893369 309.513561,104.479737 307.53868,106.043386 C305.563799,107.607035 268.593569,147.712322 263.448505,151.409859 C258.303441,155.107396 251.794503,157.331292 247.07616,157.331292 C242.357817,157.331292 201.064503,156.567005 195.816161,156.567005 C190.56782,156.567005 185.843742,154.282944 180.849089,151.409859 C175.854436,148.536774 138.435247,105.232854 132.973453,102.023212 C127.511659,98.8135695 124.149128,100.505422 123.018926,103.726059 C122.265458,105.87315 120.985463,113.006425 119.178942,125.125884 C106.371382,211.094535 100.284013,254.147043 100.916834,254.28341 C108.521506,255.922136 129.423012,265.195295 146.609075,274.412831 C163.795138,283.630368 195.33956,306.839108 210.384322,321.600478 C219.051706,330.104598 232.732443,329.591062 241.092911,321.600478 C252.505717,310.692597 285.980687,283.156841 303.419577,274.412831 C320.858467,265.668821 346.635945,247.738916 405.967444,244.891919 C535.588485,238.672107 583.061124,358.406212 585.998593,363.958731 C588.936061,369.51125 594.589696,385.960362 594.589696,388.680094 C594.589696,391.399826 579.063037,376.003584 534.533872,375.452187 C513.204274,375.188067 500.971609,376.188695 488.851592,377.979456 C475.669011,379.927214 461.803171,382.879661 427.665368,391.098724 C397.589105,398.339926 339.141611,413.638653 320.053265,417.110904 C310.064837,418.927841 291.59889,422.778016 282.41283,424.17947 C273.226769,425.580924 265.207673,427.486088 241.092911,428.971008 C142.356632,435.050915 92.1210311,394.941123 57.3921328,360.596727 C38.4323518,341.84686 4.92205534,292.37194 0.655586004,228.435677 C-2.89289672,175.258986 14.9974234,110.340831 67.1612928,60.8011178 C182.043672,-48.3019882 319.303989,22.905392 324.98577,26.7565516 C330.667551,30.6077112 350.570688,43.5702955 361.180485,54.745147 C371.790282,65.9199986 386.567988,85.4179405 392.05573,95.5659406 C397.543472,105.713941 410.681329,132.409578 414.846079,156.567005 C416.434664,165.781513 418.271069,181.810135 415.914887,192.216023 C413.558705,202.621912 410.081252,207.488745 405.967444,210.50526 Z M471.283281,357.39858 C474.030901,354.572589 492.177564,350.322661 513.892722,350.816979 C534.567208,351.287608 559.359147,356.585595 559.359147,355.51735 C559.359147,354.514227 541.507738,322.627594 518.763377,303.253768 C505.945496,292.335397 502.438553,291.025697 494.698641,285.844287 C488.638571,281.787431 483.763273,278.086492 481.378671,279.250524 C479.576136,280.130422 490.935283,293.158804 493.204604,303.253768 C496.220014,316.667671 490.9642,328.584138 488.304218,333.41358 C481.378671,345.987544 472.692851,350.907527 471.283281,352.760376 C469.320729,355.340106 469.834848,358.888326 471.283281,357.39858 Z" id="Combined-Shape" fill="#DB542F" fill-rule="nonzero"></path>
                        <path d="M124.269531,101.663556 C123.71674,102.222757 123.299195,102.927402 123.018926,103.726059 C122.265458,105.87315 120.985463,113.006425 119.178942,125.125884 C106.371382,211.094535 100.284013,254.147043 100.916834,254.28341 C108.521506,255.922136 129.423012,265.195295 146.609075,274.412831 C163.795138,283.630368 195.33956,306.839108 210.384322,321.600478 C219.051706,330.104598 232.732443,329.591062 241.092911,321.600478 C252.505717,310.692597 285.980687,283.156841 303.419577,274.412831 C318.418318,266.892333 339.585344,252.576773 382.963239,246.906469 C382.863843,246.982734 382.751195,247.057123 382.625107,247.129634 C360.215763,260.016863 302.905393,301.507043 281.401998,324.406059 C251.036267,356.742598 233.981406,375.692929 229.781019,381.69161 C215.505525,402.078812 203.693196,402.078812 189.115767,381.69161 C184.032672,374.582669 171.955923,347.218334 140.584753,324.406059 C110.050789,302.202577 66.9769791,285.850282 61.6574349,283.245103 C56.3378907,280.639924 46.2087011,283.767012 56.3378907,264.423612 C66.4670803,245.080212 118.34202,107.015496 123.219804,101.450334 C123.413706,101.229107 123.762252,101.310184 124.269531,101.663556 Z" id="Combined-Shape" fill="url(#linearGradient-1)"></path>
                        <path d="M144.412304,221.199295 C148.497769,220.708023 152.186044,220.708023 155.477131,221.199295 C160.413761,221.936203 170.632064,226.243167 173.78433,228.769993 C174.853535,229.627057 188.223924,240.76347 189.515855,249.367158 C189.918965,252.051693 189.515855,252.058905 189.515855,252.90233 C189.515855,253.464614 186.337884,253.464614 179.981943,252.90233 C168.860015,249.687221 161.18792,246.11257 156.965657,242.178377 C150.632262,236.277088 145.162176,228.930692 144.412304,225.064993 C143.912389,222.487861 143.912389,221.199295 144.412304,221.199295 Z" id="Path-3" fill="#DB542F"></path>
                        <path d="M261.374936,221.368454 C265.460401,220.877182 269.148677,220.877182 272.439763,221.368454 C277.376393,222.105362 287.594696,226.412326 290.746962,228.939152 C291.816167,229.796217 305.186557,240.932629 306.478487,249.536318 C306.881597,252.220853 306.478487,252.228064 306.478487,253.07149 C306.478487,253.633773 303.300516,253.633773 296.944575,253.07149 C285.822647,249.85638 278.150552,246.281729 273.928289,242.347536 C267.594895,236.446247 262.124808,229.099851 261.374936,225.234153 C260.875021,222.65702 260.875021,221.368454 261.374936,221.368454 Z" id="Path-3" fill="#DB542F" transform="translate(283.828824, 237.246601) scale(-1, 1) translate(-283.828824, -237.246601) "></path>
                        <path d="M217.401791,287.108711 C215.734305,287.108711 212.016489,287.686017 210.274407,288.726392 C208.532325,289.766768 207.458893,290.406998 205.901072,292.548821 C204.343252,294.690645 204.561054,296.600631 205.266059,299.191854 C205.971064,301.783077 218.935551,315.057147 221.094066,316.448521 C223.252582,317.839896 228.072996,317.839896 230,316.33981 C231.927004,314.839724 245.123003,301.674365 245.828007,299.083142 C246.533012,296.491919 246.750815,294.581933 245.192994,292.44011 C243.635173,290.298286 242.561741,289.658056 240.819659,288.617681 C239.077577,287.577305 235.359761,287 233.692276,287 L217.401791,287.108711 Z" id="Path-4" fill="#DB542F"></path>
                    </g>
                </g>
            </svg></a>`
        );
    }
})();