Greasy Fork

Filmweb.pl - Check on IMDb, RottenTomatoes and more

Adds buttons to imdb.com, rottentomatoes.com, metacritic.com, upflix.pl, boxofficemojo.com

目前为 2023-07-04 提交的版本。查看 最新版本

// ==UserScript==
// @name           Filmweb.pl - Check on IMDb, RottenTomatoes and more
// @name:pl        Filmweb.pl - Zobacz na IMDb, RottenTomatoes i innych
// @namespace      https://greasyfork.org/users/124677-pabli
// @version        0.5
// @description    Adds buttons to imdb.com, rottentomatoes.com, metacritic.com, upflix.pl, boxofficemojo.com
// @description:pl Dodaje przyciski do imdb.com, rottentomatoes.com, metacritic.com, upflix.pl, boxofficemojo.com
// @author         Pabli
// @license        MIT
// @icon           https://icons.duckduckgo.com/ip3/www.filmweb.pl.ico

// @match          http*://www.filmweb.pl/serial/*
// @match          http*://www.filmweb.pl/film/*

// @match          http*://www.imdb.com/find/*
// @match          http*://www.rottentomatoes.com/search*
// @match          http*://www.metacritic.com/search/*
// @match          http*://www.boxofficemojo.com/search/*
// @match          http*://upflix.pl/wszystkie/*

// @grant          GM_addStyle
// @grant          GM_getValue
// @grant          GM_setValue
// @grant          GM_registerMenuCommand
// ==/UserScript==

(function() {
    'use strict';

const hostName = window.location.hostname
const urlParams = new URLSearchParams(window.location.search)

if (hostName == 'www.filmweb.pl') {
	const ogTitle = document.querySelector('.filmCoverSection__originalTitle')
	let title = ogTitle ? ogTitle.innerText : document.querySelector('.filmCoverSection__title').innerText
	title = encodeURIComponent(title)
	const year = document.querySelector('.filmCoverSection__year').innerText
	const section = document.querySelector('.filmCoverSection__filmPreview')
	let linkDiv = document.createElement("div")
	linkDiv.setAttribute("id", "zobaczna");
	section.appendChild(linkDiv)
	const path = window.location.pathname.split('/')
	const movieTv = path[1] === 'film' ? 'movie' : 'tv'

	function link(search,website,name) {
		let button = `<a href='${search}' title='Zobacz na ${website}' target='_blank'><img src='https://icons.duckduckgo.com/ip3/www.${website}.ico' width='16'><span>${name}</span></a>`
		linkDiv.innerHTML += button
	}

	link(`https://www.imdb.com/find?q=${title} ${year}&filmweb`, 'imdb.com', 'IMDb')
	link(`https://www.rottentomatoes.com/search/?search=${title}&filmweb=${movieTv}`, 'rottentomatoes.com', 'Rotten Tomatoes')
	link(`https://www.metacritic.com/search/${movieTv}/${title}/results?filmweb`, 'metacritic.com', 'metacritic')
	link(`https://upflix.pl/wszystkie/${title}?filmweb`, 'upflix.pl', 'upflix')
	if (path[1] === 'film') link(`https://www.boxofficemojo.com/search/?q=${title} ${year}&filmweb`, 'boxofficemojo.com', 'BoxOfficeMojo')

	GM_addStyle(`
#zobaczna {
    max-width: 705px;
}
#zobaczna a {
    display: inline-flex;
    align-items: center;
    margin-top: 5px;
    margin-right: 5px;
    color: #ccc;
    border-radius: 0.125rem;
    border: 1px solid var(--main-border-color, rgba(172, 172, 172, .3));
    transition: border-color .3s cubic-bezier(.25,.46,.45,.94);
    padding: 5px 10px;
}
#zobaczna a:hover {
    border-color: #888;
}
#zobaczna img {
    width: 16px;
    margin-right: 5px;
}
.filmCoverSection__ratings {
	height: auto !important;
}
`)
}

// open first search result automatically
if (urlParams.has('filmweb')) {
	let movieTv = urlParams.get("filmweb") === "movie" ? "movie" : "tvSeries"
	switch (hostName) {
		case 'www.imdb.com': document.querySelector('.ipc-metadata-list-summary-item__t').click(); break;
		case 'www.rottentomatoes.com': document.querySelector(`[type="${movieTv}"] search-page-media-row:nth-child(1) a`).click(); break;
		case 'www.metacritic.com': document.querySelector('.product_title.basic_stat a').click(); break;
		case 'upflix.pl': document.querySelector('div.video > div > div.info > h3 > a').click(); break;
		case 'www.boxofficemojo.com': document.querySelector('.a-size-medium.a-link-normal.a-text-bold').click(); break;
	}
}

})();