Greasy Fork

Vidéos simples sur Allociné

Corrige l'affichage des vidéos dans Allociné avec uBlock Origin

目前为 2021-08-31 提交的版本。查看 最新版本

// ==UserScript==
// @name           Vidéos simples sur Allociné
// @namespace      https://openuserjs.org/users/clemente
// @match          https://www.allocine.fr/video/*
// @version        1.1
// @author         clemente
// @license        MIT
// @description    Corrige l'affichage des vidéos dans Allociné avec uBlock Origin
// @icon           https://assets.allocine.fr/favicon/allocine.ico
// @inject-into    content
// @noframes
// @homepageURL    https://openuserjs.org/scripts/clemente/Vid%C3%A9os_simples_sur_Allocin%C3%A9
// @supportURL     https://openuserjs.org/scripts/clemente/Vid%C3%A9os_simples_sur_Allocin%C3%A9/issues
// ==/UserScript==

/* jshint esversion: 6 */

function getMetaContent(name) {
  const detectedMeta = document.querySelector(`meta[name="${name}"]`);
  if (detectedMeta) return detectedMeta.content;
  return null;
}

function replacePlayer() {
  const currentPlayer = document.querySelector(".video-card-player figure");
  const newPlayerUrl = getMetaContent("og:video:secure_url");
  if (!currentPlayer || !newPlayerUrl) return;
  
  const { width, height } = currentPlayer.getBoundingClientRect();
  const newPlayer = document.createElement('iframe');
  newPlayer.src = newPlayerUrl;
  newPlayer.width = width;
  newPlayer.height = height;
  newPlayer.allow = "fullscreen";
  currentPlayer.replaceWith(newPlayer);
}

replacePlayer();