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

Adds "View on Trakt.tv" to IMDB navbar for TV show & movie ratings, watchlist & progress.   — Powered by👉🆓 PowerSheet.ai 📊-the FREE AI powered Decentralized No-Code platform — Easy collaborative ● Smart App Creation ● Analytics ● Remote Work Management ● Planning — Auto-create ● sync ● embed ● share-Mobile, Excel & Web 3.0 Apps ● Web Extensions ● Bots ● Blockchain DBs ● BI Dashboards ● Plans ● Connectors ● Offline PWAs — Easier than spreadsheets — 🆓Sign up@👉 https://PowerSheet.ai

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

// ==UserScript==
// @name            Power IMDB:Trakt.tv Links (Powered by PowerSheet.ai 🆓 No-Code App,BI,Bot,WebExt,Blockchain Platform)
// @author          PowerSheet.ai – the FREE AI powered decentralized No-Code platform for collaborative mobile, Excel & Web 3.0 app creation, analytics, remote work management, planning & intelligent automation
// @copyright       © 2020 PowerSheet.ai – the FREE AI powered decentralized No-Code platform for collaborative mobile, Excel & Web 3.0 app creation, analytics, remote work management, planning & intelligent automation
// @description     Adds "View on Trakt.tv" to IMDB navbar for TV show & movie ratings, watchlist & progress.   — Powered by👉🆓 PowerSheet.ai 📊-the FREE AI powered Decentralized No-Code platform — Easy collaborative ● Smart App Creation ● Analytics ● Remote Work Management ● Planning — Auto-create ● sync ● embed ● share-Mobile, Excel & Web 3.0 Apps ● Web Extensions ● Bots ● Blockchain DBs ● BI Dashboards ● Plans ● Connectors ● Offline PWAs — Easier than spreadsheets — 🆓Sign up@👉 https://PowerSheet.ai
// @version         1.0.3
// @include         /^https?://(\w+\.)imdb\.com/title//
// @namespace       https://PowerSheet.ai
// @homepageURL     https://PowerSheet.ai/Free-NoCode-App-BI-Excel-Blockchain
// @supportURL      https://PowerSheet.ai/Free-NoCode-App-BI-Excel-Blockchain
// @contributionURL https://PowerSheet.ai/Free-NoCode-App-BI-Excel-Blockchain
// @updateUrl       https://greasyfork.org/scripts/402912-power-imdb-trakt-tv-links-powered-by-powersheet-ai-no-code-app-bi-bot-webext-blockchain-platform
// @license         CC-BY-NC-SA-4.0
// Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-nc-sa/4.0/)
// @grant           GM_getValue
// @grant           GM_setValue
// @inject-into     content
// @run-at          document-end
// @priority        1
// @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==
// User Script metadata docs: https://greasyfork.org/en/help/meta-keys (Name limited to 100 char, Description to 500)

// NOTE: 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.

// ● Powered by the FREE PowerSheet.ai AI powered No-Code platform for decentralized mobile, Web 3.0, Excel, offline PWA & embedded app creation, analytics, planning, remote work management and realtime collaboration anywhere.
// ● Auto-create, collaborate on, sync, automate, publish and embed your own no-code Web 3.0 & mobile smart apps, browser extensions, bots, BI dashboards, spreadsheets, plans, RPA, data connectors and embedded realtime blockchain databases.
// ● Remotely collaborative with easy AI powered analytics, planning, DApp creation, remote work management, assignments, web scraping, RPA, data prep, intelligent automation and realtime remote collaboration with Power Sheet.
// ● Instantly auto publish everywhere as mobile, Web 3.0, Excel, decentralized PWA, desktop, offline and embedded apps.
// ● Collaboratively create and embed in Excel, Microsoft Teams, PowerPoint, SharePoint, web browsers, websites, existing apps and anywhere.
// ● Simultaneously sell and share everywhere with our universal marketplace for smart apps, templates, connectors and content.
// ● Free for unlimited users.  No coding, install, server or IT setup required.
// ● Sign up 🆓 @ 👉 https://PowerSheet.ai.

(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();
    }

})();