Greasy Fork

从tmdb直接跳转moviepilot搜索资源

从tmdb跳转moviepilot搜索资源

// ==UserScript==
// @name         从tmdb直接跳转moviepilot搜索资源
// @version      0.0.1
// @description  从tmdb跳转moviepilot搜索资源
// @author       thsrite
// @match        *://www.themoviedb.org/movie/*
// @match        *://www.themoviedb.org/tv/*
// @license      MIT
// @note         24-03-12 0.0.1 init
// @namespace https://greasyfork.org/users/1153077
// ==/UserScript==

// 改成自己的mp地址
const mphost = 'http://192.168.31.103:3003';

(function () {
    const title = encodeURIComponent(document.querySelector('title').innerText.replace(/(^\s*)|(\s*$)/g, '').replace(' — The Movie Database (TMDB)', ''));
    const locations = location.href.split('/')
    let tmdbid = locations[locations.length - 1]
    let mtype = locations[locations.length - 2]
    const facts = document.querySelector('h2');
    const subject = document.querySelector('.tag');
    if (!facts || !subject) {
        return;
    }

    if (tmdbid.split('-').length > 1){
        tmdbid = tmdbid.split('-')[0]
    }
    if (mtype == 'movie'){
        mtype = '电影'
    }else {
        mtype = '电视剧'
    }
    const sectl = document.createElement('span');
    facts.insertBefore(sectl, subject.nextSibling);
    sectl.insertAdjacentHTML('beforebegin',
                             createSvg(tmdbid, mtype)
                            );
    function createSvg(tmdbid, mtype) {
        return `<style>.cupfox{vertical-align: middle;}.cupfox:hover{background: #fff!important;}</style>
            <a href="${mphost}/#/resource?keyword=tmdb:${tmdbid}&type=${mtype}" class="cupfox" target="_blank">
            <svg
             width="25px"
             height="25px"
             viewBox="0 0 192 192"
             version="1.1"
             xmlns="http://www.w3.org/2000/svg"
             style="fill-rule: evenodd; clip-rule: evenodd; stroke-linejoin: round; stroke-miterlimit: 2"
             >
          <g transform="matrix(1,0,0,1,-2606,-236)">
            <g id="a2-c" transform="matrix(1,0,0,1,2606,236)">
              <rect x="0" y="0" width="192" height="192" style="fill: none" />
              <g transform="matrix(-0.800798,0.462341,-0.769972,-1.33363,1869.11,-896.718)">
                <path
                  d="M2241.27,-28.175C2238.86,-28.931 2236.64,-29.181 2234.48,-29.254L2159.78,-29.286L2165.01,-11.207C2167.16,-13.121 2169.64,-13.722 2172.26,-13.808L2222.12,-13.822C2223.52,-13.824 2225,-13.701 2226.78,-13.108L2241.27,-28.175Z"
                  style="fill: url(#_Linear1)"
                />
              </g>
              <g transform="matrix(1,0,0,1,-2157.67,-208.423)">
                <path
                  d="M2205.67,331.428L2205.67,332.25L2205.67,352.835C2205.67,354.263 2204.91,355.583 2203.67,356.298C2202.43,357.012 2200.91,357.013 2199.67,356.3L2190.78,351.174C2189.73,350.595 2188.83,350.083 2188.03,349.59L2187.45,349.257C2186.66,348.725 2185.91,348.142 2185.21,347.461C2185.08,347.331 2184.95,347.198 2184.82,347.061C2184.26,346.457 2183.75,345.778 2183.3,344.995C2182.16,343.05 2181.69,341.024 2181.68,338.948L2181.67,268.923L2209.77,274.425C2207.5,275.639 2205.68,278.3 2205.67,281.429L2205.67,331.428Z"
                  style="fill: url(#_Linear2)"
                />
              </g>
              <g transform="matrix(1,0,0,1,-2157.67,-208.423)">
                <path
                  d="M2295.93,363.064C2299.48,360.882 2301.46,357.55 2301.67,352.926L2301.67,277.879L2301.67,276.775L2301.67,252.515C2301.67,251.801 2302.05,251.14 2302.67,250.783C2303.29,250.426 2304.05,250.426 2304.67,250.784L2319.81,259.54C2321.59,260.617 2322.95,262.115 2324.04,263.875C2325.03,265.551 2325.56,267.37 2325.67,269.835L2325.67,339.91C2325.18,343.645 2323.51,346.705 2320.3,348.887L2295.93,363.064ZM2295.93,363.064C2295.73,363.184 2295.53,363.301 2295.32,363.414L2295.93,363.064Z"
                  style="fill: rgb(141, 81, 249)"
                />
              </g>
              <g transform="matrix(1,0,0,1,-2157.67,-208.423)">
                <path
                  d="M2295.93,363.064C2299.48,360.882 2301.46,357.55 2301.67,352.926L2301.67,277.879L2301.67,276.775L2301.67,252.515C2301.67,251.801 2302.05,251.14 2302.67,250.783C2303.29,250.426 2304.05,250.426 2304.67,250.784L2319.81,259.54C2321.59,260.617 2322.95,262.115 2324.04,263.875C2325.03,265.551 2325.56,267.37 2325.67,269.835L2325.67,339.91C2325.18,343.645 2323.51,346.705 2320.3,348.887L2295.93,363.064ZM2299.79,360.238C2299.79,360.238 2320.03,348.464 2320.04,348.461C2323.1,346.372 2324.69,343.444 2325.17,339.877C2325.17,339.877 2325.17,269.846 2325.17,269.839C2325.06,267.482 2324.56,265.739 2323.61,264.133C2322.56,262.445 2321.26,261.005 2319.55,259.97L2304.42,251.217C2303.96,250.949 2303.39,250.948 2302.92,251.216C2302.46,251.484 2302.17,251.979 2302.17,252.515L2302.17,276.775L2302.17,277.879L2302.17,352.926C2302.17,352.933 2302.17,352.941 2302.17,352.948C2302.04,355.861 2301.23,358.279 2299.79,360.238Z"
                  style="fill: url(#_Linear3)"
                />
              </g>
              <g transform="matrix(1,0,0,1,-2157.67,-208.423)">
                <path
                  d="M2253.67,223.256C2255.26,223.245 2257.02,223.56 2259.11,224.557L2275.67,234.102C2276.91,234.816 2277.67,236.138 2277.67,237.568L2277.67,259.508C2277.67,260.222 2277.29,260.882 2276.67,261.239C2276.05,261.597 2275.29,261.597 2274.67,261.24L2257.52,251.353C2256.38,250.731 2255.12,250.341 2253.67,250.347C2252.26,250.339 2250.99,250.721 2249.82,251.353L2187.87,287.04C2184.23,289.147 2181.96,292.478 2181.67,297.57L2181.68,269.865C2181.85,265.167 2183.93,261.653 2187.92,259.322L2248.23,224.557C2249.69,223.796 2251.5,223.29 2253.67,223.256Z"
                  style="fill: rgb(165, 118, 255)"
                />
              </g>
              <g transform="matrix(1,0,0,1,-2157.67,-208.423)">
                <path
                  d="M2253.67,223.256C2255.26,223.245 2257.02,223.56 2259.11,224.557L2275.67,234.102C2276.91,234.816 2277.67,236.138 2277.67,237.568L2277.67,259.508C2277.67,260.222 2277.29,260.882 2276.67,261.239C2276.05,261.597 2275.29,261.597 2274.67,261.24L2257.52,251.353C2256.38,250.731 2255.12,250.341 2253.67,250.347C2252.26,250.339 2250.99,250.721 2249.82,251.353L2187.87,287.04C2184.23,289.147 2181.96,292.478 2181.67,297.57L2181.68,269.865C2181.85,265.167 2183.93,261.653 2187.92,259.322L2248.23,224.557C2249.69,223.796 2251.5,223.29 2253.67,223.256ZM2253.68,223.756C2251.6,223.789 2249.87,224.269 2248.47,224.996L2188.17,259.754C2184.35,261.992 2182.35,265.367 2182.18,269.874C2182.18,269.874 2182.17,292.759 2182.17,292.757C2183.25,290.047 2185.13,288.051 2187.62,286.607L2249.57,250.919C2249.58,250.917 2249.58,250.915 2249.59,250.913C2250.83,250.243 2252.17,249.839 2253.67,249.847C2255.21,249.841 2256.54,250.253 2257.76,250.914C2257.76,250.916 2257.76,250.917 2257.76,250.919L2274.92,260.807C2275.38,261.075 2275.95,261.074 2276.42,260.806C2276.88,260.538 2277.17,260.043 2277.17,259.508L2277.17,237.568C2277.17,236.317 2276.5,235.16 2275.42,234.535C2275.42,234.535 2258.88,225 2258.87,224.996C2256.87,224.049 2255.2,223.746 2253.68,223.756Z"
                  style="fill: url(#_Linear4)"
                />
              </g>
              <g transform="matrix(0.800798,0.462341,0.769972,-1.33363,-1677.22,-896.858)">
                <path
                  d="M2241.55,-28.184C2239.1,-28.989 2236.83,-29.204 2234.68,-29.295C2234.68,-29.295 2220.82,-29.3 2215.03,-29.303C2213.48,-29.303 2212.05,-28.808 2211.28,-28.004C2208.65,-25.275 2202.56,-18.936 2199.45,-15.709C2199.07,-15.306 2199.07,-14.809 2199.46,-14.406C2199.85,-14.004 2200.57,-13.758 2201.34,-13.761C2208.36,-13.788 2222.72,-13.845 2222.72,-13.845C2223.98,-13.851 2225.44,-13.657 2227.06,-13.117L2241.55,-28.184Z"
                  style="fill: rgb(141, 81, 249)"
                />
              </g>
              <g transform="matrix(-4.32309,0,0,12.4454,9610.35,-1450.35)">
                <path
                  d="M2205.31,121.966C2205.31,121.88 2205.18,121.8 2204.96,121.757C2204.74,121.714 2204.48,121.714 2204.27,121.757C2201.75,122.263 2195.36,123.547 2192.85,124.052C2192.63,124.095 2192.5,124.174 2192.5,124.261C2192.5,124.347 2192.63,124.426 2192.85,124.469C2195.36,124.974 2201.75,126.255 2204.27,126.759C2204.48,126.802 2204.74,126.802 2204.96,126.759C2205.18,126.716 2205.31,126.636 2205.31,126.55C2205.31,125.541 2205.31,122.976 2205.31,121.966Z"
                  style="fill: rgb(104, 0, 197)"
                />
                <clipPath id="_clip5">
                  <path
                    d="M2205.31,121.966C2205.31,121.88 2205.18,121.8 2204.96,121.757C2204.74,121.714 2204.48,121.714 2204.27,121.757C2201.75,122.263 2195.36,123.547 2192.85,124.052C2192.63,124.095 2192.5,124.174 2192.5,124.261C2192.5,124.347 2192.63,124.426 2192.85,124.469C2195.36,124.974 2201.75,126.255 2204.27,126.759C2204.48,126.802 2204.74,126.802 2204.96,126.759C2205.18,126.716 2205.31,126.636 2205.31,126.55C2205.31,125.541 2205.31,122.976 2205.31,121.966Z"
                  />
                </clipPath>
                <g clip-path="url(#_clip5)">
                  <g transform="matrix(0.124502,0.074907,0.206623,-0.0414384,1997.62,-7.40235)">
                    <path
                      d="M1726.17,-64.249L1708.16,-72.303L1708.05,-23.514L1721.88,-32.386C1722.96,-33.241 1723.09,-33.944 1723.15,-34.636L1723.15,-54.373C1723.19,-56.238 1724.96,-57.594 1726.87,-56.686L1726.17,-64.249Z"
                      style="fill: url(#_Linear6)"
                    />
                  </g>
                  <g transform="matrix(-0.126036,0.0767377,0.569859,0.112933,2435.01,-3.09225)">
                    <path
                      d="M1726.17,-45.661L1704.47,-40.254C1706.28,-40.527 1708.14,-40.212 1708.16,-39.416L1708.16,-18.976L1726.17,-18.976L1726.17,-45.661Z"
                      style="fill: rgb(141, 81, 249)"
                    />
                  </g>
                  <g transform="matrix(-0.126036,0.0767377,0.569859,0.112933,2435.01,-3.09225)">
                    <path
                      d="M1726.17,-45.661L1726.17,-18.976L1708.16,-18.976L1708.16,-39.416C1707.79,-40.732 1704.5,-40.298 1702.68,-40.025L1726.17,-45.661ZM1705.49,-40.491C1706.2,-40.507 1706.87,-40.464 1707.4,-40.327C1708.01,-40.173 1708.48,-39.899 1708.62,-39.436C1708.62,-39.429 1708.62,-39.423 1708.62,-39.416L1708.62,-19.152C1708.62,-19.152 1725.72,-19.152 1725.72,-19.152L1725.72,-45.345L1705.49,-40.491Z"
                      style="fill: url(#_Radial7)"
                    />
                  </g>
                </g>
              </g>
            </g>
          </g>
          <defs>
            <linearGradient
              id="_Linear1"
              x1="0"
              y1="0"
              x2="1"
              y2="0"
              gradientUnits="userSpaceOnUse"
              gradientTransform="matrix(-70.0711,-0.927611,1.54482,-42.0752,2233.59,-20.1891)"
            >
              <stop offset="0" style="stop-color: rgb(141, 81, 249); stop-opacity: 1" />
              <stop offset="1" style="stop-color: rgb(116, 50, 223); stop-opacity: 1" />
            </linearGradient>
            <linearGradient
              id="_Linear2"
              x1="0"
              y1="0"
              x2="1"
              y2="0"
              gradientUnits="userSpaceOnUse"
              gradientTransform="matrix(4.78193e-15,-78.0949,78.0949,4.78193e-15,2195.72,354.021)"
            >
              <stop offset="0" style="stop-color: rgb(141, 81, 249); stop-opacity: 1" />
              <stop offset="1" style="stop-color: rgb(116, 50, 223); stop-opacity: 1" />
            </linearGradient>
            <linearGradient
              id="_Linear3"
              x1="0"
              y1="0"
              x2="1"
              y2="0"
              gradientUnits="userSpaceOnUse"
              gradientTransform="matrix(41.6089,41.5866,-41.5866,41.6089,2282.31,262.837)"
            >
              <stop offset="0" style="stop-color: rgb(211, 187, 255); stop-opacity: 1" />
              <stop offset="1" style="stop-color: rgb(211, 187, 255); stop-opacity: 0" />
            </linearGradient>
            <linearGradient
              id="_Linear4"
              x1="0"
              y1="0"
              x2="1"
              y2="0"
              gradientUnits="userSpaceOnUse"
              gradientTransform="matrix(9.25616,16.7005,-16.7005,9.25616,2215,243.712)"
            >
              <stop offset="0" style="stop-color: rgb(211, 187, 255); stop-opacity: 1" />
              <stop offset="1" style="stop-color: rgb(211, 187, 255); stop-opacity: 0" />
            </linearGradient>
            <linearGradient
              id="_Linear6"
              x1="0"
              y1="0"
              x2="1"
              y2="0"
              gradientUnits="userSpaceOnUse"
              gradientTransform="matrix(-0.130164,-61.9937,59.4003,-0.135847,1711.63,-25.7957)"
            >
              <stop offset="0" style="stop-color: rgb(116, 50, 223); stop-opacity: 1" />
              <stop offset="0.51" style="stop-color: rgb(110, 38, 217); stop-opacity: 1" />
              <stop offset="1" style="stop-color: rgb(91, 0, 197); stop-opacity: 1" />
            </linearGradient>
            <radialGradient
              id="_Radial7"
              cx="0"
              cy="0"
              r="1"
              gradientUnits="userSpaceOnUse"
              gradientTransform="matrix(13.8659,4.71436,-12.1609,5.37534,1708.16,-32.287)"
            >
              <stop offset="0" style="stop-color: rgb(211, 187, 255); stop-opacity: 1" />
              <stop offset="1" style="stop-color: rgb(211, 187, 255); stop-opacity: 0" />
            </radialGradient>
          </defs>
        </svg>
            </a>`
  }
})();