Power IMDB: Trakt.tv Links (by PowerSheet.ai FREE No-Code App, WebExt, BI, Bot, Blockchain Platform)

Adds "View on Trakt.tv" button with direct link for each movie, TV show and video on IMDB.com so you can browse ratings & reviews, add to watchlists and track what you've watched on Trakt. <br>● Powered[br]by the **FREE** PowerSheet.ai \n AI and <a href="https://PowerSheet.ai">realtime</a> [collaboration](https://powersheet.ai) anywhere. ----------------- ● Sign up 🆓 @ 👉 https://www.powersheet.ai.

目前为 2020-05-21 提交的版本。查看 最新版本

// ==UserScript==
// @name            Power IMDB: Trakt.tv Links (by PowerSheet.ai FREE No-Code App, WebExt, BI, Bot, Blockchain Platform)
// @author          PowerSheet.ai - the FREE AI & blockchain DB powered No-Code platform & marketplace empowering anyone to create, sync, automate & share smart apps, dashboards, plans, spreadsheets, bots & connectors for Web 3.0, Excel, mobile, offline, PowerPoint, SharePoint, Microsoft Teams, web browser extensions & embedding anywhere.
// @namespace       https://PowerSheet.ai
// @homepageURL     https://PowerSheet.ai/Free-NoCode-App-BI-Excel-Blockchain
// @description     Adds "View on Trakt.tv" button with direct link for each movie, TV show and video on IMDB.com so you can browse ratings & reviews, add to watchlists and track what you've watched on Trakt. <br>● Powered[br]by the    **FREE** PowerSheet.ai \n AI and <a href="https://PowerSheet.ai">realtime</a> [collaboration](https://powersheet.ai) anywhere. ----------------- ● Sign up 🆓 @ 👉 https://www.powersheet.ai.
// for decentralized mobile, Web 3.0, Excel, offline PWA & embedded app creation
// @copyright       © 2020 PowerSheet.ai - the FREE No-Code Apps, Analytics, Blockchain DB, Bots & Collaboration Platform & Marketplace for Web 3.0, Excel & Mobile
// @updateUrl       https://greasyfork.org/scripts/402912-power-imdb-trakt-tv-links-powersheet-ai-free-no-code-apps-bi-blockchain-db-platform-marketplace
// @license         Creative Commons Attribution Non Commercial Share Alike 4.0 International (https://creativecommons.org/licenses/by-nc-sa/4.0/)
// @version         1.0.2
// @include         /^https?://(\w+\.)imdb\.com/title//
// @grant           GM_getValue
// @grant           GM_setValue
// @run-at          document-end
// @priority        1
// @inject-into     content
// @icon            https://static.wixstatic.com/media/4d2eb7_adf8916f24a74cc3934c22130df50a0f%7Emv2.png/v1/fill/w_32%2Ch_32%2Clg_1%2Cusm_0.66_1.00_0.01/4d2eb7_adf8916f24a74cc3934c22130df50a0f%7Emv2.png
// @screenshot      https://greasyfork.org/system/screenshots/screenshots/000/020/816/original/Power-IMDB-Screenshot.jpg?1588969663
// ==/UserScript==

(function () {

    const buttonLabel = 'Trakt'; //OR: 'Trakt.tv' or ''
    const traktSearchLink = 'https://trakt.tv/search/imdb?q=tt';
    const buttonPadding = '.3rem'; //reduced padding vs. original 1rem for Watchlist etc buttons
    const labelIconPadding = '4px'; //reduced padding vs. original 1rem for Watchlist etc buttons
    const buttonOrderPos = 8; //ensure it's the last button
    const tooltip = 'Open Trakt.tv page for Title';

    const linkHtml = `
  <div class="" style="
      order: ${buttonOrderPos};
  ">
    <a id="trakt-link" title="${tooltip}" target="_blank" href="${getTraktTitleUrl()}" tabindex="0" class="ipc-button ipc-button--single-padding ipc-button--default-height ipc-button--core-baseAlt ipc-button--theme-baseAlt ipc-button--on-textPrimary ipc-text-button" style="
      padding: 0 ${buttonPadding};
  ">
      <svg id="trakt-icon" width="24" height="24" version="1.1" xmlns="http://www.w3.org/2000/svg" x="0" y="0" viewBox="-334.1 223.1 347 347" xml:space="preserve">
        <style>.st1{fill:#ed2224}</style><circle cx="-160.6" cy="396.6" r="162.5" fill="#fff"></circle><path class="st1" d="M-256.9 485c23.8 26 58.1 42.2 96.3 42.2 19.5 0 37.9-4.3 54.5-11.9l-90.7-90.5-60.1 60.2z"></path><path class="st1" d="M-197.2 370.1l-68.7 68.5-9.2-9.2 72.3-72.3 84.4-84.4c-13.2-4.5-27.4-7-42.2-7-72.3 0-130.9 58.6-130.9 130.9 0 29.4 9.7 56.6 26.3 78.6l68.5-68.5 4.7 4.5 98.1 98.1c2-1.1 3.8-2.2 5.6-3.6l-108.4-108.4-65.8 65.8-9.2-9.2 75-75 4.7 4.5 114.5 114.2c1.8-1.3 3.4-2.9 4.9-4.3L-196 369.9l-1.2.2z"></path><path d="M-63.4 484.1c20.9-23.1 33.7-53.9 33.7-87.5 0-52.5-31-97.6-75.4-118.5l-82.4 82.1 124.1 123.9zM-155.9 384l-9.2-9.2 64.9-64.9 9.2 9.2-64.9 64.9zm61.5-89.1l-74.7 74.7-9.2-9.2 74.7-74.7 9.2 9.2z" fill="#ed1c24"></path><path class="st1" d="M-160.6 559.1c-89.6 0-162.5-72.9-162.5-162.5s72.9-162.5 162.5-162.5S1.9 307 1.9 396.6-71 559.1-160.6 559.1zm0-308.6c-80.6 0-146.1 65.5-146.1 146.1s65.5 146.1 146.1 146.1 146.1-65.5 146.1-146.1S-80 250.5-160.6 250.5z"></path>
      </svg>
    <div class="trakt-text ipc-button__text" style="
      padding-left: ${labelIconPadding};
  ">${buttonLabel}</div>
    </a>
  </div>
  `;

    //insert as last child of navbar
    const topNav = document.getElementsByClassName('ipc-page-content-container')[0];
    topNav.insertAdjacentHTML('beforeEnd', linkHtml);

    function getIMDBid () {
    //get just the number after 'tt' from page URL
        const regexImdbNum = /\/title\/tt(\d{7})\//;
        const parts = regexImdbNum.exec(document.location);
        return parts[1];
    }

    function getTraktTitleUrl() {
        return traktSearchLink + getIMDBid();
    }

})();