Letterboxd movie length user script
This snippet converts the length on Letterboxd (in minutes) to show in hours+minutes.
You may install it as a user script.
A user script requires a browser extension to work. Several are available, including Violentmonkey which works in Firefox, Chrome and Edge. Safari has Userscripts. Once the extension is installed, simply use this link to install the user script.
/*
* Copyright (C) Eskild Hustvedt 2023
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
// ==UserScript==
// @name letterboxd-length
// @namespace zerodogg.org
// @version 0.1
// @description Convert letterboxd minutes to hours:minutes
// @author Eskild Hustvedt
// @license AGPLv3 - http://www.gnu.org/licenses/agpl-3.0.txt
// @match https://letterboxd.com/film/*
// ==/UserScript==
((document) => {
const element = document.querySelector("#film-page-wrapper .text-footer");
if (element === null) {
return;
}
const totalMinutes = element.innerText.replace(/^\s*(\d+)\s+min.*/s, "$1");
const hours = Math.floor(totalMinutes / 60);
const minutes = totalMinutes - hours * 60;
if (Number.isNaN(hours) || Number.isNaN(minutes)) {
return;
}
const newDiv = document.createElement("div");
newDiv.innerText = "(" + hours + "h " + minutes + "min)";
element.append(newDiv);
})(document);