Skip to content

Ombi imdb/letterboxd button script #5249

@nononolimits

Description

@nononolimits

Summary

Asked chatgpt to create me a script that adds button to imdb/letterboxd (next to title of movie), if you click on it, you get redirected to your Ombi session and said movie will appear there right away:

// ==UserScript==

// @name IMDb & Letterboxd → Ombi Discover Button
// @namespace https://greasyfork.org/users/yourname
// @Version 1.3
// @description Adds a button to IMDb and Letterboxd movie pages to search for the movie in Ombi Discover
// @match https://www.imdb.com/title/*
// @match https://letterboxd.com/film/*
// @grant none
// ==/UserScript==

(function() {
'use strict';

/***** CONFIGURATION *****/
// Change this to the base URL of your Ombi instance (no trailing slash)
const OMBI_URL = 'https://ombi.example.com';
/*************************/

// Wait for an element to appear
function waitForElement(selector) {
    return new Promise(resolve => {
        const check = setInterval(() => {
            const el = document.querySelector(selector);
            if (el && el.textContent.trim().length > 0) {
                clearInterval(check);
                resolve(el);
            }
        }, 300);
    });
}

async function main() {
    let movieTitle = '';
    let insertTarget = null;

    if (location.hostname.includes('imdb.com')) {
        const titleEl = await waitForElement('h1[data-testid="hero-title-block__title"], h1');
        movieTitle = titleEl.textContent.trim().replace(/\(\d{4}\)$/, '').trim();
        insertTarget = titleEl.parentNode;
    }

    if (location.hostname.includes('letterboxd.com')) {
        const titleEl = await waitForElement('h1.headline-1');
        movieTitle = titleEl.textContent.trim().replace(/\(\d{4}\)$/, '').trim();
        insertTarget = titleEl.parentNode;
    }

    if (!movieTitle || !insertTarget) return;

    const searchUrl = `${OMBI_URL}/discover/${encodeURIComponent(movieTitle)}`;

    const btn = document.createElement('a');
    btn.textContent = 'Search in Ombi';
    btn.href = searchUrl;
    btn.target = '_blank';
    btn.style.cssText = `
        display: inline-block;
        margin-left: 10px;
        padding: 6px 10px;
        background: #f5c518;
        color: black;
        font-weight: bold;
        border-radius: 4px;
        text-decoration: none;
    `;
    btn.addEventListener('mouseover', () => btn.style.background = '#e4b216');
    btn.addEventListener('mouseout', () => btn.style.background = '#f5c518');

    insertTarget.appendChild(btn);
}

main();

})();

You can add this script to your Tampermonkey plugin in chrome. Worked right away for me.

Ombi Version

latest

What platform(s) does this occur on?

Windows

What database are you using?

SQLite (Default)

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions