Greasy Fork

Greasy Fork is available in English.

Criticker Letterboxd Search Button

Adds a button to search the movie on Letterboxd

当前为 2021-06-01 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Criticker Letterboxd Search Button
// @namespace    https://www.criticker.com/
// @version      1.0
// @description  Adds a button to search the movie on Letterboxd
// @author       n00bCod3r (https://github.com/n00bCod3rr)
// @match        https://www.criticker.com/films*
// @grant        none
// ==/UserScript==

(function() {

  'use strict';
  function formatTitle(title) {
    title.trim();
    title = title.replaceAll('#','%23')
    title = title.replaceAll('+','%2B')
    title = title.replaceAll('&','%26')
    title = title.replaceAll('\'','%27')
    title = title.replaceAll('?', '%3F')
    title = title.replaceAll(' ', '+')
    return title;
  }

  //lbx logo
  const logoURL = 'https://a.ltrbxd.com/logos/letterboxd-decal-dots-pos-rgb-500px.png';
  //all li elements
  const titlesList = document.querySelectorAll('main>ul.fl_titlelist li');
  titlesList.forEach(el => {
    const div = el.querySelector('.fl_name'); //cotnains <a> with movie info
    console.log(div);
    const title = formatTitle(div.querySelector('a').title);
    //search link for the movie
    const lbxURL = `https://letterboxd.com/search/films/${title}/`;
    //<a> containing the lbx logo image
    const imgAnchor = document.createElement('a');
    imgAnchor.href = lbxURL;
    imgAnchor.target = "blank";
    imgAnchor.rel = "noopener noreferrer";
    //lbx logo image
    const img = document.createElement('img');
    img.src = logoURL;
    img.width = '20';
    imgAnchor.appendChild(img);
    div.prepend(imgAnchor);
  })

})();