Greasy Fork

来自缓存

Greasy Fork is available in English.

Letterboxd to RYM Search

A handy ChatGPT userscript that adds a button below the film poster on Letterboxd, allowing you to search for the same film on RateYourMusic

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Letterboxd to RYM Search
// @version      0.5
// @description  A handy ChatGPT userscript that adds a button below the film poster on Letterboxd, allowing you to search for the same film on RateYourMusic
// @author       ChatGPT
// @namespace    https://gist.github.com/Fooftilly
// @match        https://letterboxd.com/film/*
// @grant        none
// @license      none
// ==/UserScript==

(function() {
  'use strict';

  function encodeMovieTitle(title) {
    return encodeURIComponent(title);
  }

  function createRYMSearchURL(title) {
    const encodedTitle = encodeMovieTitle(title);
    return `https://rateyourmusic.com/search?searchterm=${encodedTitle}&searchtype=F`;
  }

  function addRYMSearchButton() {
    const movieTitleElement = document.querySelector('h1.headline-1');
    const filmStatsElement = document.querySelector('.film-stats');

    if (movieTitleElement && filmStatsElement) {
      const movieTitle = movieTitleElement.innerText;
      const rymSearchURL = createRYMSearchURL(movieTitle);

      const rymButton = document.createElement('a');
      rymButton.innerText = 'Search title on RYM';
      rymButton.href = rymSearchURL;
      rymButton.target = '_blank';

      // Apply styles to the button
      rymButton.style.display = 'inline-block';
      rymButton.style.margin = '10px auto';
      rymButton.style.padding = '5px 10px';
      rymButton.style.border = '1px solid #1c1c1c';
      rymButton.style.borderRadius = '4px';
      rymButton.style.fontSize = '14px';
      rymButton.style.fontWeight = '500';
      rymButton.style.textDecoration = 'none';
      rymButton.style.color = '#1c1c1c';
      rymButton.style.background = '#f5f5f5';

      // Create a new div to hold the button
      const buttonDiv = document.createElement('div');
      buttonDiv.appendChild(rymButton);

      // Apply styles to center the button within the div
      buttonDiv.style.textAlign = 'center';
      buttonDiv.style.width = '100%';

      // Append the new div below the film-stats element
      filmStatsElement.parentElement.appendChild(buttonDiv);

    } else {
      console.error('Could not find the necessary elements.');
    }
  }

  // Try adding the button after a delay to give the page more time to load
  setTimeout(addRYMSearchButton, 2000);

})();