Raw Source
ni554n / PSARips Replace Movie Post Title with IMDb Link

// ==UserScript==

// @name                PSARips Replace Movie Post Title with IMDb Link
// @description         Turns a PSARips Movie or TV Show post title into a direct IMDb link or IMDb search link.
// @version             2.5

// @namespace           io.github.ni554n
// @match               https://psarips.*/movie/*
// @match               https://psarips.*/tv-show/*
// @match               https://psa.*/movie/*
// @match               https://psa.*/tv-show/*
// @match               https://x265.club/movie/*
// @match               https://x265.club/tv-show/*

// @updateURL           https://github.com/ni554n/userscripts/raw/master/psarips/replace-post-titles-with-imdb-links/script.user.js
// @supportURL          https://github.com/ni554n/userscripts/issues
// @license             MIT

// @author              Nissan Ahmed
// @homepageURL         https://ni554n.github.io/
// @contributionURL     https://paypal.me/ni554n

// ==/UserScript==

/* Migration Notice */

console.log(`
 █████  ████████ ████████ ███████ ███    ██ ████████ ██  ██████  ███    ██ 
██   ██    ██       ██    ██      ████   ██    ██    ██ ██    ██ ████   ██ 
███████    ██       ██    █████   ██ ██  ██    ██    ██ ██    ██ ██ ██  ██ 
██   ██    ██       ██    ██      ██  ██ ██    ██    ██ ██    ██ ██  ██ ██ 
██   ██    ██       ██    ███████ ██   ████    ██    ██  ██████  ██   ████ 
                                                                           
                                                                           
`)

console.log(
`Thanks for using "PSARips Replace Movie Post Title with IMDb Link" userscript downloaded from OpenUserJS.

You are seeing this message because due to a change introduced in OpenUserJS,
future updates to this script will no longer be vaiable.

If you like to get updates in the future, please open your userscript manager program,
and remove the "PSARips Replace Movie Post Title with IMDb Link" script.

Then head over to this Github link and install this script again.
https://github.com/ni554n/userscripts/blob/master/psarips/replace-post-titles-with-imdb-links#installation

It's very easy to do and will take only 3-4 clicks.

Sorry for the inconvenience!`
);


const [postTitleH1] = document.getElementsByClassName("post-title entry-title");
const releaseTitle = postTitleH1?.innerText;

if (!postTitleH1) throw new Error("Failed to get the post title!");

// Extract the IMDb link from the movie release info section.
const [imdbMovieLink] =
  document
    .getElementsByClassName("sp-body folded")[0]
    ?.innerText.match(/https:\/\/www.imdb.com\/title\/\w+\//) ?? [];

const imdbLink = imdbMovieLink
  ? imdbMovieLink
  : `https://www.imdb.com/find?s=tt&ttype=tv&q=${encodeURIComponent(
      releaseTitle,
    )}`;

// Icons are from the bundled Font Awesome library.
const imdbIcon = `<i class="fab fa-imdb" style="font-style: normal;"></i>`;
const linkIcon = `<i class="fas fa-external-link-alt" style="font-size: 0.6em; font-style: normal;"></i>`;

postTitleH1.innerHTML = `<a href="${imdbLink}" title="Open IMDb" target="_blank">${imdbIcon} ${releaseTitle} ${linkIcon}</a>`;